antropy icon indicating copy to clipboard operation
antropy copied to clipboard

sample_entropy some time is inf ?

Open allran opened this issue 1 year ago • 2 comments

This demo, will get inf value

 sss = np.array([5.9, 6.03, 5.97, 5.92, 5.93, 5.87, 5.89, 5.95, 6.06, 6.1, 6.06, 5.81, 5.78, 5.98, 5.89, 5.95, 6.02])
 calc_value = ant.sample_entropy(sss)
 print(calc_value) 

I read the source code, it because numerator == 0

allran avatar Aug 23 '24 07:08 allran

I encountered the same problem.

hasibagen avatar Oct 18 '24 06:10 hasibagen

Thanks for opening the issue. I think it's because your timeseries does not have enough samples to reliably calculate the sample entropy. That said, I would recommend trying with the implementation of sample entropy in the neurokit2 package: https://github.com/neuropsychology/NeuroKit/blob/c1104386655724a5c624e740abf651c939fc5e48/neurokit2/complexity/entropy_sample.py#L6

raphaelvallat avatar Oct 19 '24 10:10 raphaelvallat