160 Chapter 10 Anomaly Detection
7. The Grubbs’ test, which is described by Algorithm 10.1, is a more statistically
sophisticated procedure for detecting outliers than that of Definition 10.3. It
is iterative and also takes into account the fact that the z-score does not
have a normal distribution. This algorithm computes the z-score of each
value based on the sample mean and standard deviation of the current set of
values. The value with the largest magnitude z-score is discarded if its z-score
is larger than gc, the critical value of the test for an outlier at significance
level α. This process is repeated until no objects are eliminated. Note that
the sample mean, standard deviation, and gcare updated at each iteration.
Algorithm 10.1 Grubbs’ approach for outlier elimination.
1: Input the values and α
{mis the number of values, αis a parameter, and tcis a value chosen so that
α=prob(x≥tc)foratdistribution with m−2 degrees of freedom.}
2: repeat
3: Compute the sample mean (x) and standard deviation (sx).
4: Compute a value gcso that prob(|z|≥gc)=α.
(In terms of tcand m,gc=m−1
√mt2
c
m−2+t2
c.)
5: Compute the z-score of each value, i.e., z=(x−x)/sx.
6: Let g=max|z|, i.e., find the z-score of largest magnitude and call it g.
7: if g>g
cthen
8: Eliminate the value corresponding to g.
9: m←m−1
10: end if
11: until No objects are eliminated.
(a) What is the limit of the value m−1
√mt2
c
m−2+t2
cused for Grubbs’ test as
mapproaches infinity? Use a significance level of 0.05.