The IMSL_CHISQCDF function evaluates the chi-squared distribution or non-central chi-squared distribution. Using a keyword the inverse of these distributions can be computed.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

If Two Input Arguments Are Used

The IMSL_CHISQCDF function 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, IMSL_CHISQCDF uses the Wilson-Hilferty approximation (Abramowitz and Stegun 1964, Equation 26.4.17) to the normal distribution, and IMSL_NORMALCDF function is used to evaluate the normal distribution function.

For ν ≤ 65, IMSL_CHISQCDF uses series expansions to evaluate the distribution function. If x < max(ν / 2, 26), IMSL_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 INVERSEis specified, the IMSL_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, IMSL_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 IMSL_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

The IMSL_CHISQCDF function evaluates the distribution function of a non-central chi-squared random variable with df degrees of freedom and non-centrality parameter delta, that is, with v = df, λ = delta, and x = chisq:

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 non-central 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 non-central chi-squared distribution with n degrees of freedom and non-centrality parameter equal to:

With a non-centrality parameter of zero, the non-central chi-squared distribution is the same as the chi-squared distribution.

The IMSL_CHISQCDF function 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, IMSL_CHISQCDF evaluates the inverse distribution function of a non-central chi-squared random variable with df degrees of freedom and non-centrality parameter delta; that is, with P = chisq, v = df, and λ = delta, it determines c0 (= IMSL_CHISQCDF(chisq, 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.

Examples


Example 1

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 = IMSL_CHISQCDF(chisq, df)
PM, p, Title = 'The probability that chi-squared with 2 df ' + $
  'is less than .15 is:'

IDL prints:

The probability that chi-squared with 2 df is less than .15 is:
0.0722565
 
df = 2
chisq = 3
p = 1 - IMSL_CHISQCDF(chisq, df)
PM, p, Title = 'The probability that chi-squared ' + $
  'with 2 df is greater than 3 is:'

IDL prints:

The probability that chi-squared with 2 df is greater than 3 is:
0.223130

Syntax


Result = IMSL_CHISQCDF(Chisq, Df [, Delta] [, /DOUBLE] [, /INVERSE])

Return Value


The probability that a chi-squared random variable takes a value less than or equal to chisq.

Arguments


Chisq

Expression for which the chi-squared distribution function is to be evaluated. If the keyword INVERSE is specified, the probability for which the inverse of the non-central, chi-squared distribution function is to be evaluated, the parameter chisq must be in the open interval (0.0, 1.0).

Delta

(Optional) The non-centrality parameter. delta must be nonnegative, and delta + df must be less than or equal to 200,000.

Df

Number of degrees of freedom of the chi-squared distribution. Argument df must be greater than or equal to 0.5.

Keywords


DOUBLE (optional)

If present and nonzero, double precision is used.

INVERSE (optional)

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. Parameter chisq must be in the open interval (0.0, 1.0).

Errors


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 IMSL_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 IMSL_CHISQCDF is returned.

Alert Errors

STAT_NORMAL_UNDERFLOW: Using the normal distribution for large degrees of freedom, underflow would have occurred.

Version History


6.4

Introduced