Approximate Entropy Function¶
The approximate entropy function computes the approximate entropy of a window. When combined with the SlidingWindow
abstraction, the approximate entropy function can be used to compute the approximate entropy
feature of a time series. It is used to quantify the amount of regularity and the unpredictability signals. Approximate entropy measures the likelihood that similar patterns of observations will not be followed by these similar patterns, therefore a time-series signal that exhibits seasonality or other kinds of repetitive patterns will have a relatively small approximate entropy whereas signals without such a repetitive nature will exhibit a high value of approximate entropy [1]. It is defined as:
where \(m\) is the embedding dimension, \(r\) is the tolerance, \(N\) is the length of the signal, \(x_i\) is the \(i^{th}\) sample of the signal, and \(\Theta\) is the Heaviside step function.
Compute the approximate entropy of the values in x
where where
is True
. It used to quantify the amount of regularity and the unpredictability of fluctuations in the signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | ndarray | The signal to find the approximate entropy of. | required |
m | Union[int, int_] | The length of the template vector. | required |
r | Union[int, int_] | The tolerance. | required |
where | Callable[[Union[int, float, int_, float_]], Union[bool, bool_]] | A function that takes a value and returns | lambda : not numpy.isnan(x) |
Returns:
Type | Description |
---|---|
Union[float, float_] | The approximate entropy of the values in |
References
Approximate Entropy - https://en.wikipedia.org/wiki/Approximate_entropy
Examples¶
import numpy as np
import autonfeat as aft
import autonfeat.functional as F
# Random data
n_samples = 100
x = np.random.rand(n_samples)
# Create sliding window
ws = 10
ss = 10
window = aft.SlidingWindow(window_size=ws, step_size=ss)
# Get featurizer
featurizer = window.use(F.approx_entropy_tf)
# Get features
features = featurizer(x, m=2, r=0.2)
# Print features
print(features)
References¶
[1] https://en.wikipedia.org/wiki/Approximate_entropy
If you enjoy using AutonFeat
, please consider starring the repository ⭐️.