Skip to main content
. 2019 Oct 21;21(10):1023. doi: 10.3390/e21101023
Algorithm 1. Given an m-tuple (x1,x2,…,xm)∈Xm of elements from a totally ordered set X, a distinct numerical representation n∈{0,1,…,m!−1} of its ordinal pattern of order m can be obtained as outlined by the following pseudocode.
1 function encode_pattern
2 input
3   (x1,x2,…,xm)∈Xm with m∈{2,3,…}
4 output
5   n ∈{0,1,…,m!−1}
6 begin
7   n←0
8   for i←1 to m−1 do
9     for j←i+1 to m do
10       n←n+xi>xj
11     end
12     n←(m−i)n
13   end
14   return n
15 end.