1
$\begingroup$

I am trying to use this code for estimating L.e.:

 Lya[data_, τ_, mMax_, ϵ_, δMax_] :=
  Table[Module[{emb, nn, nf, neigh},
emb = 
 Table[Take[data, {i, i + τ (m - 1), τ}], {i, 
   Length[data] - τ (m - 1)}];
nn = Length[emb];
nf = Nearest[emb -> Range[nn]];
neigh = 
    Table[DeleteCases[Rest[nf[emb[[t]], {∞, ϵ}]], 
   p_ /; p > nn - δMax], {t, nn - δMax}];
SMT1 = Table[{δ, SMT2 = Mean[ SMT3 = DeleteCases[
       SMT4 = Table[If[Length[neigh[[t]]] == 0, "d",

          Log[Mean[
            Abs[data[[t + (m - 1) τ + δ]] - 
              data[[neigh[[t]] + (m - 1) τ + δ]]]]]],
         {t, nn - δMax}], "d" | Indeterminate]]},
  {δ, 0, δMax}]], {m, mMax}];

The problem is, it works fine for chaotic or random series e.i.:

      A = RandomReal[1, 1000];
      Lya[A, 1, 1, 0.001, 20] ; // AbsoluteTiming
      {0.241372, Null}

But giving indeterminate results and very slow for constant or regular series e.i.:

      B = Table[3, 1000]; 
     Lya[B, 1, 1, 0.001, 20, 1]; //  AbsoluteTiming 
     {3.10512, Null}

Can please someone explain me, where is the problem, or the difference when calcualting A and B, what is it slowing down so much (I susspect nearest funct.) ? What could it speed up, by B ? If someone have good code calculating Lyapunov exp. from a time series please post it here.

$\endgroup$

Browse other questions tagged or ask your own question.