Kinsa / sampen

Partial Python port of PhysioNet SampEn C code
http://www.physionet.org/physiotools/sampen
GNU General Public License v2.0
10 stars 8 forks source link

Float division by zero #2

Open daroodar opened 6 years ago

daroodar commented 6 years ago

NOTE: This is using python

When I give a sample array in python as

from sampen import sampen2
a=[2.3,5.5,7.9,3.2,9.2,2.3,8.8,6.6,4.4,3.8,9.3,2.8,10.3,11.3,4.75]
sampen2(a)

It gives this error:

File "/usr/local/lib/python2.7/dist-packages/sampen/sampen2.py", line 140, in sampen2 v2[m] = p[m] * (1.0 - p[m]) / b[m]

ZeroDivisionError: float division by zero

I am using Python 2.7 What seems to be the issue?

srisadhan commented 5 years ago

To my knowledge, you have to normalize the data before using sampen2 on the time-series data [1, 2].

from sampen import sampen2, normalize_data a=[2.3,5.5,7.9,3.2,9.2,2.3,8.8,6.6,4.4,3.8,9.3,2.8,10.3,11.3,4.75] sampen2(normalize_data(a))

[1] Richman, Joshua S., and J. Randall Moorman. "Physiological time-series analysis using approximate entropy and sample entropy." American Journal of Physiology-Heart and Circulatory Physiology 278.6 (2000): H2039-H2049. [2] Costa, Madalena, Ary L. Goldberger, and C-K. Peng. "Multiscale entropy analysis of biological signals." Physical review E 71.2 (2005): 021906.