Re: Sample Entropy
Pamphile Roy <[email protected]>
| Newsgroups | gmane.comp.python.scientific.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Sebastian, This looks interesting. I am not sure where that could/would fit in our API though. Did you have a look at https://raphaelvallat.com/antropy (from Raphaël the author of Pingouin)? It seems fast (uses Numba) and with quite some features. Cheers, Pamphile On 17 Jan 2023, at 12:48, Sebastian Wallkötter <[email protected]> wrote: Hello SciPy, I implemented an algorithm to compute sample entropy (a time-series statistic) [0,1] and wonder if this is a useful addition to SciPy. In a nutshell, sample entropy quantifies the amount of regularity of a series; for example, the sequence "0101010101..." has (relatively) low sample entropy whereas "011100101100..." has (relatively) high sample entropy. It is a modification of approximate entropy with less bias. Sample Entropy and approximate entropy are useful whenever we want to measure the amount of "turbulence" in a series, e.g. when quantifying the irregularity of a heart rate signal or hormone levels [2], or the turmoil of a stock's value [3]. There is also a two-variable version called cross (sample/approximate) entropy which measures the association between two non-stationary time series. While conceptually simple a naive implementation of sample entropy doesn't scale well for large input sequences, as it operates on all pairs of fixed-length windows into the sequence. Hence why I think it is useful to have an optimized implementation available. The poor performance can be seen in the attached benchmark (blue line). Clever tricks on reusing intermediate results make this a little better (orange line), but only make sense if we avoid numpy, because they require frequent access to single elements which is expensive when done from python. Doing the same via a C extension (green line), however, makes the metric much more viable on larger sequences. If this sounds interesting, I will create an enhancement issue for this and we can discuss the details there. If not, then I would be grateful if somebody could point me to another OSS repo that might find this useful. Best, Sebastian [0] https://en.wikipedia.org/wiki/Sample_entropy [1] https://journals.physiology.org/doi/epdf/10.1152/ajpheart.2000.278.6.H2039 [2] https://pubmed.ncbi.nlm.nih.gov/11797860/ [3] Olbryś, Joanna, and Elżbieta Majewska. "Regularity in stock market indices within turbulence periods: The sample entropy approach." Entropy 24.7 (2022): 921. _______________________________________________ SciPy-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/scipy-dev.python.org/ Member address: [email protected] _______________________________________________ SciPy-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/scipy-dev.python.org/ Member address: [email protected]
result.png
(image/png, 33.6 KB) - not displayed