Search for unusual value in an array, list

I have sales statistics in the form of an array to calculate the standard deviation or the average of these data.

stats = [100, 98, 102, 100, 108, 23, 120] 

let the indicated + -20% differential be a normal situation, 23 is obviously a special case.

what is the best algorithm (in any language, pseudo or any principle) to find this unusual value?

+5
source share
3 answers

You can convert them to a Z-score and look for outliers.

>>> import numpy as np
>>> stats = [100, 98, 102, 100, 108, 23, 120]
>>> mean = np.mean(stats)
>>> std = np.std(stats)
>>> stats_z = [(s - mean)/std for s in stats]
>>> np.abs(stats_z) > 2
array([False, False, False, False, False,  True, False], dtype=bool)
+9
source

. , X "" ( X, , - 2,5 3,0 ).

. - , - , () 2.7 .

+2

find the standard deviation, and values ​​outside 3 sigma or + -3 sigma are an outrageous value ...

In theory, sigma + -3 gives a confidence value of more than 99%.

+2
source

All Articles