Group Abstract Group Abstract

Message Boards Message Boards

How to implement this Sample Entropy Algorithm?

POSTED BY: Mariusz Iwaniuk
2 Replies

I found code on this site https://mathematica.stackexchange.com.Works for MMA 11.2.

 data = Table[Sin[i], {i, 1, 100, .2}];

 ClearAll[sampleEnt2]
 sampleEnt2[data_, ws_, t_] :=  Module[{nF1, nF2, diff1, diff2, va1, va2},
  va1 = Partition[data, ws, 1];
  va2 = Partition[data, 1 + ws, 1];
  nF1 = Nearest[va1 -> Automatic, DistanceFunction -> ChessboardDistance];
  nF2 = Nearest[va2 -> Automatic, DistanceFunction -> ChessboardDistance];
  diff1 = Total[(Length /@ nF1[va1, {All, t}])] - Length[va1];
  diff2 = Total[(Length /@ nF2[va2, {All, t}])] - Length[va2];
  -Log[N@(diff2/diff1)]
  ]


   m = 2;
   r = 0.2*StandardDeviation[data];
   sampleEnt2[data, m, r] // AbsoluteTiming
   (* {0.00581366, 0.230651} *)
POSTED BY: Mariusz Iwaniuk

Did you figure out what went wrong in the code? Or was it an error in the document?

POSTED BY: Sam Carrettie
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard