(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 32391, 1055]*) (*NotebookOutlinePosition[ 33232, 1082]*) (* CellTagsIndexPosition[ 33188, 1078]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Say No to Loops!", "Title"], Cell[TextData[{ "One of the reasons people who are used to C, GAUSS, FORTRAN, etc, find ", StyleBox["Mathematica", FontSlant->"Italic"], " a bit strange to begin with is that they are used to \"procedural\" \ programming styles instead of \"functional\" programming. So when they start \ to program in ", StyleBox["Mathematica", FontSlant->"Italic"], " and use the loops and nested If[] statements and what-not, they think ", StyleBox["Mathematica", FontSlant->"Italic"], " is slow.\n\nThis notebook shows just how much you can speed up your \ computations in ", StyleBox["Mathematica", FontSlant->"Italic"], " by using functional programming instead of a loop. The only problem is \ you have to be a bit more lateral in your approach to the problem." }], "Text"], Cell[CellGroupData[{ Cell["The Problem: generating artificial ARMA time series.", "Subsection"], Cell[TextData[{ "Anyone who's done econometrics or time series work would be familiar with \ this sort of process:\n\n\t", Cell[BoxData[ \(TraditionalForm \`y\_t = \[Sum]\+\(i = 1\)\%p\( \[Phi]\_i\) y\_\(t - 1\)\ + \[Sum]\+\(j = 0\)\%q\( \[Theta]\_j\) \[Epsilon]\_\(t - j\)\)]], "\n\nThe \[Epsilon]'s are usually normally distributed, or at least iid. \ (should that be \"normally normally\").\n\nSuppose you want to create a \ function that generates artificial ARMA processes. You'd probably do \ something like this:" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Version 1: Use a loop.", "Subsection"], Cell[BoxData[ RowBox[{ \(ARMAlist[length_Integer, sv_, sd_Real, pcoefs_List, qcoefs_List]\), ":=", RowBox[{"If", "[", RowBox[{ \(Length[Dimensions[pcoefs]] == 1 && Length[Dimensions[qcoefs]] == 1\), ",", RowBox[{"Module", "[", RowBox[{ \({shocklist, maparts, q, \n\t\t\t\tp, qplus, thelist}\), ",", "\n", "\t\t\t", RowBox[{ RowBox[{ StyleBox["p", FontColor->GrayLevel[0.333333]], "=", \(Length[pcoefs]\)}], ";", "\n", "\t\t\t", RowBox[{ StyleBox["q", FontColor->GrayLevel[0.333333]], "=", \(Length[qcoefs]\)}], ";", "\n", "\t\t\t", RowBox[{ StyleBox["qplus", FontColor->GrayLevel[0.333333]], "=", " ", \(Reverse[Join[{1}, qcoefs]]\)}], ";", "\n", "\t\t\t", RowBox[{ StyleBox["shocklist", FontColor->GrayLevel[0.333333]], "=", \(RandomArray[NormalDistribution[0, sd], length + Max[p, q]\ ]\)}], ";", "\n", "\t\t\t", RowBox[{ StyleBox["maparts", FontColor->GrayLevel[0.333333]], "=", \(Expand/@\ \n\t\t\t\t\t Table[qplus.shocklist \[LeftDoubleBracket]Range[t - q, t] \[RightDoubleBracket], {t, q + 1, length + q}] \)}], ";", "\n", "\t\t\t", RowBox[{ StyleBox["thelist", FontColor->GrayLevel[0.333333]], "=", "\n", "\t\t\t\t", \(Join[Table[sv, {p}], Table[0, {length}]]\)}], ";", \(Do[thelist = ReplacePart[thelist, \n\t\t\t pcoefs.Reverse[ thelist \[LeftDoubleBracket]Range[i - p, i - 1] \[RightDoubleBracket]] + maparts \[LeftDoubleBracket]i - p\[RightDoubleBracket], i], {i, p + 1, length + p}]\), ";", StyleBox[\(Drop[thelist, p]\), FontColor->RGBColor[0, 0, 1]]}]}], " ", "]"}], ",", \(Message[ARMAlist::"\"]\)}], "]"}]}]], "Input", PageWidth->PaperWidth, AspectRatioFixed->True], Cell["\<\ Here are the timings for generating 1000 to 12 000 artificial data \ points on a Power Mac G3 (233 MHz):\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(timingtesttable1 = Table[Timing[ ARMAlist[1000\ i, 0, 0.5, {0.9, 0.09}, {0.8, 0.8, 0.5}]; ], {i, 1, 8}]\)], "Input"], Cell[BoxData[ \({{0.866666666666787932`\ Second, Null}, {2.78333333333284826`\ Second, Null}, {5.9499999999998181`\ Second, Null}, { 10.0833333333339392`\ Second, Null}, {15.4666666666662422`\ Second, Null}, {22.4833333333335749`\ Second, Null}, { 30.03333333333285`\ Second, Null}, {38.5`\ Second, Null}}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(ListPlot[\((First/@timingtesttable1)\)/Second]\)], "Input"], Cell[GraphicsData["PostScript", "\<\ %! %%Creator: Mathematica %%AspectRatio: .61803 MathPictureStart /Mabs { Mgmatrix idtransform Mtmatrix dtransform } bind def /Mabsadd { Mabs 3 -1 roll add 3 1 roll add exch } bind def %% Graphics /Courier findfont 10 scalefont setfont % Scaling calculations -0.112245 0.136054 0.00116 0.0156405 [ [.15986 -0.01134 -3 -9 ] [.15986 -0.01134 3 0 ] [.29592 -0.01134 -3 -9 ] [.29592 -0.01134 3 0 ] [.43197 -0.01134 -3 -9 ] [.43197 -0.01134 3 0 ] [.56803 -0.01134 -3 -9 ] [.56803 -0.01134 3 0 ] [.70408 -0.01134 -3 -9 ] [.70408 -0.01134 3 0 ] [.84014 -0.01134 -3 -9 ] [.84014 -0.01134 3 0 ] [.97619 -0.01134 -3 -9 ] [.97619 -0.01134 3 0 ] [.01131 .07936 -6 -4.5 ] [.01131 .07936 0 4.5 ] [.01131 .15756 -12 -4.5 ] [.01131 .15756 0 4.5 ] [.01131 .23577 -12 -4.5 ] [.01131 .23577 0 4.5 ] [.01131 .31397 -12 -4.5 ] [.01131 .31397 0 4.5 ] [.01131 .39217 -12 -4.5 ] [.01131 .39217 0 4.5 ] [.01131 .47037 -12 -4.5 ] [.01131 .47037 0 4.5 ] [.01131 .54858 -12 -4.5 ] [.01131 .54858 0 4.5 ] [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 g .25 Mabswid [ ] 0 setdash .15986 .00116 m .15986 .00741 L s [(2)] .15986 -0.01134 0 1 Mshowa .29592 .00116 m .29592 .00741 L s [(3)] .29592 -0.01134 0 1 Mshowa .43197 .00116 m .43197 .00741 L s [(4)] .43197 -0.01134 0 1 Mshowa .56803 .00116 m .56803 .00741 L s [(5)] .56803 -0.01134 0 1 Mshowa .70408 .00116 m .70408 .00741 L s [(6)] .70408 -0.01134 0 1 Mshowa .84014 .00116 m .84014 .00741 L s [(7)] .84014 -0.01134 0 1 Mshowa .97619 .00116 m .97619 .00741 L s [(8)] .97619 -0.01134 0 1 Mshowa .125 Mabswid .05102 .00116 m .05102 .00491 L s .07823 .00116 m .07823 .00491 L s .10544 .00116 m .10544 .00491 L s .13265 .00116 m .13265 .00491 L s .18707 .00116 m .18707 .00491 L s .21429 .00116 m .21429 .00491 L s .2415 .00116 m .2415 .00491 L s .26871 .00116 m .26871 .00491 L s .32313 .00116 m .32313 .00491 L s .35034 .00116 m .35034 .00491 L s .37755 .00116 m .37755 .00491 L s .40476 .00116 m .40476 .00491 L s .45918 .00116 m .45918 .00491 L s .48639 .00116 m .48639 .00491 L s .51361 .00116 m .51361 .00491 L s .54082 .00116 m .54082 .00491 L s .59524 .00116 m .59524 .00491 L s .62245 .00116 m .62245 .00491 L s .64966 .00116 m .64966 .00491 L s .67687 .00116 m .67687 .00491 L s .73129 .00116 m .73129 .00491 L s .7585 .00116 m .7585 .00491 L s .78571 .00116 m .78571 .00491 L s .81293 .00116 m .81293 .00491 L s .86735 .00116 m .86735 .00491 L s .89456 .00116 m .89456 .00491 L s .92177 .00116 m .92177 .00491 L s .94898 .00116 m .94898 .00491 L s .25 Mabswid 0 .00116 m 1 .00116 L s .02381 .07936 m .03006 .07936 L s [(5)] .01131 .07936 1 0 Mshowa .02381 .15756 m .03006 .15756 L s [(10)] .01131 .15756 1 0 Mshowa .02381 .23577 m .03006 .23577 L s [(15)] .01131 .23577 1 0 Mshowa .02381 .31397 m .03006 .31397 L s [(20)] .01131 .31397 1 0 Mshowa .02381 .39217 m .03006 .39217 L s [(25)] .01131 .39217 1 0 Mshowa .02381 .47037 m .03006 .47037 L s [(30)] .01131 .47037 1 0 Mshowa .02381 .54858 m .03006 .54858 L s [(35)] .01131 .54858 1 0 Mshowa .125 Mabswid .02381 .0168 m .02756 .0168 L s .02381 .03244 m .02756 .03244 L s .02381 .04808 m .02756 .04808 L s .02381 .06372 m .02756 .06372 L s .02381 .095 m .02756 .095 L s .02381 .11064 m .02756 .11064 L s .02381 .12628 m .02756 .12628 L s .02381 .14192 m .02756 .14192 L s .02381 .17321 m .02756 .17321 L s .02381 .18885 m .02756 .18885 L s .02381 .20449 m .02756 .20449 L s .02381 .22013 m .02756 .22013 L s .02381 .25141 m .02756 .25141 L s .02381 .26705 m .02756 .26705 L s .02381 .28269 m .02756 .28269 L s .02381 .29833 m .02756 .29833 L s .02381 .32961 m .02756 .32961 L s .02381 .34525 m .02756 .34525 L s .02381 .36089 m .02756 .36089 L s .02381 .37653 m .02756 .37653 L s .02381 .40781 m .02756 .40781 L s .02381 .42345 m .02756 .42345 L s .02381 .43909 m .02756 .43909 L s .02381 .45473 m .02756 .45473 L s .02381 .48602 m .02756 .48602 L s .02381 .50166 m .02756 .50166 L s .02381 .5173 m .02756 .5173 L s .02381 .53294 m .02756 .53294 L s .02381 .56422 m .02756 .56422 L s .02381 .57986 m .02756 .57986 L s .02381 .5955 m .02756 .5955 L s .02381 .61114 m .02756 .61114 L s .25 Mabswid .02381 0 m .02381 .61803 L s 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath .008 w .02381 .01472 Mdot .15986 .04469 Mdot .29592 .09422 Mdot .43197 .15887 Mdot .56803 .24307 Mdot .70408 .35281 Mdot .84014 .4709 Mdot .97619 .60332 Mdot % End of Graphics MathPictureEnd \ \>"], "Graphics", ImageSize->{288, 177.938}, ImageMargins->{{43, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, ImageCache->GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHg7oo 00<007ooOol08goo00<007ooOol087oo00<007ooOol08goo00<007ooOol07Woo00@007ooOol0025o o`03001oogoo025oo`04001oogoo000;Ool003Uoo`03001oogoo029oo`03001oogoo01ioo`@002Ao o`03001oogoo01ioo`04001oogoo000ROol00`00Oomoo`0POol01000Oomoo`002goo000jOol00`00 Oomoo`0OOol2000QOol00`00Ool0000ROol3000QOol3000SOol00`00Oomoo`0QOol2000Ioo`0057oo0P008Woo0P00iWoo 000DOol00`00Oomoo`3oOol:Ool001Aoo`03001oogoo0?moo`Yoo`0057oo00<007ooOol0ogoo2Woo 000DOol00`00Oomoo`3oOol:Ool001Aoo`800?moo`]oo`0057oo00<007ooOol0ogoo2Woo000Ool2001iOol001Aoo`03001oogoo0?moo`Yoo`00 57oo0P00ogoo2goo000DOol00`00Oomoo`3oOol:Ool001Aoo`03001oogoo0?moo`Yoo`0057oo00<0 07ooOol0ogoo2Woo000DOol2003oOol;Ool001Aoo`03001oogoo0?moo`Yoo`0057oo00<007ooOol0 ogoo2Woo000DOol00`00Oomoo`3oOol:Ool001Aoo`800?moo`]oo`0057oo00<007ooOol0ogoo2Woo 000DOol00`00Oomoo`3oOol:Ool001Aoo`03001oogoo0?moo`Yoo`0057oo0P00ogoo2goo000DOol0 0`00Oomoo`3oOol:Ool000Ioo`@000=oo`8000Eoo`03001oogoo0?moo`Yoo`001goo00<007ooOol0 0Woo00@007ooOol000Aoo`03001oogoo0?moo`Yoo`0027oo00D007ooOomoo`00009oo`03001oogoo 009oo`<00?moo`Yoo`002Goo00@007ooOol0009oo`03001oogoo009oo`03001oogoo0?moo`Yoo`00 1Woo00@007ooOol0009oo`04001oogoo0004Ool00`00Oomoo`3oOol:Ool000Moo`8000Aoo`8000Eo o`03001oogoo0?moo`Yoo`0057oo00<007ooOol0ogoo2Woo000DOol2003oOol;Ool001Aoo`03001o ogoo0?moo`Yoo`0057oo00<007ooOol0ogoo2Woo000DOol00`00Oomoo`3oOol:Ool001Aoo`800?mo o`]oo`0057oo00<007ooOol0/Woo0P00EGoo000DOol00`00Oomoo`2bOol2001EOol001Aoo`03001o ogoo0?moo`Yoo`0057oo0P00ogoo2goo000DOol00`00Oomoo`3oOol:Ool001Aoo`03001oogoo0?mo o`Yoo`0057oo00<007ooOol0ogoo2Woo000DOol2003oOol;Ool001Aoo`03001oogoo0?moo`Yoo`00 1Woo10000Woo0`001Goo00<007ooOol0ogoo2Woo0007Ool00`00Oomoo`05Ool00`00Oomoo`02Ool0 0`00Oomoo`3oOol:Ool000Qoo`03001oogoo00Aoo`03001oogoo009oo`<00?moo`Yoo`002Goo00<0 07ooOol00`001Goo00<007ooOol0ogoo2Woo0006Ool01000Oomoo`000Woo00<007ooOol01Goo00<0 07ooOol0ogoo2Woo0007Ool20003Ool40004Ool00`00Oomoo`3oOol:Ool001Aoo`800?moo`]oo`00 57oo00<007ooOol0ogoo2Woo000DOol00`00Oomoo`3oOol:Ool001Aoo`03001oogoo0?moo`Yoo`00 57oo00<007ooOol0ogoo2Woo000DOol2003oOol;Ool001Aoo`03001oogoo0?moo`Yoo`0057oo00<0 07ooOol0ogoo2Woo000DOol00`00Oomoo`3oOol:Ool001Aoo`800?moo`]oo`0057oo00<007ooOol0 ogoo2Woo000DOol00`00Oomoo`3oOol:Ool001Aoo`03001oogoo0?moo`Yoo`0057oo0P00ogoo2goo 000DOol00`00Oomoo`3oOol:Ool000Ioo`<000Aoo`8000Eoo`03001oogoo0?moo`Yoo`002Goo00@0 07ooOol0009oo`03001oogoo009oo`03001oogoo0?moo`Yoo`002Goo00@007ooOol0009oo`03001o ogoo009oo`<00=Moo`80031oo`001goo0P000goo00@007ooOol000Aoo`03001oogoo0=Moo`80031o o`002Goo00@007ooOol0009oo`03001oogoo009oo`03001oogoo0?moo`Yoo`001Woo0`0017oo0P00 1Goo00<007ooOol0ogoo2Woo000DOol2003oOol;Ool001Aoo`03001oogoo0?moo`Yoo`0057oo00<0 07ooOol0ogoo2Woo000DOol00`00Oomoo`3oOol:Ool001Aoo`800?moo`]oo`0057oo00<007ooOol0 ogoo2Woo000DOol00`00Oomoo`3oOol:Ool001Aoo`03001oogoo0?moo`Yoo`0057oo00<007ooOol0 ogoo2Woo000DOol2003oOol;Ool001Aoo`03001oogoo0?moo`Yoo`0057oo00<007ooOol0ogoo2Woo 000DOol00`00Oomoo`3oOol:Ool001Aoo`800?moo`]oo`0057oo00<007ooOol0ogoo2Woo0006Ool3 0003Ool30005Ool00`00Oomoo`3oOol:Ool000Uoo`03001oogoo00=oo`03001oogoo009oo`03001o ogoo0?moo`Yoo`002Goo00<007ooOol00goo00<007ooOol00Woo0`00ogoo2Woo0007Ool20003Ool3 0005Ool00`00Oomoo`3oOol:Ool000Uoo`04001oogoo0007Ool00`00Oomoo`3oOol:Ool000Ioo`<0 00=oo`@000Aoo`03001oogoo0?moo`Yoo`0057oo0P00ogoo2goo000DOol00`00Oomoo`3oOol:Ool0 01Aoo`03001oogoo0?moo`Yoo`0057oo00<007ooOol0ogoo2Woo000DOol2003oOol;Ool001Aoo`03 001oogoo0?moo`Yoo`0057oo00<007ooOol0ogoo2Woo000DOol00`00Oomoo`3oOol:Ool001Aoo`80 0?moo`]oo`0057oo00<007ooOol0ogoo2Woo000DOol00`00Oomoo`3kOol2000"], ImageRangeCache->{{{0, 287}, {176.938, 0}} -> {0.42352, -2.95593, 0.0275455, 0.239614}}], Cell[BoxData[ TagBox[\(\[SkeletonIndicator] Graphics \[SkeletonIndicator]\), False, Editable->False]], "Output"] }, Open ]], Cell["\<\ Ok, so this first version looks OK, runs reasonably well. But \ there is a better way. Functional programming is quicker than that \ loop.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Version 2: Functional Programming", "Subsection"], Cell[BoxData[ \(ARMAList[n_Integer, sv_, sd_Real, pcoefs : {_, __}, qcoefs_?VectorQ] /; \ VectorQ[pcoefs] := \ With[{p = Length[pcoefs], q = Length[qcoefs], macoefs = Flatten[Reverse[Join[{1}, qcoefs]]], rpcoefs = Reverse[pcoefs], rawshocks = RandomArray[NormalDistribution[0, sd], n + Length[qcoefs]]}, With[{mabit = Expand\ /@ \((Take[ \((macoefs. \((\(RotateLeft[rawshocks, #]&\)\ /@\ Range[0, q])\)) \), n])\)}, \n\t\t\t Rest[Last\ /@\ \((FoldList[Join[Rest[#1], {rpcoefs.#1\ + #2}]&, Table[sv, {p}], mabit])\)]\ ]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(timingtesttable = Table[Timing[ ARMAList[1000\ i, 0, 0.5, {0.9, 0.09}, {0.8, 0.8, 0.5}]; ], {i, 1, 30}]\)], "Input"], Cell[BoxData[ \({{0.149999999999636202`\ Second, Null}, {0.333333333333030168`\ Second, Null}, {0.483333333333575865`\ Second, Null}, { 0.650000000000545696`\ Second, Null}, {0.799999999999272404`\ Second, Null}, {0.96666666666715173`\ Second, Null}, { 1.11666666666678793`\ Second, Null}, {1.2999999999992724`\ Second, Null}, {1.48333333333357586`\ Second, Null}, { 1.60000000000036379`\ Second, Null}, {1.78333333333284826`\ Second, Null}, {1.98333333333357586`\ Second, Null}, { 2.13333333333321206`\ Second, Null}, {2.28333333333375776`\ Second, Null}, {2.43333333333339396`\ Second, Null}, { 2.6499999999996362`\ Second, Null}, {2.78333333333375776`\ Second, Null}, {2.9499999999998181`\ Second, Null}, { 3.21666666666624223`\ Second, Null}, {3.23333333333357586`\ Second, Null}, {3.43333333333339396`\ Second, Null}, { 3.6499999999996362`\ Second, Null}, {3.76666666666733362`\ Second, Null}, {3.96666666666624223`\ Second, Null}, { 4.10000000000036379`\ Second, Null}, {4.26666666666642413`\ Second, Null}, {4.4499999999998181`\ Second, Null}, { 4.61666666666678793`\ Second, Null}, {4.81666666666660603`\ Second, Null}, {4.9499999999998181`\ Second, Null}}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(ListPlot[\((First/@timingtesttable)\)/Second]\)], "Input"], Cell[GraphicsData["PostScript", "\<\ %! %%Creator: Mathematica %%AspectRatio: .61803 MathPictureStart /Mabs { Mgmatrix idtransform Mtmatrix dtransform } bind def /Mabsadd { Mabs 3 -1 roll add 3 1 roll add exch } bind def %% Graphics /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.031746 0.0147151 0.11891 [ [.18254 .00222 -3 -9 ] [.18254 .00222 3 0 ] [.34127 .00222 -6 -9 ] [.34127 .00222 6 0 ] [.5 .00222 -6 -9 ] [.5 .00222 6 0 ] [.65873 .00222 -6 -9 ] [.65873 .00222 6 0 ] [.81746 .00222 -6 -9 ] [.81746 .00222 6 0 ] [.97619 .00222 -6 -9 ] [.97619 .00222 6 0 ] [.01131 .13362 -6 -4.5 ] [.01131 .13362 0 4.5 ] [.01131 .25253 -6 -4.5 ] [.01131 .25253 0 4.5 ] [.01131 .37144 -6 -4.5 ] [.01131 .37144 0 4.5 ] [.01131 .49035 -6 -4.5 ] [.01131 .49035 0 4.5 ] [.01131 .60926 -6 -4.5 ] [.01131 .60926 0 4.5 ] [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 g .25 Mabswid [ ] 0 setdash .18254 .01472 m .18254 .02097 L s [(5)] .18254 .00222 0 1 Mshowa .34127 .01472 m .34127 .02097 L s [(10)] .34127 .00222 0 1 Mshowa .5 .01472 m .5 .02097 L s [(15)] .5 .00222 0 1 Mshowa .65873 .01472 m .65873 .02097 L s [(20)] .65873 .00222 0 1 Mshowa .81746 .01472 m .81746 .02097 L s [(25)] .81746 .00222 0 1 Mshowa .97619 .01472 m .97619 .02097 L s [(30)] .97619 .00222 0 1 Mshowa .125 Mabswid .05556 .01472 m .05556 .01847 L s .0873 .01472 m .0873 .01847 L s .11905 .01472 m .11905 .01847 L s .15079 .01472 m .15079 .01847 L s .21429 .01472 m .21429 .01847 L s .24603 .01472 m .24603 .01847 L s .27778 .01472 m .27778 .01847 L s .30952 .01472 m .30952 .01847 L s .37302 .01472 m .37302 .01847 L s .40476 .01472 m .40476 .01847 L s .43651 .01472 m .43651 .01847 L s .46825 .01472 m .46825 .01847 L s .53175 .01472 m .53175 .01847 L s .56349 .01472 m .56349 .01847 L s .59524 .01472 m .59524 .01847 L s .62698 .01472 m .62698 .01847 L s .69048 .01472 m .69048 .01847 L s .72222 .01472 m .72222 .01847 L s .75397 .01472 m .75397 .01847 L s .78571 .01472 m .78571 .01847 L s .84921 .01472 m .84921 .01847 L s .88095 .01472 m .88095 .01847 L s .9127 .01472 m .9127 .01847 L s .94444 .01472 m .94444 .01847 L s .25 Mabswid 0 .01472 m 1 .01472 L s .02381 .13362 m .03006 .13362 L s [(1)] .01131 .13362 1 0 Mshowa .02381 .25253 m .03006 .25253 L s [(2)] .01131 .25253 1 0 Mshowa .02381 .37144 m .03006 .37144 L s [(3)] .01131 .37144 1 0 Mshowa .02381 .49035 m .03006 .49035 L s [(4)] .01131 .49035 1 0 Mshowa .02381 .60926 m .03006 .60926 L s [(5)] .01131 .60926 1 0 Mshowa .125 Mabswid .02381 .0385 m .02756 .0385 L s .02381 .06228 m .02756 .06228 L s .02381 .08606 m .02756 .08606 L s .02381 .10984 m .02756 .10984 L s .02381 .15741 m .02756 .15741 L s .02381 .18119 m .02756 .18119 L s .02381 .20497 m .02756 .20497 L s .02381 .22875 m .02756 .22875 L s .02381 .27632 m .02756 .27632 L s .02381 .3001 m .02756 .3001 L s .02381 .32388 m .02756 .32388 L s .02381 .34766 m .02756 .34766 L s .02381 .39523 m .02756 .39523 L s .02381 .41901 m .02756 .41901 L s .02381 .44279 m .02756 .44279 L s .02381 .46657 m .02756 .46657 L s .02381 .51414 m .02756 .51414 L s .02381 .53792 m .02756 .53792 L s .02381 .5617 m .02756 .5617 L s .02381 .58548 m .02756 .58548 L s .25 Mabswid .02381 0 m .02381 .61803 L s 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath .008 w .05556 .03255 Mdot .0873 .05435 Mdot .11905 .07219 Mdot .15079 .09201 Mdot .18254 .10984 Mdot .21429 .12966 Mdot .24603 .1475 Mdot .27778 .1693 Mdot .30952 .1911 Mdot .34127 .20497 Mdot .37302 .22677 Mdot .40476 .25055 Mdot .43651 .26839 Mdot .46825 .28623 Mdot .5 .30406 Mdot .53175 .32983 Mdot .56349 .34568 Mdot .59524 .3655 Mdot .62698 .39721 Mdot .65873 .39919 Mdot .69048 .42297 Mdot .72222 .44874 Mdot .75397 .46261 Mdot .78571 .48639 Mdot .81746 .50225 Mdot .84921 .52206 Mdot .88095 .54386 Mdot .9127 .56368 Mdot .94444 .58746 Mdot .97619 .60332 Mdot % End of Graphics MathPictureEnd \ \>"], "Graphics", ImageSize->{288, 177.938}, ImageMargins->{{43, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, ImageCache->GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHgGoo00<007oo Ool09Woo00<007ooOol00Woo00@007ooOol0025oo`03001oogoo009oo`03001oogoo029oo`04001o ogoo0002Ool01000Oomoo`008Goo00@007ooOol0009oo`03001oogoo02Eoo`04001oogoo0002Ool0 0`00Oomoo`08Ool003Uoo`@002Aoo`8000Eoo`80025oo`8000Aoo`@0029oo`8000Aoo`8002=oo`80 00=oo`@0025oo`<000Aoo`8000]oo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol> Ool0011oo`03001oogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo000:Oooo000?0008Ool0011o o`03001oogoo00Ioo`03001oogoo00Eoo`03001oogoo00Ioo`03001oogoo00Eoo`03001oogoo00Io o`03001oogoo00Ioo`03001oogoo00Eoo`03001oogoo00Ioo`03001oogoo00Eoo`03001oogoo00Io o`03001oogoo00Eoo`03001oogoo00Ioo`03001oogoo00Eoo`03001oogoo00Ioo`03001oogoo00Eo o`03001oogoo00Ioo`03001oogoo00Ioo`03001oogoo00Eoo`03001oogoo00Ioo`03001oogoo00Eo o`03001oogoo00Ioo`03001oogoo00Eoo`03001oogoo00Ioo`03001oogoo00Eoo`03001oogoo00Io o`03001oogoo00Eoo`03001oogoo00Ioo`03001oogoo00Ioo`03001oogoo00Eoo`03001oogoo00Io o`03001oogoo00aoo`0047oo00<007ooOol0:7oo00<007ooOol0:7oo00<007ooOol09goo00<007oo Ool0:7oo00<007ooOol0:7oo00<007ooOol0:7oo00<007ooOol037oo000@Ool00`00Oomoo`3oOol> Ool0011oo`03001oogoo00Eoo`800?moo`Moo`0047oo00<007ooOol01Goo0P00ogoo1goo000@Ool2 003oOol?Ool0011oo`03001oogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomo o`3oOol>Ool0011oo`03001oogoo00ioo`800?eoo`0047oo00<007ooOol03Woo0P00oGoo000@Ool0 0`00Oomoo`3oOol>Ool0011oo`800?moo`moo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomo o`0FOol2003eOol0011oo`03001oogoo01Ioo`800?Eoo`0047oo00<007ooOol0ogoo3Woo000@Ool0 0`00Oomoo`3oOol>Ool0011oo`800?moo`moo`0047oo00<007ooOol07goo0P00k7oo000@Ool00`00 Oomoo`0OOol2003/Ool0011oo`03001oogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo000@Ool0 0`00Oomoo`3oOol>Ool0011oo`03001oogoo02Moo`800>Aoo`0047oo0P00:7oo0P00i7oo000@Ool0 0`00Oomoo`3oOol>Ool0011oo`03001oogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo0008Ool3 0005Ool00`00Oomoo`0`Ool2003KOol000Uoo`03001oogoo00Aoo`03001oogoo031oo`800=]oo`00 2Goo00<007ooOol017oo0`00ogoo3Woo0009Ool00`00Oomoo`04Ool00`00Oomoo`3oOol>Ool000Uo o`03001oogoo00Aoo`03001oogoo0?moo`ioo`0027oo0P001Woo00<007ooOol0>Goo0P00dWoo000@ Ool00`00Oomoo`0iOol2003BOol0011oo`03001oogoo0?moo`ioo`0047oo0P00ogoo3goo000@Ool0 0`00Oomoo`3oOol>Ool0011oo`03001oogoo0?moo`ioo`0047oo00<007ooOol0@Goo0P00bWoo000@ Ool00`00Oomoo`11Ool2003:Ool0011oo`03001oogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo 000@Ool2003oOol?Ool0011oo`03001oogoo0?moo`ioo`0047oo00<007ooOol0BWoo0P00`Goo000@ Ool00`00Oomoo`1:Ool20031Ool0011oo`03001oogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo 000@Ool2001COol2002iOol0011oo`03001oogoo059oo`800;Uoo`0047oo00<007ooOol0ogoo3Woo 000@Ool00`00Oomoo`3oOol>Ool0011oo`03001oogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo 000@Ool00`00Oomoo`1KOol2002`Ool0011oo`8005aoo`800;1oo`0047oo00<007ooOol0ogoo3Woo 000@Ool00`00Oomoo`3oOol>Ool0011oo`03001oogoo0?moo`ioo`0027oo100017oo00<007ooOol0 ogoo3Woo0009Ool00`00Oomoo`04Ool00`00Oomoo`1SOol2002XOol000Yoo`03001oogoo00=oo`<0 06=oo`800:Qoo`002goo00<007ooOol00Woo00<007ooOol0ogoo3Woo0008Ool01000Oomoo`0017oo 00<007ooOol0ogoo3Woo0009Ool20005Ool00`00Oomoo`3oOol>Ool0011oo`03001oogoo06aoo`80 09moo`0047oo00<007ooOol0K7oo0P00Wgoo000@Ool2003oOol?Ool0011oo`03001oogoo0?moo`io o`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`1dOol2002GOol0011oo`03001oogoo07Ao o`8009Moo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool0011oo`8007ioo`80 08ioo`0047oo00<007ooOol0OGoo0P00SWoo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001oogoo 0?moo`ioo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool0011oo`800?moo`mo o`0047oo00<007ooOol0QGoo0P00QWoo000@Ool00`00Oomoo`25Ool20026Ool0011oo`03001oogoo 0?moo`ioo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001oogoo 08ioo`8007eoo`0047oo0P00Sgoo0P00OGoo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001oogoo 0?moo`ioo`0047oo00<007ooOol0ogoo3Woo0008Ool30005Ool00`00Oomoo`2GOol2001dOol000]o o`03001oogoo009oo`03001oogoo09Moo`8007Aoo`002goo00<007ooOol00Woo0`00ogoo3Woo0009 Ool20005Ool00`00Oomoo`3oOol>Ool000]oo`03001oogoo009oo`03001oogoo0?moo`ioo`0027oo 0`001Goo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001oogoo0?moo`io o`0047oo0P00X7oo0P00K7oo000@Ool00`00Oomoo`2OOol20007Ool2001SOol0011oo`03001oogoo 0:Qoo`8006=oo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001o ogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo000@Ool2002aOol2001KOol0011oo`03001oogoo 0;1oo`8005]oo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001o ogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo000@Ool2003oOol?Ool0011oo`03001oogoo0;Uo o`80059oo`0047oo00<007ooOol0^Goo0P00DWoo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001o ogoo0?moo`ioo`0047oo00<007ooOol0`Goo0P00BWoo000@Ool00`00Oomoo`31Ool2001:Ool0011o o`800?moo`moo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001o ogoo0?moo`ioo`002Goo0`0017oo00<007ooOol0bWoo0P00@Goo000:Ool00`00Oomoo`03Ool00`00 Oomoo`3:Ool20011Ool000Qoo`@000Aoo`<00?moo`ioo`0027oo00<007oo00001Goo00<007ooOol0 ogoo3Woo0008Ool00`00Ool00005Ool00`00Oomoo`3oOol>Ool000Uoo`8000Eoo`03001oogoo0=9o o`8003Uoo`0047oo00<007ooOol0dWoo0P00>Goo000@Ool00`00Oomoo`3oOol>Ool0011oo`800?mo o`moo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3KOol2000`Ool0011oo`03001oogoo 0=]oo`80031oo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001o ogoo0?moo`ioo`0047oo0P00ogoo3goo000@Ool00`00Oomoo`3SOol2000XOol0011oo`03001oogoo 0>=oo`8002Qoo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001o ogoo0?moo`ioo`0047oo0P00kGoo0P007goo000@Ool00`00Oomoo`3/Ool2000OOol0011oo`03001o ogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool0011oo`03001o ogoo0?moo`ioo`0047oo00<007ooOol0ogoo3Woo000@Ool2003fOol2000FOol0011oo`03001oogoo 0?Eoo`8001Ioo`0047oo00<007ooOol0ogoo3Woo000@Ool00`00Oomoo`3oOol>Ool000Qoo`<000Eo o`03001oogoo0?eoo`8000ioo`002goo00<007ooOol00Woo00<007ooOol0oGoo0P003Woo000;Ool0 0`00Oomoo`02Ool3003oOol>Ool000Qoo`<000Eoo`03001oogoo0?moo`ioo`0027oo00<007ooOol0 1Goo00<007ooOol0ogoo3Woo0008Ool4003oOolEOol00?moob5oo`00\ \>"], ImageRangeCache->{{{0, 287}, {176.938, 0}} -> {-1.96216, -0.386227, 0.116999, 0.0312357}}], Cell[BoxData[ TagBox[\(\[SkeletonIndicator] Graphics \[SkeletonIndicator]\), False, Editable->False]], "Output"] }, Open ]], Cell["\<\ There! Heaps faster and approximately linear in the number of data \ points to be generated. The previous version would have taken AGES to \ generate 10,000 data points, especially on a slower machine, but with the \ functional programming style you can do it in less than two seconds. \ Consider that the 8000-point case is nearly TWENTY times faster!! And there \ are fewer lines of code. All right!\ \>", "Text"], Cell["\<\ One final thing: you might have noticed that I've defined pcoefs in \ the new version to match {_,__}, that is, a vector with two or more elements. \ That's because the AR(1) case admits a simpler function and I decided to \ code that as a special case.\ \>", "Text"], Cell["\<\ Luci Ellis 8 July 1998\ \>", "Text"] }, Open ]] }, Open ]] }, FrontEndVersion->"Macintosh 3.0", ScreenRectangle->{{0, 1152}, {0, 850}}, WindowSize->{551, 738}, WindowMargins->{{12, Automatic}, {Automatic, 13}}, MacintoshSystemPageSetup->"\<\ 00<0001804P000000]P2:?oQon82n@960dL5:0?l0080001804P000000]P2:001 0000I00000400`<300000BL?00400@0000000000000006P801T1T00000000000 00000000000000000000000000000000\>" ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1731, 51, 33, 0, 98, "Title"], Cell[1767, 53, 798, 18, 146, "Text"], Cell[CellGroupData[{ Cell[2590, 75, 74, 0, 44, "Subsection"], Cell[2667, 77, 563, 11, 143, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3267, 93, 44, 0, 44, "Subsection"], Cell[3314, 95, 2541, 55, 363, "Input"], Cell[5858, 152, 128, 3, 46, "Text"], Cell[CellGroupData[{ Cell[6011, 159, 164, 4, 59, "Input"], Cell[6178, 165, 357, 5, 71, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[6572, 175, 79, 1, 27, "Input"], Cell[6654, 178, 11281, 409, 186, 4467, 320, "GraphicsData", "PostScript", "Graphics"], Cell[17938, 589, 130, 3, 26, "Output"] }, Open ]], Cell[18083, 595, 164, 4, 46, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[18284, 604, 55, 0, 44, "Subsection"], Cell[18342, 606, 749, 16, 187, "Input"], Cell[CellGroupData[{ Cell[19116, 626, 164, 4, 59, "Input"], Cell[19283, 632, 1344, 20, 221, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[20664, 657, 78, 1, 27, "Input"], Cell[20745, 660, 10711, 364, 186, 3932, 276, "GraphicsData", "PostScript", "Graphics"], Cell[31459, 1026, 130, 3, 26, "Output"] }, Open ]], Cell[31604, 1032, 429, 7, 78, "Text"], Cell[32036, 1041, 278, 5, 62, "Text"], Cell[32317, 1048, 46, 3, 46, "Text"] }, Open ]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)