Comments (2)
You mean using np.diff(np.signbit(x), n=2).sum()
instead of np.diff(np.signbit(x)).sum()
, correct?
Taking a sine wave example, I think that the current method implemented in AntroPy is correct:
import numpy as np
import matplotlib.pyplot as plt
sf, f, dur = 100, 1, 4
N = sf * dur # Total number of discrete samples
t = np.arange(N) / sf # Time vector
x = np.sin(2 * np.pi * f * t)
plt.plot(t, x)
plt.xlim(t[0], t[-1])
plt.axhline(0);
There are 7 zero-crossings in x
.
>>> def nzc(x, n):
>>> return np.diff(np.signbit(x), n=n).sum()
>>> nzc(x, n=1), nzc(x, n=2)
(7, 14)
The n=1
method (default) gives the correct answer. The double differentiation leads to twice the expected number of zero-crossings.
Thanks,
Raphael
from antropy.
Ah sorry yes I must have been asleep and missed one step ^^ (I was looking at here but I didn't see the that the diff
was inside here) thanks!
from antropy.
Related Issues (17)
- RuntimeWarning in _xlogx when x has zero values HOT 4
- Different results of different SampEn implementations HOT 4
- modify the entropy function be able to compute vectorizly HOT 2
- conda-forge package HOT 3
- Allow users to pass signal in frequency domain in spectral entropy
- speedup _numba_sampen kernel HOT 9
- Errors in sample_entropy and higuchi_fd on a small vector HOT 3
- Multiscale Entropy (MSE) HOT 2
- sample_entropy not matching data types HOT 2
- Fix KDTree all_metrics HOT 2
- numba jit needs explicit nopython=True HOT 3
- Variable implementation of r e.g. SampEn or AppEn HOT 1
- how to explain the detrended_fluctuation result HOT 3
- The most "generic" entropy measure HOT 3
- Speed up importing antropy HOT 4
- Error importing with 32-bit windows 7 HOT 2
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 antropy.