API Documentation

dixonstat.Q(size, **kwargs)

Returns the \(r_{10}\) range ratio statistic.

class dixonstat.RangeRatio(size, j, i, hgh_order=17, fgh_order=31, gl_order=16)

Dixon’s \(r_{j,i}\) range ratio statistic.

The statistic can be used to detect outliers in data sets containing samples assumed to be normally distributed.

Parameters:
  • size (int) – The number of observations in the data set.

  • j (int) – The number of possible suspected outliers on the same end of the data as the value being tested.

  • i (int) – The number of possible outliers on the opposite end of the data from the suspected value.

  • hgh_order (int) – The number of quadrature points for the half-range \([0,\infty)\) Gauss-Hermite quadrature used to compute probability density.

  • fgh_order (int) – The number of quadrature points for the full-range \([-\infty,\infty)\) Gauss-Hermite quadrature used to compute probability density.

  • gl_order (int) – The number of quadrature points for the Gauss-Legendre quadrature used to compute the cumulative distribution.

Raises:

ValueError – Thrown if size is smaller than 3.

cdf(R)

The cumulative distribution function.

The monotonically increasing cumulative distribution function (CDF) \(G(R)\) is given by

\[G(R) = \int_0^R P(r)\,\mathrm{d}r, \quad \text{for}~0\leq r\leq 1\]
pdf(r)

Computes the probability density function (PDF) of the distribution.

\[P(x_i,x_{n-j},x_n) = \frac{n!}{(i-1)!(n-j-i-1)!(j-1)!} \left[ \int_{-\infty}^{x_i} \phi(t)\,\mathrm{d}t \right]^{i-1} \left[ \int_{x_i}^{x_{n-j}} \phi(t)\,\mathrm{d}t \right]^{n-j-i-1} \left[ \int_{x_{n-j}}^{x_n} \phi(t)\,\mathrm{d}t \right]^{j-1} \phi(x_i)\phi(x_{n-j})\phi(x_n)\]

where \(\phi(x)\) is the probability density function of the standard normal distribution defined as

\[\phi(x)= \frac{1}{\sqrt{2\pi}} \exp\left( -\frac{x^2}{2} \right)\]
Parameters:

r (array_like) – The \(r\) value.

Returns:

The PDF at the specified value.

Return type:

numpy.ndarray

ppf(q)

Computes percent point function value at the percentile q.

Percent point function (inverse of cdf). The critical values correspond to the roots of

\[q-G(R)=0\]
Parameters:

q – The percentile.

dixonstat.r10(size, **kwargs)

Returns the \(r_{10}\) range ratio statistic.

dixonstat.r11(size, **kwargs)

Returns the \(r_{11}\) range ratio statistic.

dixonstat.r12(size, **kwargs)

Returns the \(r_{12}\) range ratio statistic.

dixonstat.r20(size, **kwargs)

Returns the \(r_{20}\) range ratio statistic.

dixonstat.r21(size, **kwargs)

Returns the \(r_{21}\) range ratio statistic.

dixonstat.r22(size, **kwargs)

Returns the \(r_{22}\) range ratio statistic.

dixonstat.ratiotest(ratio, rvs, alpha=0.05, alternative='one-sided', **kwargs)

Perform Dixon’s ratio test.

If the statistic \(Q > p\), \(x_1\) is considered an outlier.

Parameters:
  • ratio (collections.abc.Callable, RangeRatio) – Dixon’s ratio statistic.

  • rvs (array) – 1-D array of observations of random variables.

  • alternative ({‘one-sided’, ‘two-sided’}, str) – one-sided for one-tailed test, two-sided for two-tailed test.

Returns:

  • statistic (float) – The ratio statistic.

  • p-value (float)