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.