_one#

pycafee.sample.outliers.Grubbs._one(self, x_exp, which)#

This function calculates the statistic for the Grubbs test to check if the sample has one outlier as described by Grubbs [1] (\(G^{'}\))

Parameters
x_expnumpy array

One dimension numpy array with the data ordered.

whichstr

The value that should be evaluated.

  • If which="max" (or None), the highest value is checked if it is a possible outlier.

  • If which="min", the lowest value is checked if it is a possible outlier.

Returns
statisticfloat

The test statistic

Notes

If which=="min", the equation used is:

\[G^{'} = \frac{\overline{x}-x_1}{s}\]

If which=="max", the equation used is:

\[G^{'} = \frac{x_n-\overline{x}}{s}\]

The data must be ordered.

References

1

GRUBBS, F. E. Sample Criteria for Testing Outlying Observations. The Annals of Mathematical Statistics, v. 21, n. 1, p. 27–58, 1950.

Examples

>>> from pycafee.sample.outliers import Grubbs
>>> import numpy as np
>>> x_exp = np.array([159, 153, 184, 153, 156, 150, 147])
>>> x_exp.sort(kind='quicksort')
>>> test = Grubbs()
>>> result = test._one(x_exp, which="max")
>>> print(result)
2.1532047136140045
>>> from pycafee.sample.outliers import Grubbs
>>> import numpy as np
>>> x_exp = np.array([15.42, 15.51, 15.52, 15.53, 15.68, 15.52, 15.56, 15.53, 15.54, 15.56])
>>> x_exp.sort(kind='quicksort')
>>> test = Grubbs()
>>> result = test._one(x_exp, which="min")
>>> print(result)
1.8344557993475004