@jit(nopython=True)<EOL>def evalPatternInArray(pattern, arr):
l = len(pattern)<EOL>ll = len(arr)<EOL>mx_additions = <NUM_LIT:3><EOL>sim = <NUM_LIT:0><EOL>i = <NUM_LIT:0><EOL>j = <NUM_LIT:0><EOL>c = <NUM_LIT:0><EOL>p = pattern[j]<EOL>v = arr[i]<EOL>while True:<EOL><INDENT>if p == v:<EOL><INDENT>d = <NUM_LIT:0><EOL><DEDENT>elif v + p == <NUM_LIT:0>:<EOL><INDENT>d = v<EOL><DEDENT>else:<EOL><INDENT>d = (p - v) / (v + p)<EOL><DEDENT>if abs(d) < <NUM_LIT>:<EOL><INDENT>c = mx_additions<EOL>j += <NUM_LIT:1><EOL>i += <NUM_LIT:1><EOL>if j == l:<EOL><INDENT>j = <NUM_LIT:0><EOL><DEDENT>if i == ll:<EOL><INDENT>return sim<EOL><DEDENT>p = pattern[j]<EOL>v = arr[i]<EOL><DEDENT>elif d < <NUM_LIT:0>:<EOL><INDENT>c += <NUM_LIT:1><EOL>j += <NUM_LIT:1><EOL>if j == l:<EOL><INDENT>j = <NUM_LIT:0><EOL><DEDENT>p += pattern[j]<EOL>sim += abs(d)<EOL><DEDENT>else:<EOL><INDENT>c += <NUM_LIT:1><EOL>i += <NUM_LIT:1><EOL>if i == ll:<EOL><INDENT>return sim<EOL><DEDENT>v += arr[i]<EOL>sim += abs(d)<EOL><DEDENT>if c == mx_additions:<EOL><INDENT>sim += abs(d)<EOL><DEDENT><DEDENT>
returns similarity parameter of given pattern to be
repeated in given array
the index is scalled between 0-1
with 0 = identical
and val>1 = different


>>> arr = [0,0.5,1,  0, 0.5,1,   0,0.5,1]
>>> pattern = [0,0.5,1]
>>> evalPatternInArray(pattern, arr)
0

>>> arr = [0,0.5,1,  0, 0.6,1,   0,0.5,1]
>>> pattern = [0,0.5,1]
>>> evalPatternInArray(pattern, arr)
0.09090909090909088


>>> arr = [0,0.5,1,  0, 0.6,1,   0,0.5,1]
>>> pattern = [1,0.5,-2]
>>> evalPatternInArray(pattern, arr)
162.2057359307358