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. 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. Argument
df
must be greater than 0.
Return Value¶
The inverse at 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¶
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 PyIMSL function chiSquaredCdf.
For 40 ≤ ν < 100, a modified Wilson-Hilferty approximation (Abramowitz and Stegun 1964, Equation 26.4.18) to the normal distribution is used. PyIMSL 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, we find the 99-th percentage point of a chi-squared random variable with 2 degrees of freedom and of one with 64 degrees of freedom.
from __future__ import print_function
from numpy import *
from pyimsl.stat.chiSquaredInverseCdf import chiSquaredInverseCdf
df = 2.0
p = 0.99
x1 = chiSquaredInverseCdf(p, df)
print("For p = .99 with 2 df, x = %7.3f." % x1)
df = 64.0
x2 = chiSquaredInverseCdf(p, df)
print("For p = .99 with 64 df, x = %7.3f." % x2)
Output¶
For p = .99 with 2 df, x = 9.210.
For p = .99 with 64 df, x = 93.217.
Warning Errors¶
IMSLS_UNABLE_TO_BRACKET_VALUE |
The bounds that enclose
“p ” could not be found.
An approximation for
chiSquaredInverseCdf is
returned. |
IMSLS_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. |