_r21#

pycafee.sample.outliers.Dixon._r21(self, x_exp, which)#

The equation to calculate the Dixon statsitic for the r21 ratio as described at [1]

Parameters
x_expnumpy array

One dimension numpy array with the data ordered.

whichstr

The value that should be evaluated.

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

  • If it is "min", the lowest value is checked.

Notes

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

\[r_{21} = \frac{x_3-x_{1}}{x_{n-1}-x_1}\]

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

\[r_{21} = \frac{x_n-x_{n-2}}{x_{n}-x_2}\]

References

1

DIXON, W. J. Processing Data for Outliers. Biometrics, v. 9, n. 1, p. 74–89, 1953.

Examples

>>> from pycafee.sample.dixon import Dixon
>>> import numpy as np
>>> x_exp = np.array([159, 153, 184, 153, 156, 150, 147])
>>> x_exp.sort(kind='quicksort')
>>> teste = Dixon()
>>> result = teste._r21(x_exp, which="min")
>>> print(result)
0.5
>>> result = teste._r21(x_exp, which="max")
>>> print(result)
0.8235294117647058
>>> from pycafee.sample.dixon import Dixon
>>> 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')
>>> teste = Dixon()
>>> result = teste._r21(x_exp, which="min")
>>> print(result)
0.7142857142857089
>>> result = teste._r21(x_exp, which="max")
>>> print(result)
0.7058823529411722