In [ ]:
import numpy as np
def znorm(series, znorm_threshold=0.01):
"""Fallback Python implementation."""
sd = np.std(series)
if (sd < znorm_threshold):
return series
mean = np.mean(series)
res = np.zeros(len(series))
for i in range(0, len(series)):
res[i] = (series[i] - mean) / sd
return res.ravel()
In [ ]:
In [ ]:
from numpy import std
from saxpy import znorm as zn
In [ ]:
"""Test the znorm implementation."""
ts = [-1., -2., -1., 0., 2., 1., 1., 0.]
z_thrsh = 0.001
x_scaled = [x / 100.0 for x in ts]
In [ ]:
zn.znorm(x_scaled, z_thrsh)
In [1]:
import inspect
from saxpy import znorm as zn
lines = inspect.getsourcelines(zn.znorm)
print("".join(lines[0]))
In [ ]:
mean = np.mean(zz)
mean
In [ ]:
std = np.std(zz, axis=0, ddof=1)
std
In [ ]:
In [ ]:
In [ ]: