Comments (2)
I'm having the same issue. To provide more detail:
Running this:
from pyentrp import entropy as ent
import numpy as np
x = np.random.rand(3000)
ts = [1, 4, 5, 1, 7, 3, 1, 2, 5, 8, 9, 7, 3, 7, 9, 5, 4, 3]
for values in [ts, x]:
std_ts = np.std(values)
sample_entropy = ent.sample_entropy(values, 5, 0.2 * std_ts)
multiscale_entropy = ent.multiscale_entropy(values, sample_length=5)
permutation_entropy = ent.permutation_entropy(values, order=5, normalize=True)
print(sample_entropy)
print(multiscale_entropy)
print(permutation_entropy)
Produces this output:
/usr/local/anaconda3/envs/plutus/lib/python3.7/site-packages/pyentrp/entropy.py:163: RuntimeWarning: invalid value encountered in true_divide
sampen = - np.log(Ntemp[1:] / Ntemp[:-1])
/usr/local/anaconda3/envs/plutus/lib/python3.7/site-packages/pyentrp/entropy.py:163: RuntimeWarning: divide by zero encountered in log
sampen = - np.log(Ntemp[1:] / Ntemp[:-1])
[2.95099638 2.07944154 inf nan nan]
[nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan]
0.5512400796500767
[2.18821295 2.18706536 2.1974189 2.19977194 2.11596861]
[3.11351531 2.07944154 2.7080502 ... nan nan nan]
0.9960386507116764
It appears to be specific to sample lengths greater than 2. No warnings, inf
, or nan
are produced when the sample length is 2 or 1, but the problem arrises when the sample length is 3 or greater.
Multiscale is built on top of sample, so naturally it suffers the same issue. Permutation entropy appears to be fine.
Is it possibly a function of the length of the input series? The sample_entropy sample_length=5
does not produce any warnings, nan
s, or inf
s on the longer sequence of 3000 random values, although multiscale still produces nans even on the 3000-length input.
pyentrp 0.6. numpy 1.19.4.
from pyentropy.
This error is related to division by 0. Most probably it is because of the input: at some scale this operation appears and that's why there are nans/inf in the result
from pyentropy.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyentropy.