Compute entropy for time series with pyEntropy
masterImport the entropy module from pyentrp to access various entropy computation functions. The library is built on NumPy and is designed for time series analysis.
Supported entropy types include:
shannon_entropysample_entropymultiscale_entropycomposite_multiscale_entropypermutation_entropymultiscale_permutation_entropyweighted_permutation_entropy
from pyentrp import entropy as ent
import numpy as np
ts = [1, 4, 5, 1, 7, 3, 1, 2, 5, 8, 9, 7, 3, 7, 9, 5, 4, 3]
std_ts = np.std(ts)
# Example: computing sample entropy with an embedding dimension of 4 and a tolerance of 0.2 * std
sample_entropy = ent.sample_entropy(ts, 4, 0.2 * std_ts)