# Multiscale Entropies

## Functions for estimating the multiscale entropy of a univariate time series.

Multiscale entropy can be calculated using any of the Base Entropies: `ApEn`, `AttnEn`, `BubbEn`, `CondEn`, `CoSiEn`, `DistEn`, `DispEn`, `DivEn`, `EnofEn`, `FuzzEn`, `GridEn`, `IncrEn`, `K2En`, `PermEn`, `PhasEn`, `RangEn`, `SampEn`, `SlopEn`, `SpecEn`, `SyDyEn`.

Important

Multiscale cross-entropy functions have two positional arguments:

1. the data sequence, `Sig` (a vector > 10 elements),

2. the multiscale entropy object, `Mobj`.

MSobject(EnType='SampEn', **kwargs)

MSobject creates an object to store multiscale entropy parameters.

```[Mobj] = MSobject()
```

Returns a multiscale entropy object (`Mobj`) based on that originally proposed by Costa et al. using the following default parameters: EnType = ‘SampEn’, embedding dimension = 2, time delay = 1, radius = 0.2*SD(`Sig`), logarithm = natural

```[Mobj] = MSobject(EnType)
```

Returns a multiscale entropy object using the specified entropy method (`EnType`) and the default parameters for that entropy method. To see the default parameters for a particular entropy method, type: help(EnType) (e.g. `help(SampEn)`)

```[Mobj] = MSobject(EnType, keyword = value, ...)
```

Returns a multiscale entropy object using the specified entropy method (`EnType`) and the name/value parameters for that particular method. To see the default parameters for a particular entropy method, type: help(EnType) (e.g. `help(SampEn)`)

`EnType` can be any of the following (case sensitive) string names:

Base Entropies:
`'ApEn'`:
• Approximate Entropy

`'SampEn'`:
• Sample Entropy

`'FuzzEn'`:
• Fuzzy Entropy

`'K2En'`:
• Kolmogorov Entropy

`'PermEn'`:
• Permutation Entropy

`'CondEn'`:
• Conditional Entropy

`'DistEn'`:
• Distribution Entropy

`'DispEn'`:
• Dispersion Entropy

`'SpecEn'`:
• Spectral Entropy

`'SyDyEn'`:
• Symbolic Dynamic Entropy

`'IncrEn'`:
• Increment Entropy

`'CoSiEn'`:
• Cosine Similarity Entropy

`'PhasEn'`:
• Phase Entropy

`'SlopEn'`:
• Slope Entropy

`'BubbEn'`:
• Bubble Entropy

`'GridEn'`:
• Grid Distribution Entropy

`'EnofEn'`:
• Entropy of Entropy

`'AttnEn'`:
• Attention Entropy

`'DivEn'`:
• Diversity Entropy

`'RangEn'`:
• Range Entropy

Cross Entropies:
`'XApEn'`:
• Cross-Approximate Entropy

`'XSampEn'`:
• Cross-Sample Entropy

`'XFuzzEn'`:
• Cross-Fuzzy Entropy

`'XK2En'`:
• Cross-Kolmogorov Entropy

`'XPermEn'`:
• Cross-Permutation Entropy

`'XCondEn'`:
• Cross-Conditional Entropy (corrected)

`'XDistEn'`:
• Cross-Distribution Entropy

`'XSpecEn'`:
• Cross-Spectral Entropy

Multivariate Entropies:
`'MvSampEn'`:
• Multivariate Sample Entropy

`'MvFuzzEn'`:
• Multivariate Fuzzy Entropy

`'MvDispEn'`:
• Multivariate Dispersion Entropy

`'MvCoSiEn'`:
• Multivariate Cosine Similarity Entropy

`'MvPermEn'`:
• Multivariate Permutation Entropy

`MSEn`, `MvMSEn`, `cMSEn`, `cMvMSEn`, `rMSEn`, `hMSEn`, `XMSEn`, `rXMSEn`, `cXMSEn`, `hXMSEn`

The following functions use the multiscale entropy object shown above.

MSEn(Sig, Mbjx, Scales=3, Methodx='coarse', RadNew=0, Plotx=False)

MSEn Returns the multiscale entropy of a univariate data sequence.

```MSx,CI = MSEn(Sig, Mobj)
```

Returns a vector of multiscale entropy values (`MSx`) and the complexity index (`CI`) of the data sequence `Sig` using the parameters specified by the multiscale object (`Mobj`) over 3 temporal scales with coarse- graining (default).

```MSx,CI = MSEn(Sig, Mobj, keyword = value, ...)
```

