# Cross Entropies

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

The following functions also form the cross-entropy method used by multiscale cross-entropy functions.

Attention

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. We are currently working to enable different signal lengths for cross-entropy estimation.

XApEn(Sig, varargin)

XApEn estimates the cross-approximate entropy between two univariate data sequences.

[XAp, Phi] = XApEn(Sig)

Returns the cross-approximate entropy estimates (`XAp`) and the log-average number of matched vectors (`Phi`) for `m` = [0,1,2], estimated for the data sequences contained in `Sig` using the default parameters: embedding dimension = 2, time delay = 1, radius distance threshold = 0.2*SD(`Sig`), logarithm = natural

• NOTE: `XApEn` is direction-dependent. Thus, the first row/column of `Sig` is used as the template data sequence, and the second row/column is the matching sequence.

[XAp, Phi] = XApEn(Sig, name, value, …)

Returns the cross-approximate entropy estimates (`XAp`) between the data sequences contained in `Sig` using the specified name/value pair arguments:

• `m` - Embedding Dimension, a positive integer [default: 2]

• `tau` - Time Delay, a positive integer [default: 1]

• `r` - Radius Distance Threshold, a positive scalar [default: 0.2*SD(`Sig`)]

• `Logx` - Logarithm base, a positive scalar [default: natural]

XSampEn, XFuzzEn, XMSEn, ApEn, SampEn, MSEn

References:
 Steven Pincus and Burton H. Singer,

“Randomness and degrees of irregularity.” Proceedings of the National Academy of Sciences 93.5 (1996): 2083-2088.

 Steven Pincus,

“Assessing serial irregularity and its implications for health.” Annals of the New York Academy of Sciences 954.1 (2001): 245-267.

XCondEn(Sig, varargin)

XCondEn estimates the corrected cross-conditional entropy between two univariate data sequences.

[XCond, SEw, SEz] = XCondEn(Sig)

Returns the corrected cross-conditional entropy estimates (`XCond`) and the corresponding Shannon entropies (`m: SEw`, `m+1: SEz`) for `m` = [1,2] estimated for the data sequences contained in `Sig` using the default parameters: embedding dimension = 2, time delay = 1, number of symbols = 6, logarithm = natural

• Note: `XCondEn` is direction-dependent. Therefore, the order of the data sequences in `Sig` matters. If the first row/column of `Sig` is sequence ‘y’, and the second row/column is sequence ‘u’, then `XCond` is the amount of information carried by y(i) when the pattern u(i) is found.

[XCond, SEw, SEz] = XCondEn(Sig, name, value, …)

Returns the corrected cross-conditional entropy estimates (`XCond`) for the data sequences contained in `Sig` using the specified name/value pair arguments:

• `m` - Embedding Dimension, an integer > 1 [default: 2]

• `tau` - Time Delay, a positive integer [default: 1]

• `c` - Number of symbols, an integer > 1 [default: 6]

• `Logx` - Logarithm base, a positive scalar [default: natural]

• `Norm` - Normalisation of `XCond` value, a boolean value:
• [false] no normalisation - [default]

• [true] normalises w.r.t cross-Shannon entropy.

XFuzzEn, XSampEn, XApEn, XPermEn, CondEn, XMSEn

References:
 Alberto Porta, et al.,

“Conditional entropy approach for the evaluation of the coupling strength.” Biological cybernetics 81.2 (1999): 119-129.

XDistEn(Sig, varargin)

XDistEn estimates the cross-distribution entropy between two univariate data sequences.

[XDist, Ppi] = XDistEn(Sig)

Returns the cross-distribution entropy estimate (`XDist`) and the corresponding distribution probabilities (`Ppi`) estimated between the data sequences contained in `Sig` using the default parameters: embedding dimension = 2, time delay = 1, binning method = `'Sturges'`, logarithm = base 2, normalisation = w.r.t number of histogram bins

[XDist, Pi] = XDistEn(Sig, name, value, …)

Returns the cross-distribution entropy estimate (`XDist`) estimated beween the data sequences contained in `Sig` using the specified name/value pair arguments:

• `m` - Embedding Dimension, a positive integer [default: 2]

