chi_squared_inverse_cdf
Evaluates the inverse of the chi‑squared distribution function.
Synopsis
#include <imsl.h>
float imsl_f_chi_squared_inverse_cdf (float p, float df)
The type double function is imsl_d_chi_squared_inverse_cdf.
Required Arguments
float p (Input)
Probability for which the inverse of the chi‑squared distribution function is to be evaluated. The argument p must be in the open interval (0.0, 1.0).
float df (Input)
Number of degrees of freedom of the chi‑squared distribution. The argument df must be greater than 0.
Return Value
The inverse of the chi‑squared distribution function evaluated at p. The probability that a chi‑squared random variable takes a value less than or equal to imsl_f_chi_squared_inverse_cdf is p.
Description
The function imsl_f_chi_squared_inverse_cdf evaluates the inverse distribution function of a chi‑squared random variable with ν = df and with probability p. That is, it determines x = imsl_f_chi_squared_inverse_cdf(p,df) 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_f_chi_squared_inverse_cdf uses bisection (if ν ≤ 2 or p > 0.98) or regula falsi to find the point at which the chi‑squared distribution function is equal to p. The distribution function is evaluated using function imsl_f_chi_squared_cdf.
For 40 ≤ ν < 100, a modified Wilson-Hilferty approximation (Abramowitz and Stegun 1964, equation 26.4.18) to the normal distribution is used. The function imsl_f_normal_cdf 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.
Example
In this example, the 99-th percentage point is calculated for a chi‑squared random variable with two degrees of freedom. The same calculation is made for a similar variable with 64 degrees of freedom.
#include <imsl.h>
#include <stdio.h>
int main ()
{
float df, x;
float p = 0.99;
df = 2.0;
x = imsl_f_chi_squared_inverse_cdf(p, df);
printf("For p = .99 with 2 df, x = %7.3f.\n", x);
df = 64.0;
x = imsl_f_chi_squared_inverse_cdf(p,df);
printf("For p = .99 with 64 df, x = %7.3f.\n", x);
}
Output
For p = .99 with 2 df, x = 9.210.
For p = .99 with 64 df, x = 93.217.
Warning Errors
IMSL_UNABLE_TO_BRACKET_VALUE2 |
Unable to bracket the value of the inverse chi-squared at "p" = #, with "df" = #. |
IMSL_CHI_2_INV_CDF_CONVERGENCE |
The value of the inverse chi‑squared could not be found within a specified number of iterations. An approximation for imsl_f_chi_squared_inverse_cdf is returned. |