Skip to main content
. 2019 Oct 21;21(10):1023. doi: 10.3390/e21101023
Algorithm 4.Lookup Algorithm. To transform a finite time series {xt} into a sequence of non-negative integers {nt} representing its ordinal patterns, select a pattern order m⩾2 and time lag τ⩾1. In addition, prepare a lookup table {Li,j} according to Equation (21) that matches the encode_pattern function to be used. This can be the sym-function given by Equation (11), the sym*-function of Equation (9), or any other bijective map yielding nt∈{0,1,…,m!−1}. Then, proceed as follows.
1 function encode_sequence
2 input
3   {xt} with xt ∈X and t∈{1,2,…,N}
4   m ∈N with m ⩾2
5   τ ∈N with τ ⩾1
6 output
7   {nt} with nt ∈{0,1,…,m!−1} and t ∈{1,2,…,N−(m−1)τ}
8 locals
9   {Li,j} with Li,j ∈{0,1,…,m!−1} and i ∈{1,2,…,m!} and j∈{1,2,…,m}
10 begin
11   {Li,j}←load_lookup_table(m)
12
13   /* Encode first τ ordinal patterns */
14   for t←1 to τ do
15     nt← encode_pattern(xt,xt+τ,…,xt+(m−1)τ)
16   end
17
18   /* Encode all remaining patterns */
19   for t←τ+1 to N−(m−1)τ do
24     row ←nt−τ+1
20     col ←1
21     for i←1 to m−1 do
22      col←col+xt+(i−1)τ>xt+(m−1)τ
23     end
25     nt←Lrow,col
26   end
27 end.