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 s the time series is coarse-grained by averaging over non-overlapping windows of s samples (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]. All s possible 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 scale s is the refined composite multiscale entropy (RCMSE) of Wu et al. [3] (their Eq. (8)): the template matches of length m and m + 1 are counted for each of the s coarse-grained series (as in sample_entropy(), with the same tolerance r at every scale), and the value is -log of the summed matches of length m + 1 over the summed matches of length m. Pooling the counts before the log keeps the value defined when some offsets have no matches of length m + 1. For the dispersion settings the value at scale s is 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 y is 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() with tau = 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' replace SampEn by DispEn/FDispEn and sampen by dispen/fdispen):

  • ’sampen_s{k}’: the entropy at each scale k in scale_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