I'm running permutation_entropy(my_array, m = 3, delay = 1)
on the following array and am getting a value of -0.0
for my output.
array([ 8.6354885, 7.847 , 9.786279 , 10.811804 , 11.368661 ,
10.298161 , 9.584094 , 10.228781 , 10.675296 , 10.790827 ,
10.666389 , 10.177469 , 10.89863 , 11.041763 , 8.989045 ,
11.213311 , 10.382978 , 8.943591 , 9.770281 , 10.339998 ,
9.418209 , 9.841557 , 10.484714 , 9.990864 , 10.560351 ,
10.241841 , 10.830489 , 10.062455 , 9.75937 , 9.950198 ,
10.7275305, 9.284445 , 9.037022 , 7.691061 , 10.351711 ,
8.412907 , 10.735292 , 5.889793 , 9.477356 , 4.858265 ,
9.646169 , 8.169383 , 10.117668 , 10.4823475, 7.4111977,
10.287312 , 7.277527 , 10.397271 , 7.3295283, 10.846437 ,
6.8738704, 9.159628 , 6.409748 , 8.958366 , 6.473379 ,
10.166828 , 8.030985 , 10.2656975, 9.349428 , 9.349428 ,
5.9747562, 9.571418 , 6.412549 , 10.038413 , 7.3413515,
9.748129 , 7.903518 , 10.491926 , 8.761297 , 9.51908 ,
7.7680426, 10.160261 , 6.89564 , 10.132029 , 7.983659 ,
9.381678 , 8.631905 , 10.81286 , 8.44598 , 10.472592 ,
7.6191735, 10.0790825, 7.5667286, 9.558374 , 7.1744604,
9.184171 , 8.056332 , 8.731763 , 8.138747 , 9.808532 ,
7.086683 , 9.662312 , 6.749556 , 10.758138 , 10.854101 ,
7.7829103, 11.219701 , 8.178098 ], dtype=float32)
Visually speaking. The array looks like this:
Differences in sampling rate aside, I'm inclined to believe that the hashing might not be working correctly.
The permutation distro is:
[95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
I understand permutation entropy as the following:
A
<B
<C
<D
is a distinct permutation, as is B
<A
<C
<D
for m = 3
- a total of
(m+1)!
permutations are possible. This is also the size/range of my distribution.
- Using a window size of
m+1
, I move a window across the time series with a stride of delay = 1
. The permutation bin that matches the pattern within that window is incremented by one.
- After having traversed the entire time series a permutation distribution is left over.
- something like shannon entropy is computed for the permutation distribution.
plogp
With that said the permutation distro:
[95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
is contradicted by the first 5 terms:
8.6354885, 7.847 , 9.786279 , 10.811804 , 11.368661
B A C D
for first 4
A B C D
for second 4
I'm looking for help in either debugging my understanding of permutation entropy, or debugging the code producing unexpected results. Thanks in advance! I'm glad someone has written open source code for this. If you get the index/hashing approach that might be loads faster than how I would have resolved it.