File Exchange

## Ordinal patterns distribution

version 1.2.0 (815 KB) by
Efficiently computing distribution and sequence of ordinal patterns from 1D time series

Updated 15 Oct 2018

View Version History

function OPsequence efficiently [1,2] computes distribution and sequence of ordinal patterns from 1D time series indata for the given order and delay (note that only orders = 1…8 are supported in this efficient version)

NOTES
1 Order of ordinal patterns is defined as in [1,3,7,8], i.e. order = n-1 for order of ordinal patterns n defined as in the original paper by C. Bandt and B. Pompe .

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)

OUTPUT
- opSequence - sequence of computed ordinal patterns (N-order*delay numbers of ordinal patterns ranging from 0 to ((order + 1)! - 1), where ! stands for factorial)
- opDistribution - normalised distribution of computed ordinal patterns, i.e. amount of each ordinal pattern is divided by the total amount of ordinal patterns (order+1)!, where ! stands for factorial

CITING THE CODE
 Unakafova, V.A., Keller, K., 2013. Efficiently measuring complexity on the basis of real-world data. Entropy, 15(10), 4392-4415.
 Keller, K. and Sinn, M., 2005. Ordinal analysis of time series. Physica A: Statistical Mechanics and its Applications, 356(1), pp.114-120.

EXAMPLE OF USE (with a plot):
indata( 1 ) = 0.46891641;
% simulating orbit for the logistic map
% (one can see that some ordinal patterns are missing in the distribution)
for i = 2:1000
indata( i ) = 4*indata( i - 1 )*( 1 - indata( i - 1 ) );
end
[opSequence, opDistribution] = OPsequence( indata, 1, 3 );
figure;
subplot( 2, 1, 1 );
bar( opDistribution, 'FaceColor',[0 .5 .5], 'LineWidth',1.5 );
xlabel( 'Ordinal pattern number', 'FontSize', 14 );
ylabel( 'Ordinal patterns frequency', 'FontSize', 14 );
title( 'Distribution of ordinal patterns', 'FontSize', 14 );
subplot( 2, 1, 2 );
plot( 1:length( opSequence ), opSequence, 'k*' );
title( 'Sequence of ordinal patterns', 'FontSize', 14 );
ylim( [-1 factorial(3+1)-1] );
xlabel( 'Time stamp', 'FontSize', 14 );
ylabel( 'Ordinal pattern number', 'FontSize', 14 );

CHOICE OF ORDER OF ORDINAL PATTERNS
The larger order of ordinal patterns is, the more information of the underlying dynamical system  is extracted by ordinal patterns. 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 [2,4,5,8].
In  the following rule for choice of order is recommended:
5*(order + 1)! < windowSize.

CHOICE OF DELAY BETWEEN POINTS IN ORDINAL PATTERNS
I would recommend choosing different delays and comparing results (see, for example, [3, Section 2.2-2.4] and [7, Chapter 5] for more details) though delay = 1 is often used for practical applications.
Choice of delay depends on particular data analysis you perform [3,4], on type of pre-processing 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
 Unakafova, V.A., Keller, K., 2013. Efficiently measuring complexity on the basis of real-world Data. Entropy, 15(10), 4392-4415.
 Bandt, C. and Pompe, B., 2002. Permutation entropy: a natural complexity measure for time series. Physical review letters, 88(17), p.174102.
 Keller, K., Unakafov, A.M. and Unakafova, V.A., 2014. Ordinal patterns, entropy, and EEG. Entropy, 16(12), pp.6212-6239.
 Riedl, M., Muller, A. and Wessel, N., 2013. Practical considerations of permutation entropy. The European Physical Journal Special Topics, 222(2), pp.249-262.
 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.
 Amigo, J.M., Zambrano, S. and Sanjuan, M.A., 2008. Combinatorial detection of determinism in noisy time series. EPL (Europhysics Letters), 83(6), p.60005.
 Unakafova, V.A., 2015. Investigating measures of complexity for dynamical systems and for time series (Doctoral dissertation, University of Luebeck).
 Keller, K., and M. Sinn. Ordinal analysis of time series. Physica A: Statistical Mechanics and its Applications 356.1 (2005): 114—120

### Cite As

Valentina Unakafova (2020). Ordinal patterns distribution (https://www.mathworks.com/matlabcentral/fileexchange/65590-ordinal-patterns-distribution), MATLAB Central File Exchange. Retrieved .

ervin

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