# How to detect whether an entire series is an outlier relative to others?

I have multiple price series of the same asset as follows. Visually, it is obvious that series "A" (the flat line) is an outlier, and series "E" (the line with the zig-zag pattern) also behaves differently.

What is the best method to detect whether an entire series is an outlier? Should I be looking into some sort of classification model?

• This will be difficult. Can you do it manually? Jan 6 at 13:58
• I would like to automate this process and remove the human bias from the decision Jan 6 at 13:59

One method to consider is Dynamic Time Warping (DTW), which measures similarity between time series. DTW is capable of comparing time series of different lengths, and the resulting score could be used to determine which series are most unique in your sample. You'll find in many articles that DTW works well with KNN classification (I personally can attest to having success with the combination) so you could write a script that calculates a DTW score, then finds the series score(s) which is furthest from the others.

Some intro to DTW and helpful pages:

To a human observer it is obvious that "A" and "E" are different because they show a different pattern in their amplitude compared to "B" "C" and "D". The trajectory of "E" doesn't even look that different for the most part, it just jumps up and down rapidly at certain intervals.

My idea would be to evaluate the amplitude of your line at certain windows in your timespan. Let's say you take the bi-hourly amplitude as the difference between the highest and lowest point of the graph in that window, let's call it $$A(t,l)$$, with $$t$$ representing the start of your time window, and $$l$$ indicating the line. Then, you can compare this value between the five lines.

You can then play around with setting different thresholds to see what works best. Having only seen this data, it would work to:

• Set a minimum threshold $$t_{min}$$ for $$A$$, at some low value. Low amplitudes, or ones of $$0$$, are probably always wrong in a financial use-case.
This would detect that line "A" is an outlier, because $$A(t,a) = 0 < t_{min}$$
• Set a difference threshold $$t_{diff}$$ based on the values of all the lines not filtered out in the previous step. You can probably do some math using standard deviations here, or a heuristic like: if $$A(t,l) > 2 * mean(A(t,l_{all}))$$.
You will then probably detect that $$A(t,e)$$ is much larger than that of "B" "C", and "D".

Hope this helps!