Returns a vector of multiscale entropy values (`MSx`) and the complexity index (`CI`) of the data sequence `Sig` using the parameters specified by the multiscale object (`Mobj`) and the following `keyword` arguments:

Scales:
• Number of temporal scales, an integer > 1 (default: 3)

Methodx:
• Graining method, one of the following: [default: `'coarse'`] {`'coarse'`, `'modified'`, `'imf'` , `'timeshift'` , `'generalized'`}

• Radius rescaling method, an integer in the range [1 4].

When the entropy specified by `Mobj` is `SampEn` or `ApEn`, RadNew rescales the radius threshold in each sub-sequence at each time scale (Ykj). If a radius value (`r`) is specified by `Mobj`, this becomes the rescaling coefficient, otherwise it is set to 0.2 (default). The value of RadNew specifies one of the following methods:

• [1] Standard Deviation - `r*std(Ykj)`

• [2] Variance - `r*var(Ykj)`

• [3] Mean Absolute Deviation - `r*mad(Ykj)`

• [4] Median Absolute Deviation - `r*mad(Ykj,1)`

Plotx:
• When `Plotx == True`, returns a plot of the entropy value at each time scale (i.e. the multiscale entropy curve) [default: False]

For further info on these graining procedures see the EntropyHub guide.

`MSobject`, `rMSEn`, `cMSEn`, `hMSEn`, `XMSEn`, `cXMSEn`, `hXMSEn`, `SampEn`

References:
[1] Madalena Costa, Ary Goldberger, and C-K. Peng,

“Multiscale entropy analysis of complex physiologic time series.” Physical review letters 89.6 (2002): 068102.

[2] Vadim V. Nikulin, and Tom Brismar,

“Comment on “Multiscale entropy analysis of complex physiologic time series”.” Physical review letters 92.8 (2004): 089803.

[3] Madalena Costa, Ary L. Goldberger, and C-K. Peng.

“Costa, Goldberger, and Peng reply.” Physical Review Letters 92.8 (2004): 089804.

[4] Madalena Costa, Ary L. Goldberger and C-K. Peng,

“Multiscale entropy analysis of biological signals.” Physical review E 71.2 (2005): 021906.

[5] Ranjit A. Thuraisingham and Georg A. Gottwald,

“On multiscale entropy analysis for physiological data.” Physica A: Statistical Mechanics and its Applications 366 (2006): 323-332.

[6] Meng Hu and Hualou Liang,

“Intrinsic mode entropy based on multivariate empirical mode decomposition and its application to neural data analysis.” Cognitive neurodynamics 5.3 (2011): 277-284.

[7] Anne Humeau-Heurtier

“The multiscale entropy algorithm and its variants: A review.” Entropy 17.5 (2015): 3110-3123.

[8] Jianbo Gao, et al.,

“Multiscale entropy analysis of biological signals: a fundamental bi-scaling law.” Frontiers in computational neuroscience 9 (2015): 64.

[9] Paolo Castiglioni, et al.,

“Multiscale Sample Entropy of cardiovascular signals: Does the choice between fixed-or varying-tolerance among scales influence its evaluation and interpretation?.” Entropy 19.11 (2017): 590.

[10] Tuan D Pham,

“Time-shift multiscale entropy analysis of physiological signals.” Entropy 19.6 (2017): 257.

[11] Hamed Azami and Javier Escudero,

“Coarse-graining approaches in univariate multiscale sample and dispersion entropy.” Entropy 20.2 (2018): 138.

[12] Madalena Costa and Ary L. Goldberger,

“Generalized multiscale entropy analysis: Application to quantifying the complex volatility of human heartbeat time series.” Entropy 17.3 (2015): 1197-1203.

cMSEn(Sig, Mbjx, Scales=3, RadNew=0, Refined=False, Plotx=False)

cMSEn Returns the composite (or refined-composite) multiscale entropy of a univariate data sequence.

```MSx, CI = cMSEn(Sig, Mobj)
```

Returns a vector of composite multiscale entropy values (`MSx`) for the data sequence (`Sig`) using the parameters specified by the multiscale object (`Mobj`) using the composite multiscale entropy method (cMSE) over 3 temporal scales.

```MSx, CI = cMSEn(Sig, Mobj, Refined = True)
```

