0

I'm following a tutorial paper on sample entropy, and I implemented the algorithm myself in Rust.
To check my work, I used Wikipedia's python code in this article. I have computed an example by hand that doesn't give the same result with this code.

My hand done example:
Data : [1.0, 2.0, 3.0, 4.0, 5.0], r = 1.5, m=2.
Templates of size 2: [[1.0, 2.0], [2.0, 3.0], [3.0, 4.0], [4.0, 5.0]].
Matches: 6.
Templates of size 3: [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0], [3.0, 4.0, 5.0]].
Matches: 4.
-ln(4/6) $\approx$ 0.405

the python code in the article gets the answer 0.223

I think that it is more likely that I have made some kind of error, but I have searched over the algorithm several times and I cannot find an error in my computations. The python code has such poor variable names that I cannot discern what is going on apart from the fact that they get 5 matches for the window size 2 and 4 matches for window size 3, leading to a slightly different result.

  • 1
    It looks like buggy, inefficient code in the article to me. Its approach to "self matches" looks particularly suspect. But don't you have the match counts reversed? I see 4 matches in the width-2 templates and 6 matches in the width-3 templates. BTW, this looks like a one-dimensional version of the analysis I proposed at https://stats.stackexchange.com/a/17556/919 in a spatial context. – whuber Jun 07 '23 at 21:15

0 Answers0