• `tau` - Time Delay, a positive integer [default: 1]

• `Bins` - Histogram bin selection method for distance distribution, an integer > 1 indicating the number of bins, or one of the following strings: {`'sturges'`, `'sqrt'`, `'rice'`, `'doanes'`} [default: `'sturges'`]

• `Logx` - Logarithm base, a positive scalar [default: 2] enter 0 for natural log

• `Norm` - Normalisation of `XDist` value, a boolean value:
• [false] no normalisation.

• [true] normalises w.r.t # of histogram bins [default]

XSampEn, XApEn, XPermEn, XCondEn, DistEn, DistEn2D, XMSEn.

References:
 Yuanyuan Wang and Pengjian Shang,

“Analysis of financial stock markets through the multiscale cross-distribution entropy based on the Tsallis entropy.” Nonlinear Dynamics 94.2 (2018): 1361-1376.

XFuzzEn(Sig, varargin)

XFuzzEn estimates the cross-fuzzy entropy between two univariate data sequences.

[XFuzz, Ps1, Ps2] = XFuzzEn(Sig)

Returns the cross-fuzzy entropy estimates (`XFuzz`) and the average fuzzy distances (`m: Ps1`, `m+1: Ps2`) for `m` = [1,2] estimated for the data sequences contained in `Sig`, using the default parameters: embedding dimension = 2, time delay = 1, fuzzy function (`Fx`) = `'default'`, fuzzy function paramters (`r`) = [0.2, 2], logarithm = natural

[XFuzz, Ps1, Ps2] = XFuzzEn(Sig, name, value, …)

Returns the cross-fuzzy entropy estimates (`XFuzz`) for dimensions = [1, …, `m`] estimated for the data sequences in `Sig` using the specified name/value pair arguments:

• `m` - Embedding Dimension, a positive integer [default: 2]

• `tau` - Time Delay, a positive integer [default: 1]

• `Fx` - Fuzzy function name, one of the following strings: {`'sigmoid'`, `'modsampen'`, `'default'`, `'gudermannian'`, `'linear'`}

• `r` - Fuzzy function parameters, a 1 element scalar or a 2 element vector of positive values. The `r` parameters for each fuzzy function are defined as follows: (default: [.2 2])

sigmoid:
• r(1) = divisor of the exponential argument

• r(2) = value subtracted from argument (pre-division)

modsampen:
• r(1) = divisor of the exponential argument

• r(2) = value subtracted from argument (pre-division)

default:
• r(1) = divisor of the exponential argument

• r(2) = argument exponent (pre-division)

gudermannian:
• r = a scalar whose value is the numerator of

argument to gudermannian function: GD(x) = atan(tanh(r/x)). GD(x) is normalised to have a maximum value of 1.

linear:
• r = an integer value. When `r == 0`, the

argument of the exponential function is normalised between [0 1]. When `r == 1`, the minimuum value of the exponential argument is set to 0.

• `Logx` - Logarithm base, a positive scalar [default: natural]

For further information on the name/value paire arguments, see the EntropyHub guide

FuzzEn, XSampEn, XApEn, FuzzEn2D, XMSEn, MSEn

References:
 Hong-Bo Xie, et al.,

“Cross-fuzzy entropy: A new method to test pattern synchrony of bivariate time series.” Information Sciences 180.9 (2010): 1715-1724.

XK2En(Sig, varargin)

XK2En estimates the cross-Kolmogorov (K2) entropy between two univariate data sequences.

[XK2, Ci] = XK2En(Sig)

Returns the cross-Kolmogorov entropy estimates (`XK2`) and the correlation integrals (`Ci`) for `m` = [1,2] estimated between the data sequences contained in `Sig` using the default parameters: embedding dimension = 2, time delay = 1, distance threshold (`r`) = 0.2*SD(`Sig`), logarithm = natural

[XK2, Ci] = XK2En(Sig, name, value, …)

Returns the cross-Kolmogorov entropy estimates (`XK2`) estimated between the data sequences contained in `Sig` using the specified name/value pair arguments:

• `m` - Embedding Dimension, a positive integer [default: 2]

• `tau` - Time Delay, a positive integer [default: 1]