Returns a vector of refined-composite multiscale entropy values (`MSx`) for the data sequence (`Sig`) using the parameters specified by the multiscale object (`Mobj`) using the refined-composite multiscale entropy method (rcMSE) over 3 temporal scales. When `Refined == True`, the base entropy method must be `SampEn` or `FuzzEn`. If the entropy method is `SampEn`, cMSEn employs the method described in [5]. If the entropy method is `FuzzEn`, cMSEn employs the method described in [6].

```MSx, CI = cMSEn(Sig, Mobj, keyword = value, ...)
```

Returns a vector of composite multiscale entropy values (`MSx`) of the data sequence (`Sig`) using the parameters specified by the multiscale object (`Mobj`) and the following ‘keyword’ arguments:

Scales:
• Number of temporal scales, an integer > 1 (default: 3)

• Radius rescaling method, an integer in the range [1 4].

When the entropy specified by `Mobj` is `SampEn` or `ApEn`, RadNew rescales the radius threshold in each sub-sequence at each time scale (Ykj). If a radius value (`r`) is specified by `Mobj`, this becomes the rescaling coefficient, otherwise it is set to 0.2 (default). The value of RadNew specifies one of the following methods:

• [1] Standard Deviation - `r*std(Ykj)`

• [2] Variance - `r*var(Ykj)`

• [3] Mean Absolute Deviation - `r*mad(Ykj)`

• [4] Median Absolute Deviation - `r*mad(Ykj,1)`

Refined:
• Refined-composite MSEn method. When `Refined == True` and the entropy function specified by `Mobj` is `SampEn` or `FuzzEn`,

`cMSEn` returns the refined-composite multiscale entropy (rcMSEn) [default: False]

Plotx:
• When Plotx == True, returns a plot of the entropy value at each time scale (i.e. the multiscale entropy curve) [default: False]

`MSobject`, `MSEn`, `rMSEn`, `hMSEn`, `XMSEn`, `cXMSEn`, `SampEn`, `ApEn`

References:
[1] Madalena Costa, Ary Goldberger, and C-K. Peng,

“Multiscale entropy analysis of complex physiologic time series.” Physical review letters 89.6 (2002): 068102.

[2] Vadim V. Nikulin, and Tom Brismar,

“Comment on “Multiscale entropy analysis of complex physiologic time series”.” Physical review letters 92.8 (2004): 089803.

[3] Madalena Costa, Ary L. Goldberger, and C-K. Peng.

“Costa, Goldberger, and Peng reply.” Physical Review Letters 92.8 (2004): 089804.

[4] Shuen-De Wu, et al.,

“Time series analysis using composite multiscale entropy.” Entropy 15.3 (2013): 1069-1084.

[5] Shuen-De Wu, et al.,

“Analysis of complex time series using refined composite multiscale entropy.” Physics Letters A 378.20 (2014): 1369-1374.

[6] Hamed Azami et al.,

“Refined multiscale fuzzy entropy based on standard deviation for biomedical signal analysis” Med Biol Eng Comput 55 (2017):2037–2052

hMSEn returns the hierarchical entropy of a univariate data sequence.

```MSx, Sn, CI = hMSEn(Sig, Mobj)
```

Returns a vector of entropy values (`MSx`) calculated at each node in the hierarchical tree, the average entropy value across all nodes at each scale (`Sn`), and the complexity index (`CI`) of the hierarchical tree (i.e. `sum(Sn)`) for the data sequence (`Sig`) using the parameters specified by the multiscale object (Mobj) over 3 temporal scales (default). The entropy values in MSx are ordered from the root node (S_00) to the Nth subnode at scale T (S_TN): i.e. S_00, S_10, S_11, S_20, S_21, S_22, S_23, S_30, S_31, S_32, S_33, S_34, S_35, S_36, S_37, S_40, … , S_TN. The average entropy values in Sn are ordered in the same way, with the value of the root node given first: i.e. S0, S1, S2, …, ST

```MSx, Sn, CI = hMSEn(Sig, Mobj, keyword = value, ...)
```

Returns a vector of entropy values (`MSx`) calculated at each node in the hierarchical tree, the average entropy value across all nodes at each scale (`Sn`), and the complexity index (`CI`) of the entire hierarchical tree for the data sequence (Sig) using the following ‘keyword’ arguments:

Scales:
• Number of temporal scales, an integer > 1 (default = 3) At each scale (T), entropy is estimated for 2^(T-1) nodes.

• Radius rescaling method, an integer in the range [1 4].

When the entropy specified by `Mobj` is `SampEn` or `ApEn`, RadNew rescales the radius threshold in each sub-sequence at each time scale (Ykj). If a radius value (`r`) is specified by `Mobj`, this becomes the rescaling coefficient, otherwise it is set to 0.2 (default). The value of RadNew specifies one of the following methods:

• [1] Standard Deviation - `r*std(Ykj)`

• [2] Variance - `r*var(Ykj)`

• [3] Mean Absolute Deviation - `r*mad(Ykj)`

• [4] Median Absolute Deviation - `r*mad(Ykj,1)`

Plotx:
• When `Plotx == True`, returns a plot of the average entropy value at each time scale (i.e. the multiscale entropy curve) and a network graph showing the entropy value of each node in the hierarchical tree decomposition. (default: False)

`MSobject`, `MSEn`, `rMSEn`, `cMSEn`, `XMSEn`, `hXMSEn`, `rXMSEn`, `cXMSEn`

References:
[1] Ying Jiang, C-K. Peng and Yuesheng Xu,

“Hierarchical entropy analysis for biological signals.” Journal of Computational and Applied Mathematics 236.5 (2011): 728-742.

rMSEn(Sig, Mbjx, Scales=3, F_Order=6, F_Num=0.5, RadNew=0, Plotx=False)

rMSEn returns the refined multiscale entropy of a univariate data sequence.

```MSx, CI = rMSEn(Sig, Mobj)
```

Returns a vector of refined multiscale entropy values (`MSx`) and the complexity index (`CI`) of the data sequence (`Sig`) using the parameters specified by the multiscale object (`Mobj`) and the following default parameters: Scales = 3, Butterworth LPF Order = 6, Butterworth LPF cutoff frequency at scale (T): Fc = 0.5/T. If the entropy function specified by `Mobj` is `SampEn` or `ApEn`, `rMSEn` updates the threshold radius of the data sequence (Xt) at each scale to 0.2*std(Xt) if no `r` value is provided by Mobj, or r*std(Xt) if `r` is specified.

```MSx, CI = rMSEn(Sig, Mobj, keyword = value, ...)
```

Returns a vector of refined multiscale entropy values (`MSx`) and the complexity index (`CI`) of the data sequence (`Sig`) using the parameters specified by the multiscale object (`Mobj`) and the following ‘keyword’ arguments:

Scales:
• Number of temporal scales, a positive integer (default: 3)

F_Order:
• Butterworth low-pass filter order, a positive integer (default: 6)

F_Num:
• Numerator of Butterworth low-pass filter cutoff frequency, a scalar value in range [0 < `F_Num` < 1]. The cutoff frequency at each scale (T) becomes: Fc = F_Num/T. (default: 0.5)

• Radius rescaling method, an integer in the range [1 4].

When the entropy specified by `Mobj` is `SampEn` or `ApEn`, RadNew rescales the radius threshold in each sub-sequence at each time scale (Ykj). If a radius value (`r`) is specified by `Mobj`, this becomes the rescaling coefficient, otherwise it is set to 0.2 (default). The value of RadNew specifies one of the following methods:

• [1] Standard Deviation - `r*std(Ykj)`

• [2] Variance - `r*var(Ykj)`

• [3] Mean Absolute Deviation - `r*mad(Ykj)`

• [4] Median Absolute Deviation - `r*mad(Ykj,1)`

Plotx:
• When `Plotx == True`, returns a plot of the entropy value at each time scale (i.e. the multiscale entropy curve) [default: False]

`MSobject`, `MSEn`, `cMSEn`, `hMSEn`, `XMSEn`, `rXMSEn`, `SampEn`, `ApEn`

References:
[1] Madalena Costa, Ary Goldberger, and C-K. Peng,

“Multiscale entropy analysis of complex physiologic time series.” Physical review letters 89.6 (2002): 068102.

[2] Vadim V. Nikulin, and Tom Brismar,

“Comment on “Multiscale entropy analysis of complex physiologic time series”.” Physical review letters 92.8 (2004): 089803.

[3] Madalena Costa, Ary L. Goldberger, and C-K. Peng.

“Costa, Goldberger, and Peng reply.” Physical Review Letters 92.8 (2004): 089804.

[4] José Fernando Valencia, et al.,

“Refined multiscale entropy: Application to 24-h holter recordings of heart period variability in healthy and aortic stenosis subjects.” IEEE Transactions on Biomedical Engineering 56.9 (2009): 2202-2213.

[5] Puneeta Marwaha and Ramesh Kumar Sunkaria,

“Optimal selection of threshold value ‘r’for refined multiscale entropy.” Cardiovascular engineering and technology 6.4 (2015): 557-576.