nonCentralChiSqInv

Evaluates the inverse of the noncentral chi-squared function.

Synopsis

nonCentralChiSqInv (p, df, delta)

Required Arguments

float p (Input)
Probability for which the inverse of the noncentral chi-squared distribution function is to be evaluated. p must be in the open interval (0.0, 1.0).

float df (Input)Number of degrees of freedom of the noncentral chi-squared distribution. Argument df must be greater than 0.

float delta (Input)
The noncentrality parameter. delta must be nonnegative, and delta + df must be less than or equal to 200,000.

Return Value

The probability that a noncentral chi-squared random variable takes a value less than or equal to nonCentralChiSqInv is p.

Description

Function nonCentralChiSqInv 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 \(c_0\) (= nonCentralChiSqInv (p, df, delta)), such that

\[P = \sum_{i=0}^{\infty} \frac{e^{-\lambda/2} (\lambda/2)^i}{i!} \int_{0}^{c_0} \frac {x^{(v+2i)/2-1} e^{-x/2}} {2^{(v+2i)/2} \mathit{\Gamma}\left(\frac{v+2i}{2}\right)}dx\]

where Γ (⋅) is the gamma function. In other words:

\[F^{-1} (P|\mathit{df},\mathit{delta}) = x\]

The probability that the random variable takes a value less than or equal to \(c_0\) is P.

Function nonCentralChiSqInv uses bisection and modified regula falsi to invert the distribution function, which is evaluated using function nonCentralChiSq. See nonCentralChiSq for an alternative definition of the noncentral chi-squared random variable in terms of normal random variables.

Example

In this example, we find the 95-th percentage point for a noncentral chi-squared random variable with 2 degrees of freedom and noncentrality parameter 1.

from __future__ import print_function
from numpy import *
from pyimsl.stat.nonCentralChiSqInv import nonCentralChiSqInv

p = 0.95
df = 2.0
delta = 1.0
chi_squared = nonCentralChiSqInv(p, df, delta)
print("The 0.05 noncentral chi-squared critical value is %6.4f." % chi_squared)

Output

The 0.05 noncentral chi-squared critical value is 8.6422.