• `r` - Radius Distance Threshold, a positive scalar [default: 0.2*SD(`Sig`)]

• `Logx` - Logarithm base, a positive scalar [default: natural]

XSampEn, XFuzzEn, XApEn, K2En, XMSEn, XDistEn.

References:
 Matthew W. Flood,

“XK2En - EntropyHub Project” (2021) https://github.com/MattWillFlood/EntropyHub

XPermEn(Sig, varargin)

XPermEn estimates the cross-permutation entropy between two univariate data sequences.

[XPerm] = XPermEn(Sig)

Returns the cross-permuation entropy estimates (`XPerm`) estimated betweeen the data sequences contained in `Sig` using the default parameters: embedding dimension = 3, time delay = 1, logarithm = base 2,

[XPerm] = XPermEn(Sig, name, value, …)

Returns the permutation entropy estimates (`XPerm`) for the data sequences contained in `Sig` using the specified name/value pair arguments:

• `m` - Embedding Dimension, an integer > 2 [default: 3] **Note: `XPerm` is undefined for embedding dimensions < 3.

• `tau` - Time Delay, a positive integer [default: 1]

• `Logx` - Logarithm base, a positive scalar [default: 2] (enter 0 for natural log).

PermEn, XApEn, XSampEn, XFuzzEn, XMSEn

References:
 Wenbin Shi, Pengjian Shang, and Aijing Lin,

“The coupling analysis of stock market indices based on cross-permutation entropy.” Nonlinear Dynamics 79.4 (2015): 2439-2447.

XSampEn(Sig, varargin)

XSampEn estimates the cross-sample entropy between two univariate data sequences.

[XSamp, A, B] = XSampEn(Sig)

Returns the cross-sample entropy estimates (`XSamp`) and the number of matched vectors (`m: B`, `m+1: A`) for m = [0,1,2] estimated for the two univariate data sequences contained in `Sig` using the default parameters: embedding dimension = 2, time delay = 1, radius distance threshold = 0.2*SD(`Sig`), logarithm = natural

[XSamp, A, B] = XSampEn(Sig, name, value, …)

Returns the cross-sample entropy estimates (`XSamp`) for dimensions [0,1, …, `m`] estimated between the data sequences in `Sig` using the specified name/value pair arguments:

• `m` - Embedding Dimension, a positive integer [default: 2]

• `tau` - Time Delay, a positive integer [default: 1]

• `r` - Radius Distance Threshold, a positive scalar [default: 0.2*SD(`Sig`)]

• `Logx` - Logarithm base, a positive scalar [default: natural]

XFuzzEn, XApEn, SampEn, SampEn2D, XMSEn, ApEn

References:
 Joshua S Richman and J. Randall Moorman.

“Physiological time-series analysis using approximate entropy and sample entropy.” American Journal of Physiology-Heart and Circulatory Physiology (2000)

XSpecEn(Sig, varargin)

XSpecEn estimates the cross-spectral entropy between two univariate data sequences.

[XSpec, BandEn] = XSpecEn(Sig)

Returns the cross-spectral entropy estimate (`XSpec`) of the full cross- spectrum and the within-band entropy (`BandEn`) estimated between the data sequences contained in `Sig` using the default parameters: N-point FFT = length of `Sig`, normalised band edge frequencies = [0 1], logarithm = natural, normalisation = w.r.t # of spectrum/band frequency values.

[XSpec, BandEn] = XSpecEn(Sig, name, value, …)

Returns the cross-spectral entropy (`XSpec`) and the within-band entropy (`BandEn`) estimate between the data sequences contained in `Sig` using the following specified name/value pair arguments:

• `N` - Resolution of spectrum (N-point FFT), an integer > 1

• `Freqs` - Normalised band edge frequencies, a scalar in range [0 1] where 1 corresponds to the Nyquist frequency (Fs/2). *Note: When no band frequencies are entered, `BandEn == SpecEn`

• `Logx` - Logarithm base, a positive scalar [default: natural]

• `Norm` - Normalisation of `XSpec` value, a boolean:
• [false] no normalisation.

• [true] normalises w.r.t # of frequency values within the spectrum/band [default]