Skip to main content
. 2019 Oct 21;21(10):1023. doi: 10.3390/e21101023
Algorithm 3. Overlap Algorithm. To transform a finite time series {xt} of elements xt∈X into a sequence of non-negative integers {nt} representing the ordinal patterns {Πt} of the time series, select a pattern order m⩾2 and time lag τ⩾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  {ri,j} with i∈{1,2,…,τ} and j∈{1,2,…,m}
10 begin
11  ri,j←0 for all i∈{1,2,…,τ} and all j∈{1,2,…,m}
12
13  /* Obtain initial right inversion counts Rinit */
14  for t←1 to τ do
15   for i←1 to m−2 do
16     for j←i+1 to m−1 do
17     rt,i+1←rt,i+1+xt+(i−1)τ>xt+(j−1)τ
18    end
19   end
20  end
21
22  /* Extract and encode ordinal patterns */
23  i←1
24  for t←1 to N−(m−1)τ do
25    for j←1 to m−1 do
26     ri,j ←ri,j+1+xt+(j−1)τ>xt+(m−1)τ
27    nt ←(m−j)(nt+ri,j)
28    end
29   i←(imodτ)+1/* Increment circular buffer index */
30  end
31 end.