# Multiscale Cross-Entropies

## Functions for estimating the multiscale cross-entropy between two univariate time series.

Just as one can calculate multiscale entropy using any Base entropy, the same functionality is possible with multiscale cross-entropy using any of the Cross Entropies: `XApEn`, `XSampEn`, `XK2En`, `XCondEn`, `XPermEn`, `XSpecEn`, `XDistEn`, `XFuzzEn`

To do so, we again use the `MSobject` function to pass a multiscale object (`Mobj`) to the multiscale cross-entropy functions.

Important

Multiscale cross-entropy functions have three positional arguments:

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

2. the second data sequence, `Sig2` (a vector > 10 elements),

3. 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.

XMSEn(Sig1, Sig2, Mbjx, Scales=3, Methodx='coarse', RadNew=0, Plotx=False)

XMSEn returns the multiscale cross-entropy between two univariate data sequences.

```MSx, CI = XMSEn(Sig1, Sig2, Mobj)
```

Returns a vector of multiscale cross-entropy values (`MSx`) and the complexity index (`CI`) between the data sequences contained in `Sig1` and `Sig2` using the parameters specified by the multiscale object (`Mobj`) over 3 temporal scales with coarse-graining (default).

```MSx, CI = XMSEn(Sig1, Sig2, Mobj, keyword = value, ...)
```

Returns a vector of multiscale cross-entropy values (`MSx`) and the complexity index (`CI`) between the data sequences contained in `Sig1` and `Sig2` 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 cross-entropy specified by `Mobj` is `XSampEn` or `XApEn`, 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] Pooled Standard Deviation - `r*std(Ykj)`

• [2] Pooled 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`, `XSampEn`, `XApEn`, `rXMSEn`, `cXMSEn`, `hXMSEn`, `MSEn`

References:
[1] Rui Yan, Zhuo Yang, and Tao Zhang,

“Multiscale cross entropy: a novel algorithm for analyzing two time series.” 5th International Conference on Natural Computation. Vol. 1, pp: 411-413 IEEE, 2009.

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

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

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

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

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

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

[5] Antoine Jamin, et al,

“A novel multiscale cross-entropy method applied to navigation data acquired with a bike simulator.” 41st annual international conference of the IEEE EMBC IEEE, 2019.

[6] Antoine Jamin and Anne Humeau-Heurtier.

“(Multiscale) Cross-Entropy Methods: A Review.” Entropy 22.1 (2020): 45.

cXMSEn(Sig1, Sig2, Mbjx, Scales=3, RadNew=0, Refined=False, Plotx=False)

cXMSEn returns the composite (or refined-composite) multiscale cross-entropy between two univariate data sequences.

```MSx, CI = cXMSEn(Sig1, Sig2, Mobj)
```

Returns a vector of composite multiscale cross-entropy values (`MSx`) between two univariate data sequences contained in `Sig1` and `Sig2` using the parameters specified by the multiscale object (`Mobj`) using the composite multiscale method (cMSE) over 3 temporal scales.

```MSx, CI = cXMSEn(Sig1, Sig2, Mobj, Refined = True)
```

Returns a vector of refined-composite multiscale cross-entropy values (`MSx`) for the data sequences (`Sig1`, `Sig2`) 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 `XSampEn` or `XFuzzEn`. If the entropy method is `XSampEn`, cXMSEn employs the method described in [7]. If the entropy method is `XFuzzEn`, cXMSEn employs the method described in [8].

```MSx, CI = cXMSEn(Sig1, Sig2, Mobj, keyword = value, ...)
```

Returns a vector of composite multiscale cross-entropy values (`MSx`) between the data sequences contained in `Sig1` and `Sig2` 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 cross-entropy specified by `Mobj` is `XSampEn` or `XApEn`, 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] Pooled Standard Deviation - `r*std(Ykj)`

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

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

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

Refined:
• Refined-composite XMSEn method. When `Refined == True` and the cross-entropy function specified by

`Mobj` is `XSampEn` or `XFuzzEn`, `cXMSEn` returns the refined-composite multiscale entropy (rcXMSEn) [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`, `XMSEn`, `rXMSEn`, `hXMSEn`, `XSampEn`, `XApEn`, `MSEn`, `cMSEn`, `rMSEn`

References:
[1] Rui Yan, Zhuo Yang, and Tao Zhang,

“Multiscale cross entropy: a novel algorithm for analyzing two time series.” 5th International Conference on Natural Computation. Vol. 1, pp: 411-413 IEEE, 2009.

[2] Yi Yin, Pengjian Shang, and Guochen Feng,

“Modified multiscale cross-sample entropy for complex time series.” Applied Mathematics and Computation 289 (2016): 98-110.

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

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

[4] Antoine Jamin, et al,

