pyhctsa.operations.entropy.fuzzy_entropy¶
-
pyhctsa.operations.entropy.fuzzy_entropy(y, M=
2, r=0.2, n=2)¶ Fuzzy entropy of a time series.
Chen et al.’s fuzzy entropy [1, 2], a smooth relative of sample entropy (
sample_entropy()). The series is cut into overlapping runs ofmconsecutive values, and the mean of each run is subtracted from it, so runs are compared by shape and not by level. Two runs are not simply ‘matching’ or ‘not matching’, as in sample entropy: they are given a similarityexp(-(d/r)**n), wheredis the largest absolute difference between corresponding values of the two (baseline-removed) runs.phi_mis the mean similarity over all pairs of distinct runs of lengthm, and the fuzzy entropy at dimensionmislog(phi_m) - log(phi_(m+1)). Low values indicate regular, predictable series; high values irregular ones. The smooth similarity makes the measure continuous inrand defined for short series for which sample entropy would find no matches.All runs of length 1, …, M+1 are taken from the same
N - Mstarting points, so that successive dimensions are compared on the same footing. The distances are computed pair by pair, so memory use does not grow with the square of the series length (the run time does: it is O(N^2 M)). Port of hctsa’sEN_FuzzyEn.The similarity is written here as
exp(-(d/r)**n), so thatris a distance (in units of the standard deviation ofy). Chen et al. (2007) write it asexp(-d**n/r), in whichris not a distance: forn = 2, theirr = 0.2on standardized data is a Gaussian width ofsqrt(0.2) = 0.45standard deviations, against 0.2 here. Values ofrare therefore not directly comparable with those quoted in that paper. To get the fuzzy entropy of the increments of a series, givenp.diff(y)as the input.References
- Parameters:¶
- y : array-like¶
The input time series.
- M : int, optional¶
The largest embedding dimension: the fuzzy entropy is returned for
m = 1, ..., M. Default is 2.- r : float, optional¶
The width of the similarity function, as a fraction of the standard deviation of
y(the width in the units ofyisr * std(y), so the measure is unchanged by any rescaling ofy). Default is 0.2.- n : float, optional¶
The exponent of the similarity function
exp(-(d/r)**n)(larger values make the similarity closer to a hard threshold). Default is 2.
- Returns:¶
Fields ‘fuzzyEn1’, ‘fuzzyEn2’, …, ‘fuzzyEnM’: the fuzzy entropy at each embedding dimension (nats). At
m = 1the run mean removed is the value itself, sophi_1 = 1and ‘fuzzyEn1’ is-log(phi_2). All fields are NaN if the series is constant, has fewer thanM + 3points, or has no pair of runs with a nonzero similarity.- Return type:¶
dict