File Exchange

## Conditional entropy of ordinal patterns (fast algorithm)

version 1.2.4 (815 KB) by
CondEn.m computes efficiently conditional entropy of ordinal patterns from 1D time series.

Updated 15 Oct 2018

View Version History

function eCE = CondEn( x, delay, order, windowSize )
computes efficiently conditional entropy of ordinal patterns from 1D time series in sliding windows for orders 1...8 of ordinal patterns .
See more ordinal-patterns based measures at www.mathworks.com/matlabcentral/fileexchange/63782-ordinal-patterns-based-analysis--beta-version-.

INPUT
- indata - 1D time series (1 x N points)
- delay - delay between points in ordinal patterns (delay = 1 means successive points)
- order - order of the ordinal patterns (order + 1 is the number of points in ordinal patterns)
- windowSize - size of sliding window (= number of ordinal patterns within sliding window)

OUTPUT
- outdata - values of conditional entropy of ordinal patterns (1 x (N - windowSize – (order+1)*delay) points since each sliding window contains windowSize ordinal patterns but uses in fact (windowSize + order*delay + 1) points).

CITING THE CODE
[a] Unakafova, Valentina (2015). Conditional entropy of ordinal patterns in sliding windows (fast algorithm), (www.mathworks.com/matlabcentral/fileexchange/48684-conditional-entropy-of-ordinal-patterns-in-sliding-windows--fast-algorithm-), MATLAB Central File Exchange. Retrieved Month Day, Year.
[b] Unakafov, A.M. and Keller, K., 2014. Conditional entropy of ordinal patterns. Physica D: Nonlinear Phenomena, 269, pp.94-102
[c] Unakafova, V.A., Keller, K., 2013. Efficiently measuring complexity on the basis of real-world data. Entropy, 15(10), 4392-4415.

EXAMPLE OF USE (with a plot):
indata = rand( 1, 7777 ); % generate random data points
for i = 4000:7000 % generate change of data complexity
indata( i ) = 4*indata( i - 1 )*( 1 - indata( i - 1 ) );
end
delay = 1; % delay 1 between points in ordinal patterns (successive points)
order = 3; % order 3 of ordinal patterns (4-points ordinal patterns)
windowSize = 512; % 512 ordinal patterns in one sliding window
outdata = CondEn( indata, delay, order, windowSize );
figure;
ax1 = subplot( 2, 1, 1 ); plot( indata, 'k', 'LineWidth', 0.2 );
grid on; title( 'Original time series' );
ax2 = subplot( 2, 1, 2 );
plot( length(indata) - length(outdata)+1:length(indata), outdata, 'k', 'LineWidth', 0.2 );
grid on; title( 'Values of conditional entropy of ordinal patterns' );
linkaxes( [ ax1, ax2 ], 'x' );

The method is based on precomputing values of successive ordinal patterns of order d, using the fact that they are "overlapped" in d=order points .

CHOICE OF ORDER OF ORDINAL PATTERNS
The larger order of ordinal patterns is, the better permutation entropy estimates complexity of the underlying dynamical system . But for time series of finite length too large order of ordinal patterns leads to an underestimation of the complexity because not all ordinal patterns representing the system can occur . Therefore, for practical applications, orders = 3...7 are often used [3,5,7]. In  the following rule for choice of order is recommended:
5*(order + 1)!(order +1) < windowSize.
though (order +2)! is usually sufficient.

CHOICE OF SLIDING WINDOW LENGTH
Window size should be chosen in such way that time series is stationary within the window (for example, for EEG analysis 2 seconds sliding windows are often used) so that distribution of ordinal patterns would not change within the window , [2, Section 2.2], [6, Section 5.1.2].

CHOICE OF DELAY BETWEEN POINTS IN ORDINAL PATTERNS
I would recommend choosing different delays and comparing results (see, for example, [2, Section 2.2-2.4] and [6, Chapter 5] for more details) though delay = 1 is often used for practical applications.
Choice of delay depends on particular data analysis you perform [2,5] and on sampling rate of the data. For example, if you are interested in low-frequency part of signals it makes sense to use larger delays.

REFERENCES
 Unakafov, A.M. and Keller, K., 2014. Conditional entropy of ordinal patterns. Physica D: Nonlinear Phenomena, 269, pp.94-102
 Keller, K., Unakafov, A.M. and Unakafova, V.A., 2014. Ordinal patterns, entropy, and EEG. Entropy, 16(12), pp.6212-6239.
 Bandt, C. and Pompe, B., 2002. Permutation entropy: a natural complexity measure for time series. Physical review letters, 88(17), p.174102.
 Unakafova, V.A. and Keller, K., 2013. Efficiently measuring complexity on the basis of real-world data. Entropy, 15(10), pp.4392-4415.
 Riedl, M., Muller, A. and Wessel, N., 2013. Practical considerations of permutation entropy. The European Physical Journal Special Topics, 222(2), pp.249-262.
 Unakafova, V.A., 2015. Investigating measures of complexity for dynamical systems and for time series (Doctoral dissertation, Ph. D. Thesis, draft version, University of Lubeck, Lubeck, Germany).
 Zanin, M., Zunino, L., Rosso, O.A. and Papo, D., 2012. Permutation entropy and its main biomedical and econophysics applications: a review. Entropy, 14(8), pp.1553-1577.

### Cite As

Valentina Unakafova (2020). Conditional entropy of ordinal patterns (fast algorithm) (https://www.mathworks.com/matlabcentral/fileexchange/48684-conditional-entropy-of-ordinal-patterns-fast-algorithm), MATLAB Central File Exchange. Retrieved .

MM xu

MM xu

##### MATLAB Release Compatibility
Created with R2013b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux