pyhctsa.operations.entropy.multi_scale_entropy¶
-
pyhctsa.operations.entropy.multi_scale_entropy(y, scale_range=
None, m=2, r=0.15, pre_process_how=None, what_entropy='sampen', num_classes=6)¶ Multiscale entropy (MSE) of a time series.
At each scale
sthe time series is coarse-grained by averaging over non-overlapping windows ofssamples (scale 1 is the original series), and the entropy of the coarse-grained series is computed: by default the sample entropy, SampEn(m, r) (sample_entropy()), as in the multiscale entropy of Costa et al. [1]. Allspossible starting offsets of the windows are used, instead of just offset 0 (single-offset estimates can swing several-fold depending on the arbitrary start). The sample entropy at scalesis the refined composite multiscale entropy (RCMSE) of Wu et al. [3] (their Eq. (8)): the template matches of lengthmandm + 1are counted for each of thescoarse-grained series (as insample_entropy(), with the same tolerancerat every scale), and the value is-logof the summed matches of lengthm + 1over the summed matches of lengthm. Pooling the counts before the log keeps the value defined when some offsets have no matches of lengthm + 1. For the dispersion settings the value at scalesis the mean over the offsets (composite MSE [2]). Offsets for which the coarse-grained series has fewer than 20 samples are skipped, and a scale with no remaining offsets, or with no matches, is NaN. The entropy is also summarized across scales (extremes and where they occur, mean, spread, trend); these summaries are NaN if the entropy at any scale is NaN.References
- Parameters:¶
- y : array-like¶
Input time series.
- scale_range : list or range, optional¶
Scales (window sizes) for coarse-graining. Default is
range(1, 11).- m : int, optional¶
Embedding dimension (length of the sequences to match). Default is 2.
- r : float, optional¶
Similarity threshold for sample entropy, an absolute value (it is not rescaled with the scale). It is a fraction of the standard deviation of the input if
yis z-scored. Unused for the dispersion settings. Default is 0.15.- pre_process_how : str, optional¶
Pre-processing applied (and the result z-scored) before coarse-graining:
’diff1’: incremental differences;
’rescale_tau’: first coarse-grain at the first zero-crossing of the autocorrelation function;
None: none.
Default is None.
- what_entropy : {'sampen', 'dispen', 'fdispen'}, optional¶
The entropy evaluated at each scale: sample entropy (
'sampen', the classical multiscale entropy), normalized dispersion entropy ('dispen', i.e. multiscale dispersion entropy [4];dispersion_entropy()withtau = 1) or its fluctuation-based variant ('fdispen'). Output names carry the corresponding suffix (dispen_s1,meanDispEn, …). Default is'sampen'.- num_classes : int, optional¶
The number of amplitude classes for the dispersion settings. Default is 6.
- Returns:¶
A dictionary with (names for
what_entropy = 'sampen';'dispen'/'fdispen'replaceSampEnbyDispEn/FDispEnandsampenbydispen/fdispen):’sampen_s{k}’: the entropy at each scale
kinscale_range;’maxSampEn’, ‘minSampEn’: the maximum and minimum across scales, with ‘maxScale’ and ‘minScale’ the scales at which they occur;
’meanSampEn’, ‘stdSampEn’, ‘cvSampEn’: the mean, standard deviation and coefficient of variation across scales;
’meanch’: the mean change from one scale to the next;
’slope’, ‘slopeSE’: the slope, and its standard error, of a robust (Tukey bisquare iteratively reweighted least squares) linear fit of the entropy against scale; NaN for fewer than 3 scales.
The summaries (all but ‘sampen_s{k}’) are NaN if the entropy at any scale is NaN.
NaN (scalar) if no scale has enough samples.
- Return type:¶
dict or float