File Exchange

image thumbnail

Robust permutation entropy (fast algorithm)

version 1.4.1 (815 KB) by Valentina Unakafova
Fast calculation of robust permutation entropy from 1D time series in sliding windows

8 Downloads

Updated 15 Oct 2018

View License

function outdata = rePE( indata, delay, order, windowSize, lowThreshold, highThreshold )
efficiently computes values of robust permutation entropy in sliding windows (see more ordinal-patterns based measures at http://www.mathworks.com/matlabcentral/fileexchange/63782-ordinal-patterns-based-analysis--beta-version-) for orders=1...8 of ordinal patterns [BP02,UK13,KUU14,U15].
Robust permutation entropy has shown better results than permutation entropy for simulated data and for epileptic seizures detection [U15,KUU14].

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 number of points in ordinal patterns)
- windowSize - size of sliding window (number of ordinal patterns within sliding window)
- lowThreshold - distance that is considered negligibly small between the points (see [KUU14,U15] for more details)
- upperThreshold – distance between points most probably related to artifact (see [KUU14,U15] for more details)

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

CITING THE CODE
[1] Unakafova, V.A. 2015. Robust permutation entropy (fast algorithm), MATLAB Central File Exchange. Retrieved Month Day, Year.
[2] Keller, K., Unakafov, A.M. and Unakafova, V.A., 2014. Ordinal patterns, entropy, and EEG. Entropy, 16(12), pp.6212-6239.

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
lowThreshold = 0.01; % distance that is considered negligibly small between points
upperThreshold = 100; % distance between points most probably related to artifact
outdata = rePE( indata, delay, order, windowSize, lowThreshold, upperThreshold );
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 robust permutation entropy' );
linkaxes( [ ax1, ax2 ], 'x' );

CHOICE OF ORDER OF ORDINAL PATTERNS
The larger order of ordinal patterns is, the better permutation entropy estimates complexity of the underlying dynamical system [KUU14]. 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 [KUU14]. Therefore for practical applications, orders = 3...7 are often used [BP02,RMW13,ZZR12]. In [AZS08] the following rule for choice of order is recommended: 5*(order + 1)! < windowSize.

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 s sliding windows are often used) so that distribution of ordinal patterns would not change within the window [BKP02,KUU14(Section 2.2),U15(Section 5.1.2)].

CHOICE OF DELAY BETWEEN POINTS IN ORDINAL PATTERNS
I would recommend choosing different delays and comparing results (e.g. [KUU14, Section 2.2-2.4,U15, Chapter 5] ) though delay = 1 is often used for practical applications. Choice of delay depends on particular data analysis [RWM13,KUU14].

CHOISE OF THRESHOLDS
is described in [U15(Section 3.3.6),KUU14]. New description is to be added.

REFERENCES
[AZS08] 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.
[BP02] Bandt, C. and Pompe, B., 2002. Permutation entropy: a natural complexity measure for time series. Physical review letters, 88(17), p.174102.
[KUU14] Keller, K., Unakafov, A.M. and Unakafova, V.A., 2014. Ordinal patterns, entropy, and EEG. Entropy, 16(12), pp.6212-6239.
[RMW13] Riedl, M., Muller, A. and Wessel, N., 2013. Practical considerations of permutation entropy. The European Physical Journal Special Topics, 222(2), pp.249-262.
[UK13] Unakafova, V.A., Keller, K., 2013. Efficiently measuring complexity on the basis of real-world Data. Entropy, 15(10), 4392-4415.
[U15] Unakafova, V.A., 2015. Investigating measures of complexity for dynamical systems and for time series (Doctoral dissertation, University of Luebeck).
[ZZR12] 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 (2019). Robust permutation entropy (fast algorithm) (https://www.mathworks.com/matlabcentral/fileexchange/50557-robust-permutation-entropy-fast-algorithm), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

citysky

MM xu

ervin

Updates

1.4.1

Cover picture has been updated

1.4.0.0

1 The script is updated for compatibility with MATLAB 2018.
2 The values of robust permutation entropy are normalised as in original paper by Bandt and Pompe (divided by log((order+1)!)) not by the order of ordinal patterns as in previous version.

1.3.2.1

description is renewed

1.3.2.0

Description is renewed

1.3.1.0

Example of use is added

1.3.0.0

Cover picture has been added

1.2.0.0

Minor code style corrections

1.1.0.0

-

1.1.0.0

Precomputed tables as *.mat files are added.

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