(*********************************************************************** 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[ 96682, 2598]*) (*NotebookOutlinePosition[ 97577, 2627]*) (* CellTagsIndexPosition[ 97533, 2623]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData[ "Danny Kaplan\[CloseCurlyQuote]s nonlinear time series functions"], "Title"], Cell[TextData[{ "The ", StyleBox["Mathematica", FontSlant->"Italic"], " functions below are translations of D. Kaplan\[CloseCurlyQuote]s Matlab \ code available at" }], "Text"], Cell[BoxData[ \(Off[General::spell]\)], "Input"], Cell[CellGroupData[{ Cell["Acknowledgments", "Subsubsection"], Cell["\<\ Firstly, I obviously have to thank Daniel Kaplan for allowing me to \ publish the translation of his code, and for helping me when I got stuck. \ Mathew Dafilis of Swinburne University in Melbourne also helped me fixed some \ remaining bugs.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Packages to Load in", "Subsection"], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell["Required for plotACF", "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell["\<\ Required for theilerQ, crinkleStatistic, nonlinearPredictionError\ \ \>", "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell["Required for the various box* functions and compHistogram", "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell["Required for kaplanScatterPlot, plotDE and plotACF", "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell["Required for compHistogram", "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell["Required for kaplanScatterPlot", "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell["Required for midCast,timeReversalAssymetryStatistic", "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell["\<\ Required for model1, model1realization, model2, and \ model2realization.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \($Packages\)], "Input"], Cell[BoxData[ \({"Statistics`ContinuousDistributions`", "LinearAlgebra`Orthogonalization`", "LinearAlgebra`MatrixManipulation`", "Graphics`Graphics3D`", "Graphics`Common`GraphicsCommon`", "Graphics`Graphics`", "Utilities`FilterOptions`", "DiscreteMath`Tree`", "Statistics`DataManipulation`", "DiscreteMath`ComputationalGeometry`", "Statistics`Common`MultivariateCommon`", "Statistics`Common`DistributionsCommon`", "Statistics`NormalDistribution`", "Statistics`DescriptiveStatistics`", "Statistics`MultiDescriptiveStatistics`", "Global`", "System`"}\)], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Functions not implemented", "Subsection"], Cell[TextData[{ "A number of the functions implemented in Kaplan's set of M-files are \ already implemented in the standard distribution of ", StyleBox["Mathematica", FontSlant->"Italic"], ", or can be built up from basic ", StyleBox["Mathematica", FontSlant->"Italic"], " functions. These include Kaplan's ", StyleBox["gausspdf.m", FontWeight->"Bold"], " (see \"Statistics`ContinuousDistributions`\"), ", StyleBox["rho.m", FontWeight->"Bold"], " (See \"Statistics`MultiDescriptiveStatistics`\"), ", StyleBox["globelin.m", FontWeight->"Bold"], " (see \"Statistics`LinearRegression`\"), ", StyleBox["bootstr.m", FontWeight->"Bold"], " and ", StyleBox["comphist.m. ", FontWeight->"Bold"], "Similarly,", StyleBox[" repeatp.m", FontWeight->"Bold"], " is probably easiest to achieve using a function like ", StyleBox["NestList", FontWeight->"Bold"], ", ", StyleBox["FoldList", FontWeight->"Bold"], " or ", StyleBox["Table", FontWeight->"Bold"], ", and ", StyleBox["Map", FontWeight->"Bold"], "ping the desired function onto the resultant list, all of which can be \ done on a single line. ", StyleBox["scatter3movie.m", FontWeight->"Bold"], " and ", StyleBox["scattermovie.m", FontWeight->"Bold"], " are best implemented using ", StyleBox["Mathematica", FontSlant->"Italic"], "'s front end commands for generating movies in various formats.\n", StyleBox["surrstat.m", FontWeight->"Bold"], " just maps a particular statistic onto surrogate data. Rather than write a \ function to do this specifically, it seems that it would be best to use \ nameOfFunction[fftSurrogate[data]] directly.\n", StyleBox["fditer.m ", FontWeight->"Bold"], "just iterates on a function and returns a list of the iterates. May as \ well use ", StyleBox["NestList[]", FontWeight->"Bold"], ".\n", StyleBox["squid1.m", FontWeight->"Bold"], " and ", StyleBox["squid2.m", FontWeight->"Bold"], " are only half-implemented because they seem to refer to external code, \ which does not appear to be included in the download. I didn't do", StyleBox[" squidper.m", FontWeight->"Bold"], " for the same reason.\n", StyleBox["nearneib.m ", FontWeight->"Bold"], "doesn't appear to do anything.\n", StyleBox["xfershow.m", FontWeight->"Bold"], " relies on function that are not defined in other code in the package, \ namely coherence, that I don't know how to implement.\n", StyleBox["polyshow.m ", FontWeight->"Bold"], "can be replicated using ", StyleBox["Mathematica", FontSlant->"Italic"], "'s built-in ", StyleBox["Fit[]", FontWeight->"Bold"], " function and the plots of your choice. \nSimilarly,", StyleBox[" threeplot.m ", FontWeight->"Bold"], "can be implemented using built-in Plot functions (check out the \ documentation on Statistics`DataManipulation`BinCounts and BarChart to get \ histograms with a minimum of fuss.\n\n\n I have also decided not to implement \ the Lorenz ODE, since this is in the ", StyleBox["Mathematica", FontSlant->"Italic"], " Book, ", ButtonBox["section 3.9.7", ButtonData:>{ "::::::Applications:Mathematica 3.0 \ Files:Documentation:English:MainBook:3_09.nb", "7.16"}, ButtonStyle->"Hyperlink"], ", (this link might only work on Macs, as it is path dependent).\nNDSolve[ \ {x'[t] == -3 (x[t] - y[t]), y'[t] == -x[t] z[t] + 26.5 x[t] - y[t], z'[t] \ == x[t] y[t] - z[t], x[0] == z[0] == 0, y[0] == 1}, {x, y, z}, {t, 0, \ 20}, MaxSteps->3000 ]" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Code by Luci Ellis", "Subsubtitle"], Cell[CellGroupData[{ Cell["\<\ simpleLinRegress[ ]: A Simple Linear Regression function built for \ speed not features\ \>", "Subsubsection"], Cell[CellGroupData[{ Cell[BoxData[ \(simpleLinRegress::usage = "\"\)], "Input"], Cell[BoxData[ \("simpleLinRegress[data_MatrixQ] takes a rectangular matrix of real \ numbers and performs a linear regression or weighted linear regression of the \ first column on the other columns. The output is a non-rectangular list of \ three lists -- the estimated coefficients, the fitted values and the \ residuals."\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(GLSWeights::usage\ = \ "\"\)], "Input"], Cell[BoxData[ \("GLSWeights is an option to simpleLinRegress that takes either the \ value Automatic, corresponding to OLS, or a list of real numbers \ corresponding to the weights to be used in a WLS procedure."\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(IncludeConstant::usage\ = \ "\"\)], "Input"], Cell[BoxData[ \("IncludeConstant is an option to simpleLinRegress that indicates \ whether or not a constant should be added to the data matrix."\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(simpleLinRegress::wtnum = "\"\)], "Input"], Cell[BoxData[ \("Either the vector of weights is not a vector of real numbers with the \ same number of element as the data sample size, or you have tried to apply \ WLS to a model with a single explanator and no constant."\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(simpleLinRegress::notnum\ = \ "\"\)], "Input"], Cell[BoxData[ \("Some of the data supplied is non-numeric."\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Options[simpleLinRegress] = {GLSWeights -> Automatic, IncludeConstant \[Rule] True}\)], "Input"], Cell[BoxData[ \({GLSWeights \[Rule] Automatic, IncludeConstant \[Rule] True}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(SetOptions[simpleLinRegress, GLSWeights -> Automatic, IncludeConstant \[Rule] True]\)], "Input"], Cell[BoxData[ \({GLSWeights \[Rule] Automatic, IncludeConstant \[Rule] True}\)], "Output"] }, Open ]], Cell[BoxData[ \(simpleLinRegress[data_?MatrixQ, \ opts___?OptionQ] := \ If[And\ @@\ \((NumericQ\ /@\ Flatten[data])\), \n\t\t Module[{\[ScriptW], \[ScriptC]}, \[ScriptW]\ = \ \(GLSWeights\ /. {opts}\)\ /. Options[simpleLinRegress]; \n\t\t \[ScriptC]\ = \ \(IncludeConstant\ /. {opts}\)\ /. Options[simpleLinRegress]; \n \t\tWith[{ \[ScriptY] = If[Not[\[ScriptC]] && \ \(Dimensions[data]\)\[LeftDoubleBracket]2 \[RightDoubleBracket] == 2, Flatten[First/@data], First\ /@\ data], \n\t\t\t\t\t\t\t\ \ \[ScriptX]\ = \ If[\[ScriptC], Transpose[ Join[{Table[1, {Length[data]}]}, Transpose[Rest\ /@\ data]]], If[\(Dimensions[Rest\ /@data]\)\[LeftDoubleBracket]2 \[RightDoubleBracket] == 1, Flatten[Rest\ /@\ data], Transpose[Rest\ /@\ data]]], \[ScriptN] = Length[data]}, \n\t\t\tModule[{betas, yhat, \ resids}, \n\t\t\t\t Which[\[ScriptW] === Automatic, \(betas\ = \ If[Not[\[ScriptC]] && \(Dimensions[Rest\ /@data]\)\[LeftDoubleBracket]2 \[RightDoubleBracket] == 1, { \((1/\((\[ScriptX].\[ScriptX])\))\)* \((\[ScriptX].\[ScriptY])\)}, Flatten[ Inverse[\((Transpose[\ \[ScriptX]].\ \[ScriptX])\)]. \((Transpose[\ \[ScriptX]].\[ScriptY])\)]]; \), \n \t\t\t\t\t \((Length[\[ScriptW]] == \[ScriptN]\ )\) && \((Length[\[ScriptW]] > 1\ )\) && \ \((And\ @@\ \((NumericQ\ /@\ \[ScriptW])\))\), \ \(betas\ = Inverse[ Transpose[\((\[ScriptW]*\[ScriptX])\)]. \((\[ScriptX])\)]. \((\((Transpose[\[ScriptW]*\[ScriptX]])\). \((\[ScriptY])\))\); \), True, \ Message[simpleLinRegress::wtnum]; \ $Failed]; \n\t\t\t\t yhat\ = If[Not[\[ScriptC]] && \ \(Dimensions[data]\)\[LeftDoubleBracket]2 \[RightDoubleBracket] == 2, \[ScriptX]*betas\[LeftDoubleBracket]1\[RightDoubleBracket], \ \[ScriptX].betas]; \n\t\t\t\t resids\ = \ \[ScriptY] - yhat; \n \t\t\t\t{betas, yhat, resids}]]], Message[simpleLinRegress::notnum]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["mHistory", "Subsubsection"], Cell[CellGroupData[{ Cell[BoxData[ \(mHistory::usage = "\"\)], "Input"], Cell[BoxData[ \("mHistory[data,m] constructs a m-embedding of the data series data with \ lag 1. mHistory[data,m,l] constructs an m-embedding with lag l. This function \ replicates the functionality of a Gauss procedure lagembed, written by Daniel \ Kaplan, but was written by Luci Ellis prior to her seeing his code."\)], "Output"] }, Open ]], Cell[BoxData[ \(mHistory[data_?VectorQ, 1] := \ data\)], "Input"], Cell[BoxData[ \(mHistory[data_?VectorQ, m_Integer] := \ Drop[Transpose[\(RotateLeft[data, #]\ &\)\ /@\ Range[0, m - 1]], 1 - m] \)], "Input"], Cell[BoxData[ \(mHistory[data_?VectorQ, m_Integer, lag_Integer] /; Length[data] > \((m + lag + 1)\) := \n\t\ \(Drop[Transpose[\(RotateLeft[data, #]\ &\)\ /@\ Range[0, m - 1]], 1 - m - lag]\)\[LeftDoubleBracket]Range[1, Length[data] - m - lag, lag]\[RightDoubleBracket]\)], "Input"], Cell[BoxData[ \(mHistory[data_?MatrixQ, 1] := \ data\)], "Input"], Cell[BoxData[ \(mHistory[data_?MatrixQ, m_Integer] := \ Drop[Transpose[\(RotateLeft[data, #]\ &\)\ /@\ Range[0, m - 1]], 1 - m] \)], "Input"], Cell[BoxData[ \(mHistory[data_?MatrixQ, m_Integer, lag_Integer] /; Length[data] > \((m + lag + 1)\) := \n\t\ \(Drop[Transpose[\(RotateLeft[data, #]\ &\)\ /@\ Range[0, m - 1]], 1 - m - lag]\)\[LeftDoubleBracket]Range[1, Length[data] - m - lag, lag]\[RightDoubleBracket]\)], "Input"] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Code by Danny Kaplan translated from Matlab to ", StyleBox["Mathematica", FontSlant->"Italic"], " by Luci Ellis" }], "Subsubtitle"], Cell[CellGroupData[{ Cell["plotACF", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ plotACF::usage=\"plotACF plots the autocovariance function up to a \ given lag, showing the 95 percent confidence intervals for white noise. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("plotACF plots the autocovariance function up to a given lag, showing \ the 95 percent confidence intervals for white noise. This version is based on \ Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(plotACF[data : {__?NumericQ}, maxlag_Integer, opts___Rule] /; \((maxlag < \((Length[data]/2)\))\) := \n With[{n = Length[data]}, With[{confint = Table[2/Sqrt[n], {maxlag}]}, \n\t\t\t Show[ListPlot[ \(Correlation[Drop[data, #], Drop[data, \(-#\)]]&\)\ /@\ Range[maxlag], DisplayFunction \[Rule] Identity], \n\t\t\t ListPlot[confint, PlotJoined \[Rule] True, PlotStyle \[Rule] Dashing[{0.02, \ 0.02}], DisplayFunction \[Rule] Identity], \n\t\t\t ListPlot[\(-confint\), PlotJoined \[Rule] True, PlotStyle \[Rule] Dashing[{0.02, \ 0.02}], DisplayFunction \[Rule] Identity], FilterOptions[ListPlot, opts], DisplayFunction \[Rule] $DisplayFunction]\ ]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["abcalc", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ abcalc::usage=\"abcalc[alpha0, beta0, alpha1, beta1, p0, p1] \ calculates a and b for feedback control of one-dimensional maps for the \ definitions of the arguments, see the Squid Lab instructions. This version is \ based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("abcalc[alpha0, beta0, alpha1, beta1, p0, p1] calculates a and b for \ feedback control of one-dimensional maps for the definitions of the \ arguments, see the Squid Lab instructions. This version is based on Matlab \ code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(abcalc[\[Alpha]0_, \ \[Beta]0_, \ \[Alpha]1_, \ \[Beta]1_, \ p0_, \ p1_] := \n\tWith[{ \[Gamma]\ = \ \((\[Beta]1 - \[Beta]0)\)/\((p1 - p0)\)}, \n{\ \(-\[Alpha]0\)\ /\((\[Gamma]\ - \[Alpha]0\ *\ \[Gamma])\), \ \((\[Alpha]0*\[Beta]0\ + \[Gamma]*p0\ - \ \[Alpha]0*\[Gamma]*p0) \)/\((\[Gamma]\ - \[Alpha]0*\[Gamma])\)}]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["ampsurr", "Subsection"], Cell[CellGroupData[{ Cell["\<\ ampsurr::usage = \"ampsurr[x,y,seed] generates amplitude adjusted \ surrogate data. x is the data, y is data from a target histogram, or an \ Integer. n == 1 ==> N(0,1) n == 2 ==> Uniform(0,1) --- this is deterministic n == 3 ==> Triangular(0,2) This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("ampsurr[x,y,seed] generates amplitude adjusted surrogate data. x is \ the data, y is data from a target histogram, or an Integer. n == 1 ==> \ N(0,1) n == 2 ==> Uniform(0,1) --- this is deterministic n == 3 ==> \ Triangular(0,2) This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(ampsurr[x_?VectorQ, y_: 1, seed_] := \n Module[{}, SeedRandom[seed]; \n\ histxfrm[fftSurrogate[\ histxfrm[x, y, seed], seed], x]]\)], "Input"], Cell[BoxData[ \(ampsurr[x_?VectorQ, y_: 1] := \n\ histxfrm[fftSurrogate[\ histxfrm[x, y]], x]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["ARResids", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ ARResids::usage=\"ARResids[data, porder] calculates the residuals of data from the specified AR model. This function \ is based on Matlab code by Daniel Kaplan and uses the simpleLinRegress \ quick-and-dirty OLS function by Luci Ellis. The difference between this \ version and the Kaplan version is that this one just takes the order (p) of \ the AR model to be estimated, estimates it by OLS and returns the \ residuals.\"\ \>", "Input"], Cell[BoxData[ \("ARResids[data, porder] calculates the residuals of data from the \ specified AR model. This function is based on Matlab code by Daniel Kaplan \ and uses the simpleLinRegress quick-and-dirty OLS function by Luci Ellis. \ The difference between this version and the Kaplan version is that this one \ just takes the order (p) of the AR model to be estimated, estimates it by OLS \ and returns the residuals."\)], "Output"] }, Open ]], Cell[BoxData[ \(ARResids[data : {__?NumericQ}, p_Integer] /; \((p\ < Length[data])\) := \n\t With[{olsdata = Transpose[ \(Drop[#, p]&\)\ /@ \((\(RotateRight[data, #]&\)\ /@\ Range[0, p])\)]}, Last[simpleLinRegress[olsdata]]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["bincountsInformation", "Subsection"], Cell[CellGroupData[{ Cell["\<\ bincountsInformation::usage=\"bincountsInformation[bincounts] \ calculates the information given a probability distribution in the form of \ bincounts. Example usage: (s,t) = hist(data); inform(s) r is normalized to the \ information in the uniform distribution with length(bincnts). This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("bincountsInformation[bincounts] calculates the information given a \ probability distribution in the form of bincounts. Example usage: (s,t) = \ hist(data); inform(s) r is normalized to the information in the uniform \ distribution with length(bincnts). This version is based on Matlab code by \ Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(bincountsInformation[bincnts_List] := \n With[{counts = \ Select[\ bincnts\ , # > \ 0\ &]}, \n\t\t With[{normcounts = counts/\((Plus\ @@\ counts)\)}, \n \(-\((\ Plus\ @@\((normcounts*Log[normcounts])\))\)\)/ Log[Length[bincnts]]\ ]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["bootstrap", "Subsection"], Cell[CellGroupData[{ Cell["\<\ bootstrap::usage=\"bootstrap[data,stat,n] estimates the standard \ error of a statistic using bootstrapping. data is a matrix containing the data --- sampling is done row-by-row stat is the statistic to use. n is the number of bootstrap samples to take. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("bootstrap[data,stat,n] estimates the standard error of a statistic \ using bootstrapping. data is a matrix containing the data --- sampling is \ done row-by-row stat is the statistic to use. n is the number of bootstrap \ samples to take. This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(bootstrap[data, \ stat_Symbol, \ n_Integer] := \n\t With[{s = Dimensions[data]}, With[{len = Max[s], datatouse = If[s\[LeftDoubleBracket]1\[RightDoubleBracket] < s\[LeftDoubleBracket]2\[RightDoubleBracket], Transpose[data], data]}, \n\t Table[Evaluate[ stat\ @@\ datatouse \[LeftDoubleBracket]Ceiling[len*Table[Random[], {len}]]\ \[RightDoubleBracket]], {n}]\ ]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["boxCount and boxDim", "Subsection"], Cell[CellGroupData[{ Cell["\<\ boxCount::usage=\"boxCount[ data, nbins] counts the number of boxes \ that a matrix occupies. Uses the standard package Statistics`DataManipution. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("boxCount[ data, nbins] counts the number of boxes that a matrix \ occupies. Uses the standard package Statistics`DataManipution. This version \ is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(boxCount[data_?MatrixQ, nbins_Integer] := \n\t With[{mx = Ceiling[Max[data]], mn = Floor[Min[data]]}, With[{bincnts = BinCounts[data, {mn, mx, \((mx - mn)\)/nbins}]}, Length[Select[bincnts, #\ != \ 0\ &]]/nbins]]\)], "Input"], Cell["\<\ An equivalent way to get the same answer. It remains to be tested \ which is more efficient.\ \>", "Text"], Cell[BoxData[ \(boxCount2[data_?MatrixQ, nbins_Integer] := \n\t With[{mx = Ceiling[Max[data]], mn = Floor[Min[data]]}, With[{bincnts = BinCounts[Flatten[data], {mn, mx, \((mx - mn)\)/nbins}]}, \((nbins - Length[Cases[bincnts, 0]])\)/nbins]]\)], "Input"], Cell[CellGroupData[{ Cell["\<\ boxDim::usage=\"boxDim[data] returns two columns, log of the box resolution and log of the number of occupied boxes at that \ resolution. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("boxDim[data] returns two columns, log of the box resolution and log \ of the number of occupied boxes at that resolution. This version is based on \ Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(boxDim[data_?MatrixQ, n_Integer] := \n\t Table[{Log[i], Log[i*\ boxCount[data] + 0.0000001]}, {i, n}]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["compHistogram (comphist.m)", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(compHistogram::usage = "\"\)], "Input"], Cell[BoxData[ \("compHistogram[data, tname, numbins] overplots a histogram and a normal \ probability distribution. This version is based on Matlab code by Daniel \ Kaplan. The x-axis labels are only displayed to one decimal place."\)], "Output"] }, Open ]], Cell[BoxData[ \(compHistogram[data_?VectorQ, \ tname_String, numbins_Integer, opts___Rule]\ := \n\t With[{\[Mu] = Mean[data], \[Sigma] = StandardDeviation[data], \[Alpha] = Min[data], \[Beta] = Max[data], \[ScriptN] = Length[data]}, \n\t\t With[{j = Abs[\((\((\[Beta] - \[Alpha])\)/\((numbins)\))\)]}, \n\t\t Show[{\ BarChart[ Transpose[{ BinCounts[data, \ {\[Alpha], \ \[Beta], \ \((\((\[Beta] - \[Alpha])\)/\((numbins)\))\)}]\ , Round[10\ Rest[Range[\[Alpha], \[Beta], \ j] - \((j/2)\)\ ]]/ 10.}], DisplayFunction \[Rule] Identity], \ \n ListPlot[ Table[\[ScriptN]\ * \((CDF[NormalDistribution[\[Mu], \[Sigma]], x + j])\) - \[ScriptN]\ * CDF[NormalDistribution[\[Mu], \[Sigma]], x], {x, \[Alpha], \[Alpha] + j\ numbins, j\ }], PlotRange \[Rule] All, PlotJoined \[Rule] True, DisplayFunction \[Rule] Identity]}, PlotLabel \[Rule] tname, DisplayFunction \[Rule] $DisplayFunction, FilterOptions[ListPlot, opts]]\ ]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["evalMap", "Subsection"], Cell[CellGroupData[{ Cell["\<\ evalMap::usage=\"evalMap[zz,targs,k] finds the values of a locally \ linear map and a locally constant map for targs = f(zz) zz - embedding of data targs -- the images of zz under the dynamics --- the map will be fit to this. k - number of neigbors to use in constructing the map RETURNED VALUES lin -- values of the locally linear map at each point in zz const -- values of the locally contant map at each point. This version is \ based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("evalMap[zz,targs,k] finds the values of a locally linear map and a \ locally constant map for targs = f(zz) zz - embedding of data targs -- the \ images of zz under the dynamics --- the map will be fit to this. k - number \ of neigbors to use in constructing the map RETURNED VALUES lin -- values of \ the locally linear map at each point in zz const -- values of the locally \ contant map at each point. This version is based on Matlab code by Daniel \ Kaplan."\)], "Output"] }, Open ]], Cell[TextData[ "evalMap[zz_,targs_,k_]:=\n\tWith[{len =Length[zz]},\n\ Transpose[Table[localLinearFitMap[zz, zz\[LeftDoubleBracket]j\ \[RightDoubleBracket], k, targs, j]\n\t(* exclude the current point j from \ the fitting *),{j,len}]]\[LeftDoubleBracket]{3,4}\[RightDoubleBracket] ]"], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["filterSpecification (filtspec.m)", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(gaussTruth::usage = "\"\)], "Input"], Cell[BoxData[ \("gaussTruth is just a one-liner that replicates the functionality of \ the way Gauss and Matlab do greater than / less than tests on lists, \ returning (0,1) instead of True/False the way Mathematica does. However, note \ that if the value tested is exactly equal to 0, gaussTruth returns 1/2 so you \ might have to explicitly wrap a Sign[] function around the gaussTruth \ command. As an example, to replicate vector.< x , use \ gaussTruth[x-vector]."\)], "Output"] }, Open ]], Cell[BoxData[ \(gaussTruth[x_] := \ 1/2\ + \ Sign[x]/2\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(filterSpecification::usage = "\"\)], "Input"], Cell[BoxData[ \("filterSpecification[ cut, len, width] is a function for specifying a \ low-pass filter in the fourier domain cut - cutoff frequency in terms of the \ sampling frequency. len - length of the data to be filtered. width - width of \ the transition zone. This version is based on Matlab code by Daniel \ Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ \(filterSpecification[\ cut_, \ len_, \ width_] /; \n \((\((\tcut\ <= \ 0.5)\)\ && \ \((cut\ + \ width\ <= \ 0.5)\)) \)\), " ", ":=", "\n", \(Module[{t, \[Tau]}, \t With[{high1 = len/2, high2 = If[Mod[len, 2] == 0, len/2 - 1, \ Floor[len/2]\ ]}, \n\t\t With[{q\ = \ {\ 0, high1\ high2, \(-1\), 1\ }/len}, \n\t\t\t \[Tau] = \ \((cut\ + \ width\ - q)\)/\ width; \n\t\t\t t = If[width == 0, 0*q, \[Tau]\ *gaussTruth[0.9999 - \[Tau]]* gaussTruth[\[Tau] - 0.0001]]; \n t\ + Sign[gaussTruth[cut - q]]\ \ ]]]\), StyleBox[ \( (*\ NB : \ last\ line\ is\ equivalent\ to\ t\ + \ q\ <= \ cut.\ Since\ gaussTruth\ returns\ 1/2\ if\ the\ value\ is\ exactly\ zero\ \((ie\ in\ the\ case\ of\ equality)\), \ this\ has\ been\ implemented\ by\ gaussTruth[cut - q]\ which\ returns\ 0, 1/2, \ 1\ if\ q\ is\ \(greater/equal\)/less\ than\ cut.\ Wrapping\ Sign[]\ around\ that\ gives\ 0\ if\ q > cut\ and\ 1\ if\ q <= cut\ *) \), FontColor->GrayLevel[0.500008]], "\n"}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["findNeighbour (findneib.m)", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ findNeighbour::usage=\"findNeighbour[data_, pt, k, r ] finds the \ nearest neighbors to pt in z data -- matrix of points, 1 per row pt -- vector of a single point k -- number to find r (optional )-- if specified, find all neighbors closer than this inds -- indices of the closest points to pt dist -- corresponding distances from pt This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("findNeighbour[data_, pt, k, r ] finds the nearest neighbors to pt in z \ data -- matrix of points, 1 per row pt -- vector of a single point k -- \ number to find r (optional )-- if specified, find all neighbors closer than \ this inds -- indices of the closest points to pt dist -- corresponding \ distances from pt This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(findNeighbour[data_?MatrixQ, \ pt_?VectorQ, \ k_, \ r_: 0\ ] /; \((\(Dimensions[data]\)\[LeftDoubleBracket]2\[RightDoubleBracket]\ == \ Length[pt])\)\ := \n With[{ds\ = \ Sort[Transpose[{oneDist[data, pt], Range[Length[data]]}\ ]]\ }, \n Reverse\ /@\ \((If[r == 0, Transpose[Take[ds, k]], Transpose[ Select[ds, #\[LeftDoubleBracket]1\[RightDoubleBracket]\ < \ r \ &]]\ ])\)]\)], "Input"], Cell[BoxData[ \(findNeighbour[data_?VectorQ, \ pt_?NumericQ, \ k_, \ r_: 0\ ] := \n With[{ds\ = \ Sort[Transpose[{oneDist[data, pt], Range[Length[data]]}\ ]]\ }, \n Reverse\ /@\ \((If[r == 0, Transpose[Take[ds, k]], Transpose[ Select[ds, #\[LeftDoubleBracket]1\[RightDoubleBracket]\ < \ r \ &]]\ ])\)]\)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["fftFilter", "Subsection"], Cell[CellGroupData[{ Cell["\<\ fftFilter::usage=\"fftFilter filters in the spectral domain. The \ filter is usually constructed using filtSpec. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("fftFilter filters in the spectral domain. The filter is usually \ constructed using filtSpec. This version is based on Matlab code by Daniel \ Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(fftFilter[data : {__?NumericQ}, filter_?VectorQ] /; \((Length[data] == Length[filter]\ )\) := \n Re[InverseFourier[Fourier[data]*filter]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["fftSurrogate", "Subsection"], Cell[CellGroupData[{ Cell["\<\ fftSurrogate::usage=\"fftSurrogate calculates phase randomized \ surrogate data from a time series x, with an optional specified seed. This \ version is based on Matlab code by Daniel Kaplan, with bugfixes by Mathew \ Dafilis.\"\ \>", "Input"], Cell[BoxData[ \("fftSurrogate calculates phase randomized surrogate data from a time \ series x, with an optional specified seed. This version is based on Matlab \ code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ RowBox[{\(fftSurrogate[x_?VectorQ, seed_?NumericQ]\), ":=", "\n", RowBox[{"Module", "[", RowBox[{\({ph, iph}\), ",", "\t", RowBox[{"With", "[", RowBox[{\({z = Fourier[x]}\), ",", "\n", "\t\t", RowBox[{\(SeedRandom[seed]\), ";", "\n", RowBox[{ StyleBox["(*", FontColor->GrayLevel[0.500008]], StyleBox[" ", FontColor->GrayLevel[0.500008]], StyleBox[ \(randomize\ the\ phases\ and\ replace\ 2\ Pi\ with\ some \ other\ phase\ since\ 2\ Pi\ == \ 0\), FontColor->GrayLevel[0.500008]], StyleBox[" ", FontColor->GrayLevel[0.500008]], StyleBox["*)", FontColor->GrayLevel[0.500008]]}], "\n", "\t\t\t\t", \(ph\ = \ \((2*Pi* Table[Random[], {1, Ceiling[Length[z]/2\ - \ 1]}]\ ) \) //. \ N[2\ Pi]\ -> Random[Real, {0, 2 Pi}]\), ";", "\n", "\t", \(iph\ = Flatten[ If[\ Mod[Length[z], 2]\ == \ 0\ , \n \ {\ 0, \ ph, \ 0, \ \(-Reverse[ph]\)}, \ {\ 0, \ ph, \ \ \(-Reverse[ph]\)\ }]]\), ";", "\n", \(Re[InverseFourier[\ z*\ Exp[I*iph]]]\)}]}], " ", "]"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{\(fftSurrogate[x_?VectorQ]\), ":=", "\n", RowBox[{"Module", "[", RowBox[{\({ph, iph}\), ",", "\t", RowBox[{"With", "[", RowBox[{\({z = Fourier[x]}\), ",", "\n", StyleBox[ \( (*\ randomize\ the\ phases\ and\ replace\ 2\ Pi\ with\ some \ other\ phase\ since\ 2\ Pi\ == \ 0\ *) \), FontColor->GrayLevel[0.500008]], "\n", "\t\t\t\t", \(ph\ = \ \((2*Pi*Table[Random[], {1, Ceiling[Length[z]/2\ - \ 1]}]\ ) \) //. \ N[2\ Pi]\ -> Random[Real, {0, 2 Pi}]; \n\t iph\ = Flatten[ If[\ Mod[Length[z], 2]\ == \ 0\ , \n \ {\ 0, \ ph, \ 0, \ \(-Reverse[ph]\)}, \ {\ 0, \ ph, \ \(-Reverse[ph]\)\ }]]; \n Re[InverseFourier[\ z*\ Exp[I*iph]]]\)}], " ", "]"}]}], "]"}]}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["histogramTransformation (histxform.m)", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell[BoxData[ \(?? histosort\)], "Input"], Cell[BoxData[ \("histosort[x,y] is an auxiliary function that is called by \ histogramTransformation, to sort the data in y into the same order implied by \ the data in x. Both x and y should be N*2 matrices with the data in the first \ column and integers in the second column."\)], "Print"], Cell[BoxData[ InterpretationBox[ StyleBox[ \(histosort[xs : {{_, \ _Integer}..}, \ ys : {{_, \ _Integer}..}]\ /; \ \(Dimensions[xs]\)[\([1]\)]\ == \ \(Dimensions[ys]\)[\([1]\)]\ := \ With[{originalindices\ = \ Flatten[ Rest\ /@\ Sort[Transpose[{Rest\ /@\ xs, \ Range[Length[xs]]}]]]}, \ First\ /@\ ys[\([originalindices]\)]]\), ShowStringCharacters->True, NumberMarks->True], InputForm[ Definition[ histosort]], Editable->True, AutoDelete->True]], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(histosort::usage = "\"\)], "Input"], Cell[BoxData[ \("histosort[x,y] is an auxiliary function that is called by \ histogramTransformation, to sort the data in y into the same order implied by \ the data in x. Both x and y should be N*2 matrices with the data in the first \ column and integers in the second column."\)], "Output"] }, Open ]], Cell[BoxData[ \(histosort[xs : {{_, _Integer}..}, ys : {{_, _Integer}..}] /; \((\(Dimensions[xs]\)\[LeftDoubleBracket]1\[RightDoubleBracket] == \(Dimensions[ys]\)\[LeftDoubleBracket]1\[RightDoubleBracket]) \) := \n\t With[{originalindices = Flatten[Rest\ /@\ \((Sort[Transpose[{\((Rest\ /@\ xs)\), Range[Length[xs]]\ }]]) \)]}, \n\t\t First\ /@\ ys\[LeftDoubleBracket]originalindices\[RightDoubleBracket]\ ]\)], "Input"], Cell[TextData[ "Note that, strictly speaking, I could have just piled all the calculations \ to obtain the indices inside the part specification: \n\ ys\[LeftDoubleBracket]Sort[Transpose[{(Rest /@ xs),Range[Length[xs]] }]]\ \[RightDoubleBracket], without using a local constant and a With statement.\n\ I decided to do it the way I did for ease of understanding."], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(histogramTransformation::usage = "\"\)], "Input"], Cell[BoxData[ \("histogramTransformation[x,y] transforms x so that it has the same \ histogram as y while maintaining the order of the ranks in x. x and y should \ be single column vectors. histogramTransformation[x,dist,seed] transforms x \ to have a histogram of the type specified by the distribution dist, with \ (optional) seed s. This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(histogramTransformation[x_?VectorQ, y_?VectorQ] /; \((Length[x] > 0\ && Length[y] > 0)\) := \n\t With[{xrange = Range[Length[x]]}, \n\t\t With[{xs = Sort[Transpose[{x, xrange}]], ys = Sort[Transpose[{y, xrange}]]}, histosort[xs, ys]\ ]]\)], "Input"], Cell[BoxData[ \(histogramTransformation[x_?VectorQ, dist_] /; \((Length[x] > 0)\) := \n \tWith[{y = RandomArray[dist, Length[x]], xrange = Range[Length[x]]}, \n \t\tWith[{xs = Sort[Transpose[{x, xrange}]], ys = Sort[Transpose[{y, xrange}]]}, histosort[xs, ys]]]\)], "Input"], Cell[BoxData[ \(histogramTransformation[x_?VectorQ, dist_, seed_?NumericQ] /; \((Length[x] > 0)\) := \n\t Module[{}, SeedRandom[seed], histogramTransformation[x, dist]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["localMap", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ localMap::usage=\"localMap[z, pt, k, exclude] constructs the indices of neighboring points from z, a matrix of embedded data; pt, the \ point at which to find the neighbors; and k, the number of nearest neighbors \ to use exclude (optional) exclude this point from the preimages. This \ version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("localMap[z, pt, k, exclude] constructs the indices of neighboring \ points from z, a matrix of embedded data; pt, the point at which to find the \ neighbors; and k, the number of nearest neighbors to use exclude (optional) \ exclude this point from the preimages. This version is based on Matlab code \ by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(localMap[z_?MatrixQ, \ pt_?VectorQ, \ k_, \ exclude_Integer] := \n Transpose[Delete[\ Transpose[\ findNeighbour[z, pt, k + 1]], exclude]] \)], "Input"], Cell[BoxData[ \(localMap[z_?VectorQ, \ pt_?NumericQ, \ k_, \ exclude_Integer] := \n Transpose[Delete[\ Transpose[\ findNeighbour[z, pt, k + 1]], exclude]] \)], "Input"], Cell[BoxData[ \(localMap[z_?MatrixQ, \ pt_?VectorQ, \ k_] := findNeighbour[z, pt, k]\)], "Input"], Cell[BoxData[ \(localMap[z_?VectorQ, \ pt_?NumericQ, \ k_] := findNeighbour[z, pt, k]\)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "localLinearFitMap (locallin.m) ", StyleBox[ "(This doesn't quite work yet -- The LinearSolve seems to come up with no \ solution!)", FontColor->RGBColor[1, 0, 0]] }], "Subsection"], Cell[TextData[{ "The reason is that ", StyleBox["Transpose[Join[{Table[1.,{Length[f]}]},Transpose[ p]]] ", FontWeight->"Bold"], "(p with 1's as the first column) has the same length as f, but it's not \ square. That is, the system is underdetermined (x equations in y unknowns, \ where x > y by a long way!). I'm not sure why this happens yet, since the \ function depends on so many other functions it's hard to trace through." }], "Text"], Cell[CellGroupData[{ Cell["\<\ localLinearFitMap::usage=\"localLinearFitMap[z,pt,k,targs,exclude] \ finds a locally linear map for z(t+1) based on embedded values where z is \ embedded data; pt is the point at which to construct the map; k is how many \ neighbors to use; targs -- the actual target values in the time series; \ exclude is a point to be excluded from the map. The output is {a0,a1,val,mn} \ where a0 is the constant in map; a1 is the vector by which to multiply pt; \ val is the value of the map evaluated at pt and mn is value of a locally \ constant map. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("localLinearFitMap[z,pt,k,targs,exclude] finds a locally linear map for \ z(t+1) based on embedded values where z is embedded data; pt is the point at \ which to construct the map; k is how many neighbors to use; targs -- the \ actual target values in the time series; exclude is a point to be excluded \ from the map. The output is {a0,a1,val,mn} where a0 is the constant in map; \ a1 is the vector by which to multiply pt; val is the value of the map \ evaluated at pt and mn is value of a locally constant map. This version is \ based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ \(localLinearFitMap[z_, pt_, k_, targs_, exclude_]\), ":=", "\n", "\t", RowBox[{"Module", "[", RowBox[{\({f, p, foo}\), ",", "\n", RowBox[{"With", "[", RowBox[{ \({lm = \((localMap[z, pt, k, exclude])\)}\), ",", "\n", "\t\t\t", RowBox[{"With", "[", RowBox[{ \({inds = lm\[LeftDoubleBracket]2\[RightDoubleBracket]}\), ",", "\n", "\t\t\t\t\t", RowBox[{ \(blah = inds\), ";", "\n", \(f = \ \(( targs\[LeftDoubleBracket]inds\[RightDoubleBracket]) \)\), ";", "\n", \(p\ = \ z\[LeftDoubleBracket]inds\[RightDoubleBracket]\), ";", "\n", StyleBox[ \( (*\ construct\ an\ augmented\ matrix\ for\ the\ linear\ fit\ *) \), FontColor->GrayLevel[0.500008]], "\n", \(foo\ = LinearSolve[ Transpose[ Join[{Table[1., {Length[f]}]}, Transpose[\ p]]], f] \), ";", "\n", \({\ First[foo], \ Rest[foo], \ \ First[foo]\ + \ pt*Rest[foo], \ Mean[f]}\)}]}], "]"}]}], "]"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{\(localLinearFitMap[z_, pt_, k_, targs_]\), ":=", "\n", "\t\t", RowBox[{"Module", "[", RowBox[{\({f, p, foo}\), ",", RowBox[{"With", "[", RowBox[{\({lm = \((localMap[z, pt, k])\)}\), ",", RowBox[{"With", "[", RowBox[{ \({inds = lm\[LeftDoubleBracket]2\[RightDoubleBracket]}\), ",", "\n", "\t\t\t\t\t\t\t\t", RowBox[{ \(blah = inds\), ";", "\n", \(f = \ \ \((targs\[LeftDoubleBracket]inds\[RightDoubleBracket]) \)\), ";", "\n", \(p\ = \ z\[LeftDoubleBracket]inds\[RightDoubleBracket]\), ";", "\n", StyleBox[ \( (*\ construct\ an\ augmented\ matrix\ for\ the\ linear\ fit\ *) \), FontColor->GrayLevel[0.500008]], \(\n foo\ = LinearSolve[ Transpose[ Join[{Table[1., {Length[f]}]}, Transpose[\ p]]], f]; \n{\ First[foo], \ Rest[foo], \ First[foo]\ + \ pt*\ Rest[foo], \ Mean[f]}\)}]}], "]"}]}], "]"}]}], "]"}]}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["mapControl", "Subsection"], Cell[CellGroupData[{ Cell[TextData[ "mapControl::usage=\"mapControl[x0,map,a,b,n,mu0,xon,xsize] iterates a map \ using linear feedback control.\nx0 -- initial condition\nmap -- the map to \ iterate map[x,param]\na, b -- parameters in the feedback control\nn -- number \ of iterates\n\[Mu]0 -- default value of parameter\nxon, xsize -- turn on \ control when x is in xon+-xsize.\nThis version is based on Matlab code by \ Daniel Kaplan. It is similar to a standard NestList except that the second \ parameter passed to the map varies according to the previous value of of \ iterated function.\""], "Input"], Cell[BoxData[ \("mapControl[x0,map,a,b,n,mu0,xon,xsize] iterates a map using linear \ feedback control. x0 -- initial condition map -- the map to iterate \ map[x,param] a, b -- parameters in the feedback control n -- number of \ iterates \[Mu]0 -- default value of parameter xon, xsize -- turn on control \ when x is in xon+-xsize. This version is based on Matlab code by Daniel \ Kaplan. It is similar to a standard NestList except that the second parameter \ passed to the map varies according to the previous value of of iterated \ function."\)], "Output"] }, Open ]], Cell[BoxData[ \(mapControl[x0_, thismap_Symbol, a_, b_, n_Integer, \[Mu]0_, xon_Integer, xsize_Integer] := \n Rest[NestList[\ \((thismap \ @@{#, If[Abs[# - xon]\ < \ xsize, \ a*# + \ b, \ \ \[Mu]0]}) \)\ &, x0, n]]\)], "Input"], Cell["Applying a Symbol that is the name of a map works like this:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(f\ @@\ {a, b}\)], "Input"], Cell[BoxData[ \({0.702448520503296069`, \(-0.673316793909990085`\), \(-1.1314335406978031`\), \(-0.263251170899063158`\), \(-0.870587192070094495`\), \(-0.465467020591156188`\), 1.4130788741833089`, \(-0.608314967489984592`\), \(-0.0181145688046858222`\), \(-0.67143167232270331`\), 0.342075077098133917`, 1.45928962792189098`, \(-0.851668377802129761`\), 0.807199522869842489`, \(-0.338635340378060156`\), 1.51946345096164598`, \(-0.0066173608535548869`\), 0.0975463494084504567`, \(-0.931701848244958341`\), 0.603364953497210887`}[a, b]\)], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["midCast", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell[BoxData[ \(midCast::usage = "\"\)], "Input"], Cell[BoxData[ \("midCast[z] is similar to getImage[] but for midcasting. This version \ is based on Matlab code by Daniel Kaplan. It requires the MatrixManipulation \ package from the LinearAlgebra group."\)], "Output"] }, Open ]], Cell[BoxData[ \(midCast[z_?MatrixQ] /; \((\(Dimensions[z]\)\[LeftDoubleBracket]2\[RightDoubleBracket] > 2) \) := \nWith[{ col\ = \ Round[.51\ + \ \(Dimensions[z]\)\[LeftDoubleBracket]2\[RightDoubleBracket]/ 2]}, \n{\ \(Delete[#, col]&\)\ z\ , \ TakeColumns[z, {col, col}]}\ ]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["model1", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell[BoxData[ \(model1::usage = "\"\)], "Input"], Cell[BoxData[ \("model1[\[Alpha],\[Beta],\[Nu],x0] runs model 1 dynamics and \ measurements given the noise inputs \[Nu]. x0 is the initial condition. This \ version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(model1[\[Alpha]_, \[Beta]_, \[Nu]_?VectorQ, x0_] := \n\t \[Nu]\ + Rest[NestList[\[Alpha]\ *\ #\ + \ \[Beta]\ &, x0, Length[\[Nu]]]]\)], "Input"], Cell[BoxData[ \(model1[\[Alpha]_, \[Beta]_, \[Nu]_?VectorQ] := \n\t With[{x0\ = \ \[Beta]/\((1 - \[Alpha])\)}, model1[\[Alpha], \[Beta], \[Nu], x0]\ ]\)], "Input"], Cell[BoxData[ \(model1[\[Alpha]_, \[Beta]_] := \n\t With[{x0\ = \ \[Beta]/\((1 - \[Alpha])\), \[Nu] = \ RandomArray[NormalDistribution[0, 1], 10]}, model1[\[Alpha], \[Beta], \[Nu], x0]\ ]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["model1realization (mod1.m)", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell[TextData[ "model1realization::usage=\"model1realization[\[Alpha],\[Beta],n,\[Sigma]] \ generates a realization of model 1 with gaussian measurement noise with \ standard deviation \[Sigma]. This version is based on Matlab code by Daniel \ Kaplan.\""], "Input"], Cell[BoxData[ \("model1realization[\[Alpha],\[Beta],n,\[Sigma]] generates a realization \ of model 1 with gaussian measurement noise with standard deviation \[Sigma]. \ This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(model1realization[\[Alpha]_, \[Beta]_, n_Integer, \[Sigma]_?Positive] := \nWith[{ foo\ = \ RandomArray[NormalDistribution[0, \[Sigma]], n]}, \n\ model1[\[Alpha], \[Beta], foo, \[Beta]/\((.00001 + Abs[1 - \[Alpha]])\)]\ ]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["model2", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell[BoxData[ \(model2::usage = "\"\)], "Input"], Cell[BoxData[ \("model2[\[Alpha],\[Beta],\[Omega],\[Nu],x0] runs model 2 dynamics and \ measurements given the noisy dynamics \[Omega] and measurement inputs \[Nu]. \ x0 is the initial condition. This version is based on Matlab code by Daniel \ Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(\(model2[\[Alpha]_, \[Beta]_, \[Omega]_?VectorQ, \[Nu]_?VectorQ, x0_] := \n\t\[Nu]\ + Rest[FoldList[\[Alpha]\ *\ #1 + \[Beta]\ + #2\ \ &, x0, \[Omega]]]\ \)\)], "Input"], Cell[BoxData[ \(model2[\[Alpha]_, \[Beta]_, \[Omega]_?VectorQ, \[Nu]_?VectorQ] := \n\t With[{x0\ = \ \[Beta]/\((1 - \[Alpha])\)}, model2[\[Alpha], \[Beta], \[Omega], \[Nu], x0]\ ]\)], "Input"], Cell[BoxData[ \(model2[\[Alpha]_, \[Beta]_, \[Omega]_?VectorQ] := \n\t With[{x0\ = \ \[Beta]/\((1 - \[Alpha])\), \[Nu] = RandomArray[NormalDistribution[0, 1], Length[\[Omega]]]}, model2[\[Alpha], \[Beta], \[Omega], \[Nu], x0]\ ]\)], "Input"], Cell[BoxData[ \(model2[\[Alpha]_, \[Beta]_] := \n\t With[{x0\ = \ \[Beta]/\((1 - \[Alpha])\), \[Omega] = \ RandomArray[NormalDistribution[0, 1], 10], \[Nu] = RandomArray[NormalDistribution[0, 1], 10]}, model2[\[Alpha], \[Beta], \[Omega], \[Nu], x0]\ ]\)], "Input", CellDingbat->"\[GraySquare]"] }, Closed]], Cell[CellGroupData[{ Cell["model2realization (mod2.m)", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell[TextData[ "model2realization::usage=\"model2realization[\[Alpha],\[Beta],n,sdyn,smeas] \ generates a realization of model 2, where n = number of points, sdyn = \ standard deviation of dynamical noise, smeas = standard deviation of \ measurement noise. This version is based on Matlab code by Daniel Kaplan.\""], "Input"], Cell[BoxData[ \("model2realization[\[Alpha],\[Beta],n,sdyn,smeas] generates a \ realization of model 2, where n = number of points, sdyn = standard deviation \ of dynamical noise, smeas = standard deviation of measurement noise. This \ version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(model2realization[\[Alpha]_, \[Beta]_, n_Integer, sdyn_?Positive, smeas_?Positive] := \n\t With[{ndyn\ = RandomArray[NormalDistribution[0, sdyn], n], \n nmeas\ = RandomArray[NormalDistribution[0, smeas], n]}, \n\ model2[\[Alpha], \[Beta], ndyn, \ nmeas, \ \[Beta]/\((.00001 + Abs[1 - \[Alpha]])\)]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["crinkleStatistic", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ crinkleStatistic::usage=\"crinkleStatistic[y] calculates the \ crinkle statistic on a vector of de-meaned data: (x_{t-1}-2*x_t+x_{t+1})^4> / < ( x_t^2 ) ^2 \tas proposed by James Theiler. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("crinkleStatistic[y] calculates the crinkle statistic on a vector of \ de-meaned data: (x_{t-1}-2*x_t+x_{t+1})^4> / < ( x_t^2 ) ^2 as proposed by \ James Theiler. This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(crinkleStatistic[data : {__?NumericQ}] /; \((Length[data] > 3\ )\) := \n With[{x\ = data\ - Mean[data]}, With[{x2 = \((Mean[x^2])\)^2}, \n If[x2\ == \ 0\ , 0, \n\t\t\t\t With[{d2\ = \ 2*Drop[Rest[x], \(-1\)] - \ Drop[x, \(-2\)]\ - \ Drop[x, 2]}, \n\ Mean[d2\ ^\ 4]/x2]]\ ]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["kaplanScatterPlot", "Subsection"], Cell[CellGroupData[{ Cell["\<\ kaplanScatterPlot::usage=\"kaplanScatterPlot[data,tau,opts]makes a \ scatter plot of x(t+tau) versus x(t). This version is based on Matlab code by \ Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("kaplanScatterPlot[data,tau,opts]makes a scatter plot of x(t+tau) \ versus x(t). This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(kaplanScatterPlot[data : {__?NumericQ}, \[Tau]_: 1, opts___Rule] /; \((IntegerQ[\[Tau]] && Positive[\[Tau]] && \((\[Tau] < Length[data])\))\) := \n ListPlot[Transpose[{Drop[data, \[Tau]], Drop[data, \(-\[Tau]\)]}], PlotRange \[Rule] All, AspectRatio \[Rule] 1, FilterOptions[ListPlot, opts]]\)], "Input"], Cell[BoxData[ \(kaplanScatterPlot3[data : {__?NumericQ}, \[Tau]_: 1, opts___Rule] /; \((IntegerQ[\[Tau]] && Positive[\[Tau]] && \((2\ \[Tau] < Length[data])\))\) := \n ScatterPlot3D[ Transpose[{Drop[data, 2\ \[Tau]], Drop[Drop[data, \[Tau]], \(-\[Tau]\)], Drop[data, \(-2\)\ \[Tau]]}], PlotRange \[Rule] All, FilterOptions[ScatterPlot3D, opts]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "nonlinearPredictionError (prederr.m) ", StyleBox["(still not working)", FontColor->RGBColor[1, 0, 0]] }], "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(Options[nonlinearPredictionError] = {EmbeddingLag \[Rule] 1, EmbeddingDimension \[Rule] 3}\)], "Input"], Cell[BoxData[ \({EmbeddingLag \[Rule] 1, EmbeddingDimension \[Rule] 3}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ nonlinearPredictionError::usage=\"nonlinearPredictionError[x] \ returns the nonlinear prediction error for time series x. This version is \ based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("nonlinearPredictionError[x] returns the nonlinear prediction error for \ time series x. This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(EmbeddingDimension::usage = "\"\)], "Input"], Cell[BoxData[ \("EmbeddingDimension is an option to nonlinearPredictionError with a \ default value of 3."\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(EmbeddingLag::usage = "\"\)], "Input"], Cell[BoxData[ \("EmbeddingLag is an option to nonlinearPredictionError with a default \ value of 1."\)], "Output"] }, Open ]], Cell[BoxData[ \(nonlinearPredictionError[x_?VectorQ, opts___Rule] := \n Module[{data2, images, lin, const}, \n\t\t With[{lag = \(EmbeddingLag /. {opts}\) /. Options[nonlinearPredictionError], \n\t\t\t\t emdim = \(EmbeddingDimension /. {opts}\) /. Options[nonlinearPredictionError]}, \n\t\t With[{k = If[emdim > 19, emdim + 1, 20]}, \n{data2, \ images}\ = \ getImage[\ mHistory[x, emdim, \ lag], \ lag]; \n{lin, \ const}\ = \ evalMap[\ data2, \ images, \ k]; \n\ Standardize[images - lin]\ ]]]\)], "Input"], Cell[BoxData[ \(\(nonlinearPredictionError[x_?VectorQ, a_Integer, b_Integer] := \n nonlinearPredictionError[x, EmbeddingLag \[Rule] a, EmbeddingDimension \[Rule] b]\n\)\)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["nearNeighbour (nearneib.m)", "Subsection"], Cell["\<\ The function nearneib.m doesn't appear to do anything, given the \ content of the original code. I have implemented the row number (actually \ column in this case) test and the pattern for the function to match, but \ there is currently no return value. \ \>", "Text"], Cell[CellGroupData[{ Cell["\<\ nearNeighbour::usage=\"nearNeighbour[emb, p, k, time, lockout] \ finds the k nearest neighbors of a point in a set of vectors where emb is the \ list of vectors (embedded points?), p is the reference point, k is the number \ of neighbors and lockout is an optional paramater that excludes points that \ are nearby in time. This version is based on Matlab code by Daniel \ Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("nearNeighbour[emb, p, k, time, lockout] finds the k nearest neighbors \ of a point in a set of vectors where emb is the list of vectors (embedded \ points?), p is the reference point, k is the number of neighbors and lockout \ is an optional paramater that excludes points that are nearby in time. This \ version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ \(nearNeighbour[emb_?MatrixQ, \ p_List, \ k_, \ time_, \ lockout_] /; \((\(Dimensions[emb]\)\[LeftDoubleBracket]2\[RightDoubleBracket] == Length[p]\ )\)\), StyleBox[ \( (*\ emb\ and\ p\ must\ have\ the\ same\ number\ of\ columns\ *) \), FontColor->GrayLevel[0.500008]], ":=", "Null"}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["polynomialFitwithCrossValidation (polycv.m)", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ polynomialFitwithCrossValidation::usage=\"\ polynomialFitwithCrossValidation[pre,post,order] calculates the residuals of \ a polynomial fit of post vs pre using leave-one-out cross validation. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("polynomialFitwithCrossValidation[pre,post,order] calculates the \ residuals of a polynomial fit of post vs pre using leave-one-out cross \ validation. This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[TextData[ "polynomialFitwithCrossValidation[pre_?VectorQ,post_?VectorQ,order_Integer]/;\ \n(Length[pre]==Length[post]):=\n\t\ With[{npts=Length[pre],inds=Range[Length[pre]],vars=Table[x^n,{n,0,order}]},\n\ (* loop over all points *)\n\t\ Table[(Fit[Transpose[{Delete[pre,k],Delete[post,k]}],vars,x]/.x\[Rule]pre\ \[LeftDoubleBracket]k\[RightDoubleBracket])-post\[LeftDoubleBracket]k\ \[RightDoubleBracket],{k,npts}] ]"], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["powerTest", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell[BoxData[ \(powerTest::usage = "\ normalized by ^{n/2} \ on a vector This version is based on Matlab code by Daniel Kaplan.\>"\)], "Input"], Cell[BoxData[ \("powertest[x,n] calculates Q=<(x_{t+1})^n> normalized by ^{n/2} on \ a vector This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(powerTest[x_?VectorQ, n_] := \n\t With[{x2\ = \ Mean[x\ *x\ ]^\((n/2)\)}, \n\t\t If[x2 == 0, 0, \n With[{d2 = Rest[x] + Drop[x, \(-1\)], d2a = Rest[x] - Drop[x, \(-1\)]}, {\ Mean[d2\ ^\ n]/x2, Mean[x\ ^\ n]/x2, Mean[d2a\ ^\ n]/x2}\ ]]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["squidSinglePulse (squid1.m)", "Subsection"], Cell[CellGroupData[{ Cell["\<\ squidSinglePulse::usage=\"squidSinglePulse[ amp, dur] stimulates a model of the Squid Giant Axon with a single pulse of amplitude \ amp and duration dur, and returns the voltage sampled at 100 samples per time unit. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("squidSinglePulse[ amp, dur] stimulates a model of the Squid Giant Axon \ with a single pulse of amplitude amp and duration dur, and returns the \ voltage sampled at 100 samples per time unit. This version is based on Matlab \ code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[TextData[{ "squidSinglePulse[amp_?Positive, dur_?Positive]:=\nWith[{a = 5 + dur + \ 30,stims={5,amp,dur} },\n", StyleBox[ "(* save /tmp/stims1 stims -ascii *)\n(* eval(['! /ssnd/bin/hh ' num2str(a) \ ' 1 < /tmp/stims1 > /tmp/res.dat']); *)\n(* load /tmp/res.dat; *)", FontColor->GrayLevel[0.500008]], "\nTakeColumns[res,{3,3}]]" }], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["squidTwoPulse (squid2.m)", "Subsection"], Cell[CellGroupData[{ Cell["\<\ squidTwoPulse::usage=\"squidTwoPulse[ amp1, dur1, interval, amp2, \ dur2] does 2-pulse stimulation of the squid model where amp1, dur1 = amplitude, \ duration of the first pulse; interval = interval between the start of the \ two pulses; and amp2, dur2 = amplitude, duration of the second pulse. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("squidTwoPulse[ amp1, dur1, interval, amp2, dur2] does 2-pulse \ stimulation of the squid model where amp1, dur1 = amplitude, duration of the \ first pulse; interval = interval between the start of the two pulses; and \ amp2, dur2 = amplitude, duration of the second pulse. This version is based \ on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[TextData[{ "squidTwoPulse[ amp1_?Positive, dur1_?Positive, interval_?Positive, \ amp2_?Positive, dur2 _?Positive]:=\n\tWith[{a = 5 + dur1 + dur2 + interval + \ 30,\nstims={{5,amp1,dur1},{5+interval,amp2,dur2}} },\n", StyleBox[ "(* save /tmp/stims2 stims -ascii *)\n(* eval(['! /ssnd/bin/hh ' num2str(a) \ ' 1 < /tmp/stims2 > /tmp/res.dat']); *)\n(* load /tmp/res.dat; *)", FontColor->GrayLevel[0.500008]], "\nTakeColumns[res,{3,3}]]" }], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["timeReversalAssymetryStatistic (timerev.m)", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell[BoxData[ \(timeReversalAssymetryStatistic::usage = "\"\)], "Input"], Cell[BoxData[ \("timeReversalAssymetryStatistic[x,lag calculates a time reversal \ asymmetry statistic. This version is based on Matlab code by Daniel \ Kaplan."\)], "Output"] }, Open ]], Cell["\<\ Here's an faster version that doesn't require loading in \ LinearAlgebra`MatrixManipulation`\ \>", "Text"], Cell[BoxData[ \(timeReversalAssymetryStatistic[x_, lag_: 1] := \n\t With[{foo = mHistory[x, 3, lag]}, \n\t\t With[{a = \(Transpose[foo]\)\[LeftDoubleBracket]1\[RightDoubleBracket], b = \(Transpose[foo]\)\[LeftDoubleBracket]2\[RightDoubleBracket], c = \(Transpose[foo]\)\[LeftDoubleBracket]3 \[RightDoubleBracket]}, \nMean[a*a*b\ - \ b*c*c]]]\)], "Input"], Cell["\<\ Here's an alternative version that uses \ LinearAlgebra`MatrixManipulation`, which looks neater, but is slower in the \ end.\ \>", "Text"], Cell[BoxData[ \(timeReversalAssymetryStatisticSlower[x_, lag_: 1] := \n\t With[{foo = mHistory[x, 3, lag]}, \n\t\t With[{a = Flatten[TakeColumns[foo, {1, 1}]], b = Flatten[TakeColumns[foo, {2, 2}]], c = Flatten[TakeColumns[foo, {3, 3}]]}, \n Mean[a*a*b\ - \ b*c*c]]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["theilerQ", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ theilerQ::\"usage\"=\"theilerQ calculates Q=(x_t +x_{t+1})^3 \ normalized by x^2^{3/2} where x is vector. This version is based on Matlab \ code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("theilerQ calculates Q=(x_t +x_{t+1})^3 normalized by x^2^{3/2} where x \ is vector. This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(theilerQ[x : {__?NumericQ}] := \n With[{x2\ = Mean[x\ *\ x]^\((3/2)\)}, \n\t\t If[x2 == 0, 0, Mean[\((Rest[x] + Drop[x, \(-1\)])\)^3]/x2]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["typicalDistances (disttyp.m)", "Subsection", CellDingbat->"\[GraySquare]"], Cell[BoxData[ \(Clear[typicalDistances]\)], "Input"], Cell[CellGroupData[{ Cell["\<\ typicalDistances::usage=\"typicalDistances[z,percs] calculates \ typical distances between pre-images where z is some embedded data, and percs \ are the percentiles to use. It returns distances at the given percentiles. \ All of this is from a small sample of all pairs of distances. This version is \ based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("typicalDistances[z,percs] calculates typical distances between \ pre-images where z is some embedded data, and percs are the percentiles to \ use. It returns distances at the given percentiles. All of this is from a \ small sample of all pairs of distances. This version is based on Matlab code \ by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[TextData[{ "typicalDistances[z_,percs_]:=\n", StyleBox["(* all the elements of percs must be between 0 and 1 *)", FontColor->GrayLevel[0.500008]], "\nModule[{ntargs,dists},With[{Npts = Length[z]},\n", StyleBox["(* we want up to 10000 points *)", FontColor->GrayLevel[0.500008]], "\nntargs = Min[Npts, Ceiling[10000/(Npts-1)]];\n \ dists=Drop[Sort[Take[Flatten[Table[oneDist[z,z\[LeftDoubleBracket]j\ \[RightDoubleBracket]],{j,ntargs}]],Npts*ntargs]],ntargs];\n", StyleBox["(* get rid of the zeros corresponding to self-distances *)", FontColor->GrayLevel[0.500008]], "\nWith[{\[ScriptD]=Length[dists]}, Table[dists\[LeftDoubleBracket] Min[ \ Max[Round[percs\[LeftDoubleBracket]p\[RightDoubleBracket]*(\[ScriptD]-1)],0],\ \[ScriptD]-1]+1 \[RightDoubleBracket],{p,1,Length[percs]}] ]]] /;(And @@ (((# \ >0. )&& (# <1.))& /@ percs))" }], "Input"] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "zeroPredictionError (zeropred.m) ", StyleBox["(not quite finished?)", FontColor->RGBColor[1, 0, 0]] }], "Subsection"], Cell[CellGroupData[{ Cell[TextData[ "zeroPredictionError::usage=\"zeroPredictionError calculates prediction error \ from time-series. Calculates mean error of zeroth order prediction of entire \ series. Mean error is normalized by dividing by error of constant\nprediction \ = mean of series, to get NPE (norm. pred. error). This version is based on \ Matlab code by Daniel Kaplan. This Mathematica version has four options with \ the following defaults: {NumberOfNeighbours\[Rule]10, MaxHorizon\[Rule]10, \ Lag\[Rule]1, EmbeddingDimension\[Rule]3}\""], "Input"], Cell[BoxData[ \("zeroPredictionError calculates prediction error from time-series. \ Calculates mean error of zeroth order prediction of entire series. Mean error \ is normalized by dividing by error of constant prediction = mean of series, \ to get NPE (norm. pred. error). This version is based on Matlab code by \ Daniel Kaplan. This Mathematica version has four options with the following \ defaults: {NumberOfNeighbours\[Rule]10, MaxHorizon\[Rule]10, Lag\[Rule]1, \ EmbeddingDimension\[Rule]3}"\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Options[zeroPredictionError] = {NumberOfNeighbours \[Rule] 10, MaxHorizon \[Rule] 10, Lag \[Rule] 1, EmbeddingDimension \[Rule] 3} \)], "Input"], Cell[BoxData[ \({NumberOfNeighbours \[Rule] 10, MaxHorizon \[Rule] 10, Lag \[Rule] 1, EmbeddingDimension \[Rule] 3}\)], "Output"] }, Open ]], Cell[BoxData[ RowBox[{\(zeroPredictionError[data_?VectorQ, opts___Rule]\), ":=", RowBox[{"With", "[", RowBox[{ \({\[ScriptCapitalN] = Length[data], \n\t\t\t k = \(NumberOfNeighbours /. {opts}\) /. Options[zeroPredictionError], \n\t\t\t Hmax = \(MaxHorizon /. {opts}\) /. Options[zeroPredictionError], \n\t\t\t\[ScriptCapitalL] = \(Lag /. {opts}\) /. Options[zeroPredictionError], \n\t\t\t \[ScriptCapitalE] = \(EmbeddingDimension /. {opts}\) /. Options[zeroPredictionError], \n\t\t\t huge = 1000000000000000000}\), ",", "\n", RowBox[{"Module", "[", RowBox[{ \({xx, me, End, m1, m2, normE, a, tot, \ error, \ merror, sorted, index}\), ",", "\n", "\t\t\t", RowBox[{ \(xx = mHistory[data, \[ScriptCapitalE], \[ScriptCapitalL]]\), " ", ";", "\n", StyleBox[ \( (*\ Find\ mean\ of\ portion\ of\ time\ series\ to\ be\ predicted\ *) \), FontColor->GrayLevel[0.500008]], "\n", " ", \(me = Mean[ Take[\(Transpose[xx] \)\[LeftDoubleBracket]\[ScriptCapitalE]\ \[RightDoubleBracket], { 1 + \((\[ScriptCapitalE] - 1)\)*\[ScriptCapitalL] + 2*Hmax, \[ScriptCapitalN] - \((\[ScriptCapitalE] - 1)\)*\[ScriptCapitalL]}]]\), ";", "\n", " ", \(End = \[ScriptCapitalN] - \((\[ScriptCapitalE] - 1)\)*\[ScriptCapitalL] - Hmax\), ";", "\n", StyleBox[ \( (*\ Find\ k\ nearest\ neighbors\ of\ xx \((j)\)\ *) \), FontColor->GrayLevel[0.500008]], "\n", RowBox[{"Do", "[", " ", "\n", " ", RowBox[{ RowBox[{ \(m1 = Max[0, j - 50]\), ";", " ", \(m2 = Min[j + 50, End + 1]\), ";", "\n", " ", \(normE = Join[Table[ \((xx\[LeftDoubleBracket]i, Range[\[ScriptCapitalE]] \[RightDoubleBracket] - xx\[LeftDoubleBracket]j, Range[\[ScriptCapitalE]] \[RightDoubleBracket])\). \((xx\[LeftDoubleBracket]i, Range[\[ScriptCapitalE]] \[RightDoubleBracket] - xx\[LeftDoubleBracket]j, Range[\[ScriptCapitalE]] \[RightDoubleBracket])\), {i, m1}], Table[huge, {m2 - m1}]]\), ";", "\n", " ", \({sorted, index} = Sort[normE]\), ";", "\n", "\t\t ", StyleBox[ \( (*\ xx\[LeftDoubleBracket]index \((1 : k)\), 1 : E\[RightDoubleBracket]\ are\ the\ k\ nearest \ neighbors\ of\ xx\[LeftDoubleBracket]j\[RightDoubleBracket]\ *) \), FontColor->GrayLevel[0.500008]], StyleBox["\n", FontColor->GrayLevel[0.500008]], StyleBox[ \( (*\ Next\ find\ the\ zeroth\ order\ prediction\ for \ xx \((j + H, E)\)\ *) \), FontColor->GrayLevel[0.500008]], StyleBox["\n", FontColor->GrayLevel[0.500008]], StyleBox[ \( (*\ Record\ the\ prediction\ error\ in\ the\ error \ array\ *) \), FontColor->GrayLevel[0.500008]], StyleBox["\n", FontColor->GrayLevel[0.500008]], StyleBox[ \( (*\ Record\ the\ prediction\ error\ of\ predicting \ the\ mean\ in\ merror\ *) \), FontColor->GrayLevel[0.500008]], "\n", " ", \(error\[LeftDoubleBracket]j\[RightDoubleBracket] = Table[xx\[LeftDoubleBracket]j + H, \[ScriptCapitalE]\[RightDoubleBracket] - \((Plus\ @@\ \((\ xx \[LeftDoubleBracket]Range[H + 1, H + k], \[ScriptCapitalE]\[RightDoubleBracket]) \)/k)\), {H, Hmax}]\), ";", "\n", " ", \(merror\[LeftDoubleBracket]j\[RightDoubleBracket] = Table[xx\[LeftDoubleBracket]j + H, \[ScriptCapitalE]\[RightDoubleBracket] - me, { H, Hmax}]; \)}], " ", ",", \({j, End}\)}], "]"}], ";", " ", \( (*\ end\ of\ loop\ for\ each\ index\ point*) \), "\n", "\n", StyleBox[ \( (*\ Compute\ normalized\ mean\ prediction\ error\ *) \), FontColor->GrayLevel[0.500008]], "\n", " ", \(npe = Table[\ norm[ \(Normalize[error] \)\[LeftDoubleBracket]\[ScriptH]\ \[RightDoubleBracket]]/\ Normalize[ \(Transpose[merror] \)\[LeftDoubleBracket]\[ScriptH]\ \[RightDoubleBracket]], {\[ScriptH], Hmax}]\), ";", "\n", StyleBox[ \( (*\ Write\ the\ horizon\ and\ normalized\ mean\ prediction\ error\ to\ disk\ *) \), FontColor->GrayLevel[0.500008]], "\n", \(Transpose[{Range[Hmax], TakeMatrix[\ npe, {1, 1}, {Hmax, \[ScriptCapitalE]}]}]\), ";"}]}], "\n", "]"}]}], "]"}]}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Maps", "Section"], Cell["Maps are also really easy to do as anonymous functions.", "Text"], Cell[CellGroupData[{ Cell["henonMap", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ henonMap::usage=\"henonMap[{x1,x2},p] gives a single iteration of \ the Henon map. Note that the p parameter doesn't appear to do anything and is \ included only for comparability with other map functions in this \ notebook.This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("henonMap[{x1,x2},p] gives a single iteration of the Henon map. Note \ that the p parameter doesn't appear to do anything and is included only for \ comparability with other map functions in this notebook.This version is based \ on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(henonMap[{x1_, x2_}, p_] := \n{1.4\ + \ 0.3\ *\ x2\ - \ x1*x2, \ x1}\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["quadraticMap", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell[BoxData[ \(quadraticMap::usage = "\"\)], "Input"], Cell[BoxData[ \("quadraticMap[x,p] gives a single iteration of the quadratic map. This \ version is based on Matlab code by Daniel Kaplan. The parameter p is optional \ and has a default value of 4, the chaotic value."\)], "Output"] }, Open ]], Cell[BoxData[ \(\(quadraticMap[x_, p_: 4] := \ p\ *\ x\ *\ \((1 - x)\); \)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["squidMap", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ squidMap::usage=\"squidMap[x,p] creates something that looks like \ the squid map, symmetric around x=0.5, where x is the state and p is a parameter representing inter-stimulus interval. This version is \ based on Matlab code by Daniel Kaplan. ALERT! Make sure you use the \ appropriate values for x and p to avoid Overflow.\"\ \>", "Input"], Cell[BoxData[ \("squidMap[x,p] creates something that looks like the squid map, \ symmetric around x=0.5, where x is the state and p is a parameter \ representing inter-stimulus interval. This version is based on Matlab code by \ Daniel Kaplan. ALERT! Make sure you use the appropriate values for x and p \ to avoid Overflow."\)], "Output"] }, Open ]], Cell[BoxData[ \(squidMap[x_, p_] := \n\t With[{\[ScriptX] = If[x > 0.5, 1 - x, x]}, \n If[\ \[ScriptX]\ < \ .693/p, \((\ Exp[\[ScriptX]*p] - 1)\)^3, \ 1 - .05*\[ScriptX]]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["tentMap", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ tentMap::usage=\"tentMap[x,p] tent map of x at parameter p. p = 1.99999 is the chaotic one. This version is based on Matlab code by \ Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("tentMap[x,p] tent map of x at parameter p. p = 1.99999 is the chaotic \ one. This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(tentMap[x_, p_?NumericQ] /; \((x > 0\ && \ x < 1)\) := p*\ If[x\ > \ 0.5, 1 - x, x]\)], "Input"], Cell[BoxData[ \(ListPlot[NestList[tentMap[#, 1.8]&, 0.49, 1000], PlotJoined \[Rule] True] // Timing\)], "Input"], Cell[TextData[ "{0.266667 Second,\[SkeletonIndicator]Graphics\[SkeletonIndicator]}"], "Text"], Cell[TextData[ "{0.333333 Second,\[SkeletonIndicator]Graphics\[SkeletonIndicator]}"], "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["delta-epsilon", "Section"], Cell[CellGroupData[{ Cell["getImage", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ getImage::usage=\"getImage[data, pred] finds the scalar images of the points in a time series time sets in \ the future data --- matrix of embedded data (from mHistory) pred --- look ahead time, default value 1. It returns data2 --- a new \ embedded data matrix appropriately trimmed, and images --- the images (at \ time ) of the points in data2. This is a convenience program to trim an \ embedding appropriately. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("getImage[data, pred] finds the scalar images of the points in a time \ series time sets in the future data --- matrix of embedded data (from \ mHistory) pred --- look ahead time, default value 1. It returns data2 --- a \ new embedded data matrix appropriately trimmed, and images --- the images (at \ time ) of the points in data2. This is a convenience program to trim an \ embedding appropriately. This version is based on Matlab code by Daniel \ Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(getImage[data_?MatrixQ, pred_Integer: 1] := \n{\ Drop[data, pred], First\ /@\ Drop[data, \(-pred\)]}\)], "Input"], Cell[BoxData[ \(getImage[data_List, pred_Integer: 1] := \n{\ Drop[data, pred], First\ /@\ Drop[data, \(-pred\)]}\)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["oneDist", "Subsection", CellDingbat->"\[GraySquare]"], Cell[CellGroupData[{ Cell["\<\ oneDist::usage=\"oneDist[data,pt] calculates the distance between \ point pt and each row in matrix data. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("oneDist[data,pt] calculates the distance between point pt and each row \ in matrix data. This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(oneDist[data_?MatrixQ, pt_?VectorQ] /; \((\(Dimensions[data]\)\[LeftDoubleBracket]2\[RightDoubleBracket]\ == \ Length[pt])\)\ := \n Sqrt[Table[ Plus\ @@\(( \((data\[LeftDoubleBracket]i\[RightDoubleBracket] - pt)\)^2) \), {i, Length[data]}]]\)], "Input"], Cell[BoxData[ \(oneDist[data_?VectorQ, pt_?NumericQ] := \n Sqrt[Table[ Plus\ @@\(( \((data\[LeftDoubleBracket]i\[RightDoubleBracket] - pt)\)^2) \), {i, Length[data]}]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["deltaepsilonFit", "Subsection"], Cell[CellGroupData[{ Cell["\<\ deltaepsilonFit::usage=\"linear fitting routine for delta-epsilon \ method. delta --distances between pre-images: output by delta-epsilon epsilon -- distances between images: output by delta-epsilon maxdelta-- optional - largest delta to consider. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("linear fitting routine for delta-epsilon method. delta --distances \ between pre-images: output by delta-epsilon epsilon -- distances between \ images: output by delta-epsilon maxdelta-- optional - largest delta to \ consider. This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[TextData[ "\ndeltaepsilonFit[delta_,epsilon_,maxdelta_:(10^100)]:=\n(* get rid of \ points whose pre-images are too far apart *)\n\ Module[{x,y,i,s,sx,sy,sxx,sxy,del},\nWith[{foo =Transpose[Select[ \ Transpose[delta],#\[LeftDoubleBracket]2\[RightDoubleBracket] < maxdelta &]]},\ \n\t\tWith[{delta2 = \ delta\[LeftDoubleBracket]foo\[RightDoubleBracket],epsilon2 = epsilon\ \[LeftDoubleBracket]foo\[RightDoubleBracket]},\n(* Sort the pairs into \ ascending order on delta *)\n{x,i}= Sort[delta2];\ny = epsilon2\ \[LeftDoubleBracket]i\[RightDoubleBracket];\ns = Length[x];\nsx =Plus @@ x;\n\ sy =Plus @@ y;\nsxx =Plus @@( x^2);\nsxy = Plus @@( x*y);\ndel = s*sxx - \ sx*sx;\n{(sxx*sy - sx*sxy)/del,(s*sxy - sx*sy)/del} ]]]"], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["deltaEpsilonMethod", "Subsection"], Cell[CellGroupData[{ Cell["\<\ deltaEpsilonMethod::usage=\"deltaEpsilonMethod[z, images, lockout] \ implements the Delta-epsilon method where z is embedded data as from \ getImage[], images as from getImage[], and lockout is an optional argument \ that excludes points closer than the specified value.This version is based on \ Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("deltaEpsilonMethod[z, images, lockout] implements the Delta-epsilon \ method where z is embedded data as from getImage[], images as from \ getImage[], and lockout is an optional argument that excludes points closer \ than the specified value.This version is based on Matlab code by Daniel \ Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ \(deltaEpsilonMethod[z_, \ images_, \ lockout_: 0]\), ":=", "\n", "\t", RowBox[{"Module", "[", RowBox[{\({delta, epsilon, \ count, kk}\), ",", "\n", RowBox[{"With", "[", RowBox[{\({npts\ = Length[z]}\), ",", "\n", "\t\t\t", RowBox[{"With", "[", RowBox[{\({k = Min[npts - 2, 20]}\), ",", "\n", RowBox[{ \(delta = Flatten[ZeroMatrix[k*npts, 1]]\), ";", "\n", \(epsilon = delta\), ";", "\n", \(count = 0\), ";", "\n", RowBox[{"Do", "[", StyleBox[" ", FontColor->GrayLevel[0.500008]], StyleBox[ RowBox[{ StyleBox["(*", FontColor->GrayLevel[0.500008]], StyleBox[" ", FontColor->GrayLevel[0.500008]], RowBox[{ StyleBox[\(find\ the\ nearest\ neighbors\), FontColor->GrayLevel[0.500008]], StyleBox[",", FontColor->GrayLevel[0.500008]], \(eliminating\ the\ ones\ closer\ in\ time\ than\ the\ lockout\)}], StyleBox[ RowBox[{" ", StyleBox[" ", FontColor->GrayLevel[0.500008]]}]], StyleBox["*)", FontColor->GrayLevel[0.500008]]}], FontColor->GrayLevel[0.500008]], "\n", " ", RowBox[{ RowBox[{ \({inds, dists}\ = Transpose[ Cases[Transpose[\ findNeighbour[z, \ z\[LeftDoubleBracket]i \[RightDoubleBracket], \ k + 10]], \((\ Abs[#\[LeftDoubleBracket]1 \[RightDoubleBracket]\ - \ i]\ )\) > \ lockout\ \ &]\ ]\), ";", "\n", " ", \(kk\ = \ Min[Length[dists], k]\), ";", "\n", StyleBox["\t ", FontColor->GrayLevel[0.500008]], StyleBox[ \( (*\ store\ the\ distances\ between\ pre - images\ in\ the\ output\ *) \), FontColor->GrayLevel[0.500008]], "\n", RowBox[{" ", RowBox[{ \(delta\[LeftDoubleBracket]count + 1, count + kk\[RightDoubleBracket]\ = \ Take[dists, kk]\), ";", "\n", "\t ", StyleBox[ \( (*\ store\ the\ distances\ between\ images\ *) \), FontColor->GrayLevel[0.500008]], "\n", \(\ \ epsilon\[LeftDoubleBracket]count + 1, count + kk\[RightDoubleBracket]\ = \ images \[LeftDoubleBracket]Take[inds, kk] \[RightDoubleBracket]\ - \ images\[LeftDoubleBracket]i \[RightDoubleBracket]; \n\ \ \(count\ = \ count + kk; \)\)}]}]}], "\n", "\t\t\t\t\t", ",", \({i, npts}\)}], "]"}], ";", "\n", StyleBox[ \( (*\ take\ the\ absolute\ value\ of\ the\ distances\ between\ images\ *) \), FontColor->GrayLevel[0.500008]], "\n", \({Abs[Take[epsilon, count]], Take[\ delta, count]}\)}]}], " ", "]"}]}], "]"}]}], "]"}]}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["DoDE", "Subsection"], Cell[CellGroupData[{ Cell["\<\ DoDE::usage=\"DoDE[ts,dim,lag,nsurrs] runs deltaeps on some data \ and surrogates. This version is based on Matlab code by Daniel Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("DoDE[ts,dim,lag,nsurrs] runs deltaeps on some data and surrogates. \ This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ \(DoDE[ts_, dim_, lag_, nsurrs_] := \n{\ quickDE[ts, dim, lag], Table[quickDE[ampsurr[ts], dim, lag], {nsurrs}]}\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["quickDE", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(quickDE::usage = "\"\)], "Input"], Cell[BoxData[ \("quickDE[ts,dim,lag,nmin] does a quick-and-dirty characterization of \ determinism using de: ts -- the time series dim -- the embedding dimension \ lag -- the embedding lag nmin -- optional: number of points to use for \ delta-eps fitting -- default value: 500 This version is based on Matlab code \ by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[TextData[{ "quickDE[ts_,dim_,lag_,nmin_:500]:=\n\t\ Module[{pre,post,perc,deltamax,delta,epsilon},\n", StyleBox[ "(* embed the data and get the 'forecasting' pre-image and image *)", FontColor->GrayLevel[0.500008]], "\n{pre,post}= getImage[ mHistory[ts,dim,lag],1];\n", StyleBox[ "(* find a 'typical' distance to use for delta-epsilon\n we want to have at \ least nmin points, so we pick *)", FontColor->GrayLevel[0.500008]], "\nperc = (2*nmin)/(Length[ts])^2;\ndeltamax = typicalDistances[pre,perc];\n\ {delta,epsilon} = deltaEpsilonMethod[pre,post];\n \ deltaepsilonFit[delta,epsilon,deltamax] ]" }], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["plotDE", "Subsection"], Cell[CellGroupData[{ Cell["\<\ plotDE::usage=\"plotDE[delta,epsilon,opts] makes a cumulative plot \ of epsilon vs delta that is useful for picking length scales and for \ comparing to surrogate data. This version is based on Matlab code by Daniel \ Kaplan.\"\ \>", "Input"], Cell[BoxData[ \("plotDE[delta,epsilon,opts] makes a cumulative plot of epsilon vs delta \ that is useful for picking length scales and for comparing to surrogate data. \ This version is based on Matlab code by Daniel Kaplan."\)], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{\(plotDE[delta_, epsilon_, opts___Rule]\), ":=", "\n", StyleBox[\( (*\ sort\ delta\ and\ epsilon\ *) \), FontColor->GrayLevel[0.500008]], "\n", \(With[{{d, inds}\ = Transpose[Sort[Transpose[delta]]]}, \n\t\t With[{ee\ = \ NestList[Plus, First[epsilon\[LeftDoubleBracket]inds \[RightDoubleBracket]], Rest[epsilon\[LeftDoubleBracket]inds \[RightDoubleBracket]]]/Range[Length[inds]]}, \n ListPlot[d, ee, PlotJoined \[Rule] True, FilterOptions[ListPlot, opts]]\ ]]\)}], ";"}]], "Input"] }, Closed]] }, Open ]] }, Open ]] }, Open ]] }, FrontEndVersion->"Macintosh 3.0", ScreenRectangle->{{0, 1152}, {0, 850}}, WindowSize->{824, 740}, WindowMargins->{{Automatic, 64}, {Automatic, 41}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, MacintoshSystemPageSetup->"\<\ 01h0005X0FP000003g`;C?oComH@A0]f8085N`?P0000005X0FP000003g`;C05/ 038;C4LH05000@4100000BL?00400@=9NF00000000000000000000000040I000 00000000000@X@804A000000001C>30`\>" ] (*********************************************************************** 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, 91, 1, 136, "Title"], Cell[1825, 54, 186, 6, 32, "Text"], Cell[2014, 62, 52, 1, 27, "Input"], Cell[CellGroupData[{ Cell[2091, 67, 40, 0, 42, "Subsubsection"], Cell[2134, 69, 265, 5, 46, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[2436, 79, 41, 0, 46, "Subsection"], Cell[2480, 81, 84, 1, 27, "Input"], Cell[2567, 84, 36, 0, 30, "Text"], Cell[2606, 86, 79, 1, 27, "Input"], Cell[2688, 89, 91, 3, 30, "Text"], Cell[2782, 94, 74, 1, 27, "Input"], Cell[2859, 97, 73, 0, 30, "Text"], Cell[2935, 99, 70, 1, 27, "Input"], Cell[3008, 102, 67, 0, 30, "Text"], Cell[3078, 104, 64, 1, 27, "Input"], Cell[3145, 107, 42, 0, 30, "Text"], Cell[3190, 109, 66, 1, 27, "Input"], Cell[3259, 112, 46, 0, 30, "Text"], Cell[3308, 114, 79, 1, 27, "Input"], Cell[3390, 117, 67, 0, 30, "Text"], Cell[3460, 119, 78, 1, 27, "Input"], Cell[3541, 122, 81, 1, 27, "Input"], Cell[3625, 125, 97, 3, 30, "Text"], Cell[CellGroupData[{ Cell[3747, 132, 42, 1, 27, "Input"], Cell[3792, 135, 632, 11, 70, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[4473, 152, 47, 0, 30, "Subsection"], Cell[4523, 154, 3605, 105, 378, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[8165, 264, 41, 0, 48, "Subsubtitle"], Cell[CellGroupData[{ Cell[8231, 268, 120, 3, 42, "Subsubsection"], Cell[CellGroupData[{ Cell[8376, 275, 378, 6, 91, "Input"], Cell[8757, 283, 342, 5, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[9136, 293, 264, 4, 75, "Input"], Cell[9403, 299, 230, 3, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[9670, 307, 202, 3, 59, "Input"], Cell[9875, 312, 163, 2, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[10075, 319, 277, 4, 75, "Input"], Cell[10355, 325, 241, 3, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[10633, 333, 118, 2, 27, "Input"], Cell[10754, 337, 77, 1, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[10868, 343, 125, 2, 43, "Input"], Cell[10996, 347, 97, 2, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[11130, 354, 123, 2, 43, "Input"], Cell[11256, 358, 97, 2, 70, "Output"] }, Open ]], Cell[11368, 363, 2733, 52, 347, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[14138, 420, 33, 0, 28, "Subsubsection"], Cell[CellGroupData[{ Cell[14196, 424, 366, 6, 75, "Input"], Cell[14565, 432, 339, 5, 70, "Output"] }, Open ]], Cell[14919, 440, 69, 1, 27, "Input"], Cell[14991, 443, 160, 3, 43, "Input"], Cell[15154, 448, 323, 5, 59, "Input"], Cell[15480, 455, 69, 1, 27, "Input"], Cell[15552, 458, 160, 3, 43, "Input"], Cell[15715, 463, 323, 5, 59, "Input"] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[16087, 474, 158, 5, 32, "Subsubtitle"], Cell[CellGroupData[{ Cell[16270, 483, 61, 1, 46, "Subsection"], Cell[CellGroupData[{ Cell[16356, 488, 222, 4, 57, "Input"], Cell[16581, 494, 216, 3, 70, "Output"] }, Open ]], Cell[16812, 500, 854, 15, 171, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[17703, 520, 60, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[17788, 525, 282, 5, 72, "Input"], Cell[18073, 532, 275, 4, 70, "Output"] }, Open ]], Cell[18363, 539, 406, 6, 59, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[18806, 550, 29, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[18860, 554, 330, 8, 102, "Input"], Cell[19193, 564, 325, 5, 70, "Output"] }, Open ]], Cell[19533, 572, 178, 3, 59, "Input"], Cell[19714, 577, 118, 2, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[19869, 584, 62, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[19956, 589, 450, 8, 102, "Input"], Cell[20409, 599, 441, 6, 70, "Output"] }, Open ]], Cell[20865, 608, 309, 7, 59, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[21211, 620, 42, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[21278, 624, 368, 7, 87, "Input"], Cell[21649, 633, 349, 5, 70, "Output"] }, Open ]], Cell[22013, 641, 301, 5, 75, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[22351, 651, 31, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[22407, 655, 336, 7, 102, "Input"], Cell[22746, 664, 333, 5, 70, "Output"] }, Open ]], Cell[23094, 672, 552, 12, 75, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[23683, 689, 41, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[23749, 693, 228, 4, 57, "Input"], Cell[23980, 699, 221, 3, 70, "Output"] }, Open ]], Cell[24216, 705, 272, 4, 75, "Input"], Cell[24491, 711, 117, 3, 30, "Text"], Cell[24611, 716, 298, 5, 75, "Input"], Cell[CellGroupData[{ Cell[24934, 725, 221, 5, 72, "Input"], Cell[25158, 732, 216, 3, 70, "Output"] }, Open ]], Cell[25389, 738, 140, 2, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[25566, 745, 48, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[25639, 749, 284, 5, 75, "Input"], Cell[25926, 756, 254, 4, 70, "Output"] }, Open ]], Cell[26195, 763, 1317, 24, 187, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[27549, 792, 29, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[27603, 796, 497, 10, 147, "Input"], Cell[28103, 808, 497, 7, 86, "Output"] }, Open ]], Cell[28615, 818, 298, 5, 72, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[28950, 828, 54, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[29029, 832, 516, 8, 123, "Input"], Cell[29548, 842, 486, 7, 70, "Output"] }, Open ]], Cell[30049, 852, 72, 1, 24, "Input"], Cell[CellGroupData[{ Cell[30146, 857, 375, 7, 107, "Input"], Cell[30524, 866, 344, 5, 70, "Output"] }, Open ]], Cell[30883, 874, 1253, 24, 235, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[32173, 903, 80, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[32278, 908, 416, 10, 147, "Input"], Cell[32697, 920, 411, 6, 71, "Output"] }, Open ]], Cell[33123, 929, 525, 10, 75, "Input"], Cell[33651, 941, 412, 8, 59, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[34100, 954, 31, 0, 46, "Subsection"], Cell[CellGroupData[{ Cell[34156, 958, 194, 4, 57, "Input"], Cell[34353, 964, 186, 3, 70, "Output"] }, Open ]], Cell[34554, 970, 185, 3, 59, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[34776, 978, 34, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[34835, 982, 253, 5, 57, "Input"], Cell[35091, 989, 205, 3, 41, "Output"] }, Open ]], Cell[35311, 995, 1539, 32, 155, "Input"], Cell[36853, 1029, 967, 19, 139, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[37857, 1053, 91, 1, 46, "Subsection"], Cell[CellGroupData[{ Cell[37973, 1058, 45, 1, 27, "Input"], Cell[38021, 1061, 296, 4, 52, "Print"], Cell[38320, 1067, 629, 16, 67, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[38986, 1088, 326, 5, 75, "Input"], Cell[39315, 1095, 297, 4, 56, "Output"] }, Open ]], Cell[39627, 1102, 532, 11, 91, "Input"], Cell[40162, 1115, 373, 5, 62, "Text"], Cell[CellGroupData[{ Cell[40560, 1124, 450, 7, 107, "Input"], Cell[41013, 1133, 412, 6, 71, "Output"] }, Open ]], Cell[41440, 1142, 309, 6, 75, "Input"], Cell[41752, 1150, 308, 5, 75, "Input"], Cell[42063, 1157, 203, 4, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[42303, 1166, 62, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[42390, 1171, 364, 6, 87, "Input"], Cell[42757, 1179, 357, 5, 71, "Output"] }, Open ]], Cell[43129, 1187, 185, 3, 43, "Input"], Cell[43317, 1192, 186, 3, 43, "Input"], Cell[43506, 1197, 104, 2, 27, "Input"], Cell[43613, 1201, 109, 2, 27, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[43759, 1208, 207, 6, 46, "Subsection"], Cell[43969, 1216, 452, 8, 64, "Text"], Cell[CellGroupData[{ Cell[44446, 1228, 626, 10, 117, "Input"], Cell[45075, 1240, 605, 8, 101, "Output"] }, Open ]], Cell[45695, 1251, 1499, 33, 171, "Input"], Cell[47197, 1286, 1416, 30, 139, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[48650, 1321, 32, 0, 46, "Subsection"], Cell[CellGroupData[{ Cell[48707, 1325, 584, 8, 177, "Input"], Cell[49294, 1335, 563, 8, 70, "Output"] }, Open ]], Cell[49872, 1346, 307, 7, 43, "Input"], Cell[50182, 1355, 76, 0, 30, "Text"], Cell[CellGroupData[{ Cell[50283, 1359, 46, 1, 27, "Input"], Cell[50332, 1362, 637, 10, 70, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[51018, 1378, 61, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[51104, 1383, 248, 4, 59, "Input"], Cell[51355, 1389, 223, 3, 70, "Output"] }, Open ]], Cell[51593, 1395, 382, 8, 59, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[52012, 1408, 60, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[52097, 1413, 253, 4, 59, "Input"], Cell[52353, 1419, 227, 3, 70, "Output"] }, Open ]], Cell[52595, 1425, 184, 4, 43, "Input"], Cell[52782, 1431, 183, 3, 43, "Input"], Cell[52968, 1436, 231, 4, 59, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[53236, 1445, 80, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[53341, 1450, 265, 4, 57, "Input"], Cell[53609, 1456, 242, 3, 70, "Output"] }, Open ]], Cell[53866, 1462, 293, 5, 59, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[54196, 1472, 60, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[54281, 1477, 297, 5, 59, "Input"], Cell[54581, 1484, 271, 4, 70, "Output"] }, Open ]], Cell[54867, 1491, 214, 4, 43, "Input"], Cell[55084, 1497, 212, 3, 43, "Input"], Cell[55299, 1502, 272, 4, 59, "Input"], Cell[55574, 1508, 338, 6, 75, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[55949, 1519, 80, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[56054, 1524, 328, 5, 72, "Input"], Cell[56385, 1531, 304, 4, 70, "Output"] }, Open ]], Cell[56704, 1538, 378, 6, 75, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[57119, 1549, 70, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[57214, 1554, 269, 6, 87, "Input"], Cell[57486, 1562, 255, 4, 70, "Output"] }, Open ]], Cell[57756, 1569, 388, 7, 91, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[58181, 1581, 39, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[58245, 1585, 190, 4, 42, "Input"], Cell[58438, 1591, 173, 3, 70, "Output"] }, Open ]], Cell[58626, 1597, 371, 6, 75, "Input"], Cell[59000, 1605, 433, 8, 75, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[59470, 1618, 145, 4, 30, "Subsection"], Cell[CellGroupData[{ Cell[59640, 1626, 132, 2, 27, "Input"], Cell[59775, 1630, 88, 1, 26, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[59900, 1636, 205, 4, 57, "Input"], Cell[60108, 1642, 181, 3, 41, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[60326, 1650, 162, 3, 43, "Input"], Cell[60491, 1655, 124, 2, 26, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[60652, 1662, 151, 3, 43, "Input"], Cell[60806, 1667, 119, 2, 26, "Output"] }, Open ]], Cell[60940, 1672, 650, 12, 139, "Input"], Cell[61593, 1686, 200, 3, 59, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[61830, 1694, 48, 0, 46, "Subsection"], Cell[61881, 1696, 280, 5, 46, "Text"], Cell[CellGroupData[{ Cell[62186, 1705, 406, 7, 87, "Input"], Cell[62595, 1714, 390, 5, 70, "Output"] }, Open ]], Cell[63000, 1722, 380, 8, 75, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[63417, 1735, 98, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[63540, 1740, 274, 5, 72, "Input"], Cell[63817, 1747, 244, 4, 70, "Output"] }, Open ]], Cell[64076, 1754, 434, 7, 102, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[64547, 1766, 63, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[64635, 1771, 202, 4, 59, "Input"], Cell[64840, 1777, 173, 2, 70, "Output"] }, Open ]], Cell[65028, 1782, 323, 6, 91, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[65388, 1793, 50, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[65463, 1797, 297, 6, 87, "Input"], Cell[65763, 1805, 284, 4, 70, "Output"] }, Open ]], Cell[66062, 1812, 358, 8, 102, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[66457, 1825, 46, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[66528, 1829, 379, 7, 87, "Input"], Cell[66910, 1838, 367, 5, 70, "Output"] }, Open ]], Cell[67292, 1846, 463, 9, 132, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[67792, 1860, 96, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[67913, 1865, 225, 4, 59, "Input"], Cell[68141, 1871, 179, 3, 70, "Output"] }, Open ]], Cell[68335, 1877, 116, 3, 30, "Text"], Cell[68454, 1882, 434, 8, 75, "Input"], Cell[68891, 1892, 148, 4, 30, "Text"], Cell[69042, 1898, 335, 6, 91, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[69414, 1909, 62, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[69501, 1914, 190, 4, 57, "Input"], Cell[69694, 1920, 178, 3, 70, "Output"] }, Open ]], Cell[69887, 1926, 189, 4, 59, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[70113, 1935, 82, 1, 30, "Subsection"], Cell[70198, 1938, 56, 1, 27, "Input"], Cell[CellGroupData[{ Cell[70279, 1943, 368, 6, 87, "Input"], Cell[70650, 1951, 351, 5, 70, "Output"] }, Open ]], Cell[71016, 1959, 874, 16, 162, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[71927, 1980, 142, 4, 30, "Subsection"], Cell[CellGroupData[{ Cell[72094, 1988, 542, 7, 102, "Input"], Cell[72639, 1997, 518, 7, 86, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[73194, 2009, 181, 3, 43, "Input"], Cell[73378, 2014, 140, 2, 26, "Output"] }, Open ]], Cell[73533, 2019, 6694, 131, 491, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[80264, 2155, 23, 0, 50, "Section"], Cell[80290, 2157, 71, 0, 30, "Text"], Cell[CellGroupData[{ Cell[80386, 2161, 62, 1, 46, "Subsection"], Cell[CellGroupData[{ Cell[80473, 2166, 308, 6, 72, "Input"], Cell[80784, 2174, 296, 4, 70, "Output"] }, Open ]], Cell[81095, 2181, 110, 2, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[81242, 2188, 66, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[81333, 2193, 268, 4, 75, "Input"], Cell[81604, 2199, 236, 3, 70, "Output"] }, Open ]], Cell[81855, 2205, 92, 1, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[81984, 2211, 62, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[82071, 2216, 352, 6, 87, "Input"], Cell[82426, 2224, 345, 5, 70, "Output"] }, Open ]], Cell[82786, 2232, 214, 4, 59, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[83037, 2241, 61, 1, 30, "Subsection"], Cell[CellGroupData[{ Cell[83123, 2246, 175, 4, 42, "Input"], Cell[83301, 2252, 167, 2, 41, "Output"] }, Open ]], Cell[83483, 2257, 125, 2, 27, "Input"], Cell[83611, 2261, 125, 2, 27, "Input"], Cell[83739, 2265, 93, 1, 30, "Text"], Cell[83835, 2268, 93, 1, 30, "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[83977, 2275, 32, 0, 50, "Section"], Cell[CellGroupData[{ Cell[84034, 2279, 62, 1, 46, "Subsection"], Cell[CellGroupData[{ Cell[84121, 2284, 513, 10, 117, "Input"], Cell[84637, 2296, 508, 7, 86, "Output"] }, Open ]], Cell[85160, 2306, 141, 2, 43, "Input"], Cell[85304, 2310, 137, 2, 43, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[85478, 2317, 61, 1, 46, "Subsection"], Cell[CellGroupData[{ Cell[85564, 2322, 188, 4, 57, "Input"], Cell[85755, 2328, 183, 3, 70, "Output"] }, Open ]], Cell[85953, 2334, 341, 7, 43, "Input"], Cell[86297, 2343, 228, 5, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[86562, 2353, 37, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[86624, 2357, 332, 7, 87, "Input"], Cell[86959, 2366, 323, 5, 70, "Output"] }, Open ]], Cell[87297, 2374, 736, 11, 252, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[88070, 2390, 40, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[88135, 2394, 354, 6, 72, "Input"], Cell[88492, 2402, 335, 5, 70, "Output"] }, Open ]], Cell[88842, 2410, 4419, 82, 331, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[93298, 2497, 26, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[93349, 2501, 167, 4, 42, "Input"], Cell[93519, 2507, 159, 2, 70, "Output"] }, Open ]], Cell[93693, 2512, 159, 3, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[93889, 2520, 29, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[93943, 2524, 376, 9, 123, "Input"], Cell[94322, 2535, 353, 5, 70, "Output"] }, Open ]], Cell[94690, 2543, 638, 14, 162, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[95365, 2562, 28, 0, 30, "Subsection"], Cell[CellGroupData[{ Cell[95418, 2566, 253, 5, 57, "Input"], Cell[95674, 2573, 244, 3, 70, "Output"] }, Open ]], Cell[95933, 2579, 697, 13, 107, "Input"] }, Closed]] }, Open ]] }, Open ]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)