# 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 two positional arguments:

1. the time series signals, `Sig` (an Nx2 matrix),

2. the multiscale entropy object, `Mobj`.

Important

For cross-entropy and multiscale cross-entropy functions, the two time series signals are passed as a two-column or two-row matrix. At present, it is not possible to pass signals of different lengths separately.

`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

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

Bidimensional Entropies
`'SampEn2D'`
• Bidimensional Sample Entropy

`'FuzzEn2D'`
• Bidimensional Fuzzy Entropy

`'DispEn2D'`
• Bidimensional Dispersion Entropy

`'DistEn2D'`
• Bidimensional Distribution Entropy

`'PermEn2D'`
• Bidimensional Permutation Entropy

`'EspEn2D'`
• Bidimensional Espinosa Entropy

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

The following functions use the multiscale entropy object shown above.

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

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

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

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

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

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

Scales
• Number of temporal scales, an integer > 1 [default: 3]

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

• 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:

•  Standard Deviation - `r*std(Ykj)`

•  Variance - `r*var(Ykj)`

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

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

 Madalena Costa, Ary Goldberger, and C-K. Peng,

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

 Vadim V. Nikulin, and Tom Brismar,

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

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

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

 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.

 Antoine Jamin and Anne Humeau-Heurtier.

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

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

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

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

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

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

Returns a vector of composite multiscale cross-entropy values (`MSx`) between the data sequences contained in ‘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 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:

•  Standard Deviation - `r*std(Ykj)`

•  Variance - `r*var(Ykj)`

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

•  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`, `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
 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.

 Yi Yin, Pengjian Shang, and Guochen Feng,

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

 Madalena Costa, Ary Goldberger, and C-K. Peng,

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

 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.

 Antoine Jamin and Anne Humeau-Heurtier.

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

 Shuen-De Wu, et al.,

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

`hXMSEn`(Sig, Mbjx, Scales=3, RadNew=0, Plotx=False)

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

```MSx, Sn, CI = hXMSEn(Sig, 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 `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 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(Sig, 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 `Sig` 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:

•  Standard Deviation - `r*std(Ykj)`

•  Variance - `r*var(Ykj)`

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

•  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
 Matthew W. Flood,

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

 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.

 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`(Sig, 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(Sig, Mobj)
```

Returns a vector of refined multiscale cross-entropy values (`MSx`) and the complexity index (`CI`) between the data sequences contained in `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 `XSampEn` or `XApEn`, `rMSEn` updates the threshold radius of the data sequences (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 = rXMSEn(Sig, Mobj, keyword = value, ...)
```

Returns a vector of refined multiscale cross-entropy values (`MSx`) and the complexity index (`CI`) between the data sequences contained in `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)

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:

•  Standard Deviation - `r*std(Ykj)`

•  Variance - `r*var(Ykj)`

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

•  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
 Matthew W. Flood,

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

 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.

 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.

 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.

 Yi Yin, Pengjian Shang, and Guochen Feng,

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

 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.

 Antoine Jamin and Anne Humeau-Heurtier.

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