nonCentralChiSq

Evaluates the noncentral chi-squared distribution function.

Synopsis

nonCentralChiSq (chiSquared, df delta)

Required Arguments

float chiSquared (Input)
Argument for which the noncentral chi-squared distribution function is to be evaluated.
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 chiSquared.

Description

Function nonCentralChiSq evaluates the distribution function of a noncentral chi-squared random variable with df degrees of freedom and noncentrality parameter alam, that is, with v = df, λ = alam, and x = chiSquared,

\[F(x|\nu, \lambda) = \sum_{i=0}^{\infty} \frac{e^{-\lambda/2}(\lambda/2)^i}{i!} \int_{0}^{x}\frac{t^{(v+2i)/2-1}e^{-t/2}}{2^{(v+2i)/2} \mathit{\Gamma}\left(\frac{v+2i}{2}\right)}dt\]

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 noncentral 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 \(Y_i\) have independent normal distributions with means \(\mu_i\) and variances equal to one and

\[X = \sum_{i=1}^{n} Y_i^2\]

then X has a noncentral chi-squared distribution with n degrees of freedom and noncentrality parameter equal to

\[\sum_{i=1}^{n} \mu_i^2\]

With a noncentrality parameter of zero, the noncentral chi-squared distribution is the same as the chi-squared distribution.

Function nonCentralChiSq 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.

../../_images/csch11-figure5.png

Figure 11.5 — Noncentral Chi-squared Distribution Function

Example

In this example, nonCentralChiSq is used to compute the probability that a random variable that follows the noncentral chi-squared distribution with noncentrality parameter of 1 and with 2 degrees of freedom is less than or equal to 8.642.

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

chsq = 8.642
df = 2.0
alam = 1.0
p = nonCentralChiSq(chsq, df, alam)
print("The probability that a noncentral chi-squared random")
print("variable with %2.0f df and noncentrality parameter %3.1f is less" % (df, alam))
print("than %5.3f is %5.3f." % (chsq, p))

Output

The probability that a noncentral chi-squared random
variable with  2 df and noncentrality parameter 1.0 is less
than 8.642 is 0.950.