CHISQCDF Function
Evaluates the chi-squared distribution or noncentral chi-squared distribution. Using a keyword the inverse of these distributions can be computed.
Usage
result = CHISQCDF(chisq, df[, delta])
Input Parameters
chisq—Expression for which the chi-squared distribution function is to be evaluated.
df—Number of degrees of freedom of the chi-squared distribution. Argument df must be greater than or equal to 0.5.
delta—(Optional) The noncentrality parameter. delta must be nonnegative, and delta + df must be less than or equal to 200,000.
Returned Value
result—The probability that a chi-squared random variable takes a value less than or equal to chisq.
Input Keywords
Double—If present and nonzero, double precision is used.
Inverse—If present and nonzero, evaluates the inverse of the chi-squared distribution function. If inverse is specified, then argument chisq represents the probability for which the inverse of the chi-squared distribution function is to be evaluated. Argument chisq must be in the open interval (0.0, 1.0).
Discussion
If Two Input Arguments Are Used
Function CHISQCDF evaluates the distribution function, F, of a chi-squared random variable with ν = df. Then:
where Γ(·) is the gamma function. The value of the distribution function at the point x is the probability that the random variable takes a value less than or equal to x.
For ν > 65, CHISQCDF uses the Wilson-Hilferty approximation (Abramowitz and Stegun 1964, Equation 26.4.17) to the normal distribution, and NORMALCDF function is used to evaluate the normal distribution function.
For ν ≤  65, CHISQCDF uses series expansions to evaluate the distribution function. If x < max(ν/2, 26), CHISQCDF uses the series 6.5.29 in Abramowitz and Stegun (1964); otherwise, it uses the asymptotic expansion 6.5.32 in Abramowitz and Stegun.
If Inverse is specified, the CHISQCDF function evaluates the inverse distribution function of a chi-squared random variable with ν = df and with probability p. That is, it determines x, such that:
where Γ(·) is the gamma function. The probability that the random variable takes a value less than or equal to x is p.
For ν < 40, CHISQCDF uses bisection (if ν   2 or p > 0.98) or regula falsi to find the expression for which the chi-squared distribution function is equal to p.
For 40  ν < 100, a modified Wilson-Hilferty approximation (Abramowitz and Stegun 1964, Equation 26.4.18) to the normal distribution is used. The NORMALCDF function is used to evaluate the inverse of the normal distribution function. For ν ≥ 100, the ordinary Wilson-Hilferty approximation (Abramowitz and Stegun 1964, Equation 26.4.17) is used.
If Three Input Arguments Are Used
Function CHISQCDF evaluates the distribution function of a noncentral chi-squared random variable with df degrees of freedom and noncentrality parameter alam, that is, with v = df, λ = alam, and x = chi_squared:
where Γ(·) is the gamma function. This is a series of central chi-squared distribution functions with Poisson weights. The value of the distribution function at the point x is the probability that the random variable takes a value less than or equal to x.
The noncentral chi-squared random variable can be defined by the distribution function above, or alternatively and equivalently, as the sum of squares of independent normal random variables. If Yi have independent normal distributions with means μi and variances equal to one and:
then X has a noncentral chi-squared distribution with n degrees of freedom and noncentrality parameter equal to:
With a noncentrality parameter of zero, the noncentral chi-squared distribution is the same as the chi-squared distribution.
Function CHISQCDF determines the point at which the Poisson weight is greatest, and then sums forward and backward from that point, terminating when the additional terms are sufficiently small or when a maximum of 1000 terms have been accumulated. The recurrence relation 26.4.8 of Abramowitz and Stegun (1964) is used to speed the evaluation of the central chi-squared distribution functions.
If Inverse is specified, CHISQCDF evaluates the inverse distribution function of a noncentral chi-squared random variable with df degrees of freedom and noncentrality parameter delta; that is, with P = p, v = df, and λ = delta, it determines c0 (= CHISQCDF(p, df, delta)), such that:
where Γ(·) is the gamma function. The probability that the random variable takes a value less than or equal to c0 is P.
Example
Suppose X is a chi-squared random variable with two degrees of freedom. This example finds the probability that X is less than 0.15 and the probability that X is greater than 3.0.
df = 2
chisq = .15
p = CHISQCDF(chisq, df)
PM, p, Title = 'The probability that chi-squared ' + $
   'with 2 df is less than .15 is:' 
; PV-WAVE prints the following:
; The probability that chi-squared with 2 df is less than .15 is:
; 0.0722565
df = 2
chisq = 3
p = 1 - CHISQCDF(chisq, df)
PM, p, Title = 'The probability that chi-squared ' + $
   'with 2 df is greater than 3 is:'
; PV-WAVE prints the following:
; The probability that chi-squared with 2 df is greater than 3
; is: 0.223130
Informational Errors
STAT_ARG_LESS_THAN_ZERO—Input parameter, chisq, is less than zero.
STAT_UNABLE_TO_BRACKET_VALUE—Bounds that enclose p could not be found. An approximation for CHISQCDF is returned.
STAT_CHI_2_INV_CDF_CONVERGENCE—Value of the inverse chi-squared could not be found within a specified number of iterations. An approximation for CHISQCDF is returned.
Alert Errors
STAT_NORMAL_UNDERFLOW—Using the normal distribution for large degrees of freedom, underflow would have occurred.