## Ordinal patterns distribution

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

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

[1] Unakafova, V.A., Keller, K., 2013. Efficiently measuring complexity on the basis of real-world data. Entropy, 15(10), 4392-4415.

[2] 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 [3] 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 [3]. Therefore, for practical applications, orders = 3...7 are often used [2,4,5,8].

In [6] 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

[1] Unakafova, V.A., Keller, K., 2013. Efficiently measuring complexity on the basis of real-world Data. Entropy, 15(10), 4392-4415.

[2] Bandt, C. and Pompe, B., 2002. Permutation entropy: a natural complexity measure for time series. Physical review letters, 88(17), p.174102.

[3] Keller, K., Unakafov, A.M. and Unakafova, V.A., 2014. Ordinal patterns, entropy, and EEG. Entropy, 16(12), pp.6212-6239.

[4] Riedl, M., Muller, A. and Wessel, N., 2013. Practical considerations of permutation entropy. The European Physical Journal Special Topics, 222(2), pp.249-262.

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

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

[7] Unakafova, V.A., 2015. Investigating measures of complexity for dynamical systems and for time series (Doctoral dissertation, University of Luebeck).

[8] 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 (2024). Ordinal patterns distribution (https://www.mathworks.com/matlabcentral/fileexchange/65590-ordinal-patterns-distribution), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility

##### Platform Compatibility

Windows macOS Linux##### Categories

##### Tags

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!### Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Version | Published | Release Notes | |
---|---|---|---|

1.2.0 | Cover picture has been updated |
||

1.1.0.0 | Description has been renewed (NOTES section is added) |
||

1.0.3.0 | Output is now two variables (ordinal patterns sequence and ordinal patterns distribution) instead of structure with two fields that makes script more memory efficient |
||

1.0.2.0 | minor description changes |
||

1.0.1.0 | Minor description changes |
||

1.0.0.0 |