diff --git a/src/analyzer/algorithms.py b/src/analyzer/algorithms.py index 0a0fca72..b336ede5 100644 --- a/src/analyzer/algorithms.py +++ b/src/analyzer/algorithms.py @@ -207,8 +207,8 @@ def ks_test(timeseries): """ A timeseries is anomalous if 2 sample Kolmogorov-Smirnov test indicates that data distribution for last 10 minutes is different from last hour. - It produces false positives on non-stationary series so Augmented - Dickey-Fuller test applied to check for stationarity. + It produces false positives on series with trends so Ljung-Box test for + no autocorrelation is used to filter them out. """ hour_ago = time() - 3600 @@ -222,8 +222,8 @@ def ks_test(timeseries): ks_d, ks_p_value = scipy.stats.ks_2samp(reference, probe) if ks_p_value < 0.05 and ks_d > 0.5: - adf = sm.tsa.stattools.adfuller(reference, 10) - if adf[1] < 0.05: + _, ljp = sm.stats.diagnostic.acorr_ljungbox(reference) + if ljp[-1] > 0.05: return True return False