“A novel multiscale cross-entropy method applied to navigation data acquired with a bike simulator.” 41st annual international conference of the IEEE EMBC IEEE, 2019.

[5] Antoine Jamin and Anne Humeau-Heurtier.

“(Multiscale) Cross-Entropy Methods: A Review.” Entropy 22.1 (2020): 45.

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

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

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

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

[8] Hamed Azami et al.,

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

hXMSEn(Sig1, Sig2, Mbjx, Scales=3, RadNew=0, Plotx=False)

hXMSEn returns the hierarchical cross-entropy between two univariate data sequences.

```MSx, Sn, CI = hXMSEn(Sig1, Sig2, Mobj)
```

Returns a vector of cross-entropy values (`MSx`) calculated at each node in the hierarchical tree, the average cross-entropy value across all nodes at each scale (`Sn`), and the complexity index (`CI`) of the hierarchical tree (i.e. `sum(Sn)`) between the data sequences contained in `Sig1` and``Sig2`` 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 cross-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 = hXMSEn(Sig1, Sig2, Mobj, Keyword = value, ...)
```

Returns a vector of cross-entropy values (`MSx`) calculated at each node in the hierarchical tree, the average cross-entropy value across all nodes at each scale (`Sn`), and the complexity index (`CI`) of the entire hierarchical tree between the data sequences contained in `Sig1` and `Sig2` using 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 cross-entropy specified by `Mobj` is `XSampEn` or `XApEn`, 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] Pooled Standard Deviation - `r*std(Ykj)`

• [2] Pooled 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 cross-entropy value at each time scale (i.e. the multiscale cross-entropy curve) and a hierarchical graph showing the cross-entropy value of each node in the hierarchical tree decomposition. (default: False)

`MSobject`, `XMSEn`, `rXMSEn`, `cXMSEn`, `XSampEn`, `XApEn`, `MSEn`, `hMSEn`, `rMSEn`, `cMSEn`

References:
[1] Matthew W. Flood,

“hXMSEn - EntropyHub Project” 2021, https://github.com/MattWillFlood/EntropyHub

[2] Rui Yan, Zhuo Yang, and Tao Zhang,

“Multiscale cross entropy: a novel algorithm for analyzing two time series.” 5th International Conference on Natural Computation. Vol. 1, pp: 411-413 IEEE, 2009.

[3] 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.

rXMSEn(Sig1, Sig2, Mbjx, Scales=3, F_Order=6, F_Num=0.5, RadNew=0, Plotx=False)

rXMSEn returns the refined multiscale cross-entropy between two univariate data sequences.

```MSx, CI = rXMSEn(Sig1, Sig2, Mobj)
```

Returns a vector of refined multiscale cross-entropy values (`MSx`) and the complexity index (`CI`) between the data sequences contained in `Sig1` and `Sig2` 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 `XSampEn` or `XApEn`, `rXMSEn` updates the threshold radius of the data sequences at each scale to 0.2*SDpooled(Sig1,Sig2) if no `r` value is provided by Mobj, or r*SDpooled(Sig1,Sig2) if `r` is specified.

```MSx, CI = rXMSEn(Sig1, Sig2, Mobj, keyword = value, ...)
```

Returns a vector of refined multiscale cross-entropy values (`MSx`) and the complexity index (`CI`) between the data sequences contained in `Sig1` and `Sig2` using the parameters specified by the multiscale object (`Mobj`) and the following ‘keyword’ arguments:

Scales:
• Number of temporal scales, an integer > 1 (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 cross-entropy specified by `Mobj` is `XSampEn` or `XApEn`, 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] Pooled Standard Deviation - `r*std(Ykj)`

• [2] Pooled 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`, `XMSEn`, `cXMSEn`, `hXMSEn`, `XSampEn`, `XApEn`, `MSEn`, `rMSEn`

References:
[1] Matthew W. Flood,

“rXMSEn - EntropyHub Project” 2024, https://github.com/MattWillFlood/EntropyHub

[2] Rui Yan, Zhuo Yang, and Tao Zhang,

“Multiscale cross entropy: a novel algorithm for analyzing two time series.” 5th International Conference on Natural Computation. Vol. 1, pp: 411-413 IEEE, 2009.

[3] 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.

[4] 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.

[5] Yi Yin, Pengjian Shang, and Guochen Feng,

“Modified multiscale cross-sample entropy for complex time series.” Applied Mathematics and Computation 289 (2016): 98-110.

[6] Antoine Jamin, et al,

“A novel multiscale cross-entropy method applied to navigation data acquired with a bike simulator.” 41st annual international conference of the IEEE EMBC IEEE, 2019.

[7] Antoine Jamin and Anne Humeau-Heurtier.

“(Multiscale) Cross-Entropy Methods: A Review.” Entropy 22.1 (2020): 45.