cdfChic

Purpose

Computes the complement of the cdf of the chi-squared distribution.

Format

p = cdfChic(x, df)
Parameters:
  • x (NxK matrix.) – Values at which to evaluate the complement of the chi-squared cdf. \(x > 0\)
  • df (LxM matrix) – ExE conformable with x, degrees of freedom. \(df > 0\)
Returns:

p (matrix, max(N,L) by max(K,M)) – Each element in p is the complement of the chi-squared cdf value evaluated at the corresponding element in x.

Examples

// Vector of values
x = { .1, .2, .3, .4 };

// Degrees of freedom
df = 3;

// Call cdfChic
p = cdfChic(x, n);
print "p = " p;

After running the above code,

p =
  0.9918
  0.9776
  0.9600
  0.9402

Remarks

A -1 is returned for those elements with invalid inputs.

This equals \(1 - Χ_{df}^2(x)\), Thus, to get the chi-squared cdf, subtract cdfChic(x, df) from 1. The complement of the cdf is computed because this is what is most commonly needed in statistical applications and it can be computed with fewer problems of roundoff error.

Technical Notes

For \(n \leq 1000\), the incomplete gamma function is used and the absolute error is approx. \(\pm6e-13\).

For \(n \gt 1000\), a Normal approximation is used and the absolute error is \(\pm2e-8\).

For higher accuracy when \(n \gt 1000\), use:

1 - cdfGam(0.5*x, 0.5*n);

References

  1. Bhattacharjee, G.P. “Algorithm AS 32, the Incomplete Gamma Integral.” Applied Statistics. Vol. 19, 1970, 285-87.
  2. Mardia K.V. and P.J. Zemroch. Tables of the F- and related distributions with algorithms. Academic Press, New York, 1978. ISBN 0-12-471140-5.
  3. Peizer, D.B. and J.W. Pratt. “A Normal Approximation for Binomial, F, Beta, and other Common, Related Tail Probabilities, I.” Journal of the American Statistical Association. Vol. 63, Dec. 1968, 1416-56.

See also

Functions cdfBeta(), cdfFc(), cdfNc(), cdfTc(), gamma()