# 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);