chiSquaredInverseCdf¶
Evaluates the inverse of the chi‑squared distribution function.
Synopsis¶
chiSquaredInverseCdf (p, df)
Required Arguments¶
- float
p(Input) - Probability for which the inverse of the chi‑squared distribution
function is to be evaluated. The argument
pmust be in the open interval (0.0, 1.0). - float
df(Input) - Number of degrees of freedom of the chi‑squared distribution. The
argument
dfmust 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 chiSquaredInverseCdf is p.
Description¶
The function chiSquaredInverseCdf evaluates the inverse distribution
function of a chi‑squared random variable with ν = df and with
probability p. That is, it determines x =
chiSquaredInverseCdf(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, chiSquaredInverseCdf 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 chiSquaredCdf.
For 40 ≤ ν < 100, a modified Wilson-Hilferty approximation (Abramowitz and
Stegun 1964, equation 26.4.18) to the normal distribution is used. The
function normalCdf 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.
from __future__ import print_function
from numpy import *
from pyimsl.math.chiSquaredInverseCdf import chiSquaredInverseCdf
p = 0.99
df = 2.0
x = chiSquaredInverseCdf(p, df)
print("For p = .99 with 2 df, x = %7.3f" % (x))
df = 64.0
x = chiSquaredInverseCdf(p, df)
print("For p = .99 with 64 df, x = %7.3f" % (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
chiSquaredInverseCdf is
returned. |