g01 Chapter Contents
g01 Chapter Introduction
NAG Library Manual

NAG Library Function Documentnag_prob_lin_non_central_chi_sq (g01jcc)

1  Purpose

nag_prob_lin_non_central_chi_sq (g01jcc) returns the lower tail probability of a distribution of a positive linear combination of ${\chi }^{2}$ random variables.

2  Specification

 #include #include
 void nag_prob_lin_non_central_chi_sq (const double a[], const Integer mult[], const double rlamda[], Integer n, double c, double *p, double *pdf, double tol, Integer maxit, NagError *fail)

3  Description

For a linear combination of noncentral ${\chi }^{2}$ random variables with integer degrees of freedom the lower tail probability is
 $P ∑j=1najχ2mj,λj≤c ,$ (1)
where ${a}_{j}$ and $c$ are positive constants and where ${\chi }^{2}\left({m}_{j},{\lambda }_{j}\right)$ represents an independent ${\chi }^{2}$ random variable with ${m}_{j}$ degrees of freedom and noncentrality argument ${\lambda }_{j}$. The linear combination may arise from considering a quadratic form in Normal variables.
Ruben's method as described in Farebrother (1984) is used. Ruben has shown that (1) may be expanded as an infinite series of the form
 $∑k=0∞dkF m+2k,c/β ,$ (2)
where $F\left(m+2k,c/\beta \right)=P\left({\chi }^{2}\left(m+2k\right), i.e., the probability that a central ${\chi }^{2}$ is less than $c/\beta$.
The value of $\beta$ is set at
 $β=βB=21/amin+1/amax$
unless ${\beta }_{B}>1.8{a}_{\mathrm{min}}$, in which case
 $β=βA=amin$
is used, where ${a}_{\mathrm{min}}=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left\{{a}_{j}\right\}$ and ${a}_{\mathrm{max}}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left\{{a}_{j}\right\}$, for $\mathit{j}=1,2,\dots ,n$.

4  References

Farebrother R W (1984) The distribution of a positive linear combination of ${\chi }^{2}$ random variables Appl. Statist. 33(3)

5  Arguments

1:    $\mathbf{a}\left[{\mathbf{n}}\right]$const doubleInput
On entry: the weights, ${a}_{1},{a}_{2},\dots ,{a}_{n}$.
Constraint: ${\mathbf{a}}\left[\mathit{i}\right]>0.0$, for $\mathit{i}=0,1,\dots ,n-1$.
2:    $\mathbf{mult}\left[{\mathbf{n}}\right]$const IntegerInput
On entry: the degrees of freedom, ${m}_{1},{m}_{2},\dots ,{m}_{n}$.
Constraint: ${\mathbf{mult}}\left[\mathit{i}\right]\ge 1$, for $\mathit{i}=0,1,\dots ,{\mathbf{n}}-1$.
3:    $\mathbf{rlamda}\left[{\mathbf{n}}\right]$const doubleInput
On entry: the noncentrality parameters, ${\lambda }_{1},{\lambda }_{2},\dots ,{\lambda }_{n}$.
Constraint: ${\mathbf{rlamda}}\left[\mathit{i}\right]\ge 0.0$, for $\mathit{i}=0,1,\dots ,n-1$.
4:    $\mathbf{n}$IntegerInput
On entry: $n$, the number of ${\chi }^{2}$ random variables in the combination, i.e., the number of terms in equation (1).
Constraint: ${\mathbf{n}}\ge 1$.
5:    $\mathbf{c}$doubleInput
On entry: $c$, the point for which the lower tail probability is to be evaluated.
Constraint: ${\mathbf{c}}\ge 0.0$.
6:    $\mathbf{p}$double *Output
On exit: the lower tail probability associated with the linear combination of $n$ ${\chi }^{2}$ random variables with ${m}_{\mathit{j}}$ degrees of freedom, and noncentrality arguments ${\lambda }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,n$.
7:    $\mathbf{pdf}$double *Output
On exit: the value of the probability density function of the linear combination of ${\chi }^{2}$ variables.
8:    $\mathbf{tol}$doubleInput
On entry: the relative accuracy required by you in the results. If nag_prob_lin_non_central_chi_sq (g01jcc) is entered with tol greater than or equal to $1.0$ or less than  (see nag_machine_precision (X02AJC)), then the value of  is used instead.
9:    $\mathbf{maxit}$IntegerInput
On entry: the maximum number of terms that should be used during the summation.
Suggested value: $500$.
Constraint: ${\mathbf{maxit}}\ge 1$.
10:  $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ACCURACY
The required accuracy could not be met in $〈\mathit{\text{value}}〉$ iterations.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.2.1.2 in the Essential Introduction for further information.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_CONVERGENCE
The central Chi square has failed to converge.
NE_INT
On entry, ${\mathbf{maxit}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{maxit}}\ge 1$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
NE_INT_ARRAY
On entry, mult has an $\text{element}<1$: ${\mathbf{mult}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 3.6.6 in the Essential Introduction for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 3.6.5 in the Essential Introduction for further information.
NE_PROB_BOUNDARY
Calculated probability at boundary.
NE_REAL
On entry, ${\mathbf{c}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{c}}\ge 0.0$.
NE_REAL_ARRAY
On entry, a has an $\text{element}\le 0.0$: ${\mathbf{a}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$.
On entry, rlamda has an $\text{element}<0.0$: ${\mathbf{rlamda}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$.

7  Accuracy

The series (2) is summed until a bound on the truncation error is less than tol. See Farebrother (1984) for further discussion.

Not applicable.

None.

10  Example

The number of ${\chi }^{2}$ variables is read along with their coefficients, degrees of freedom and noncentrality arguments. The lower tail probability is then computed and printed.

10.1  Program Text

Program Text (g01jcce.c)

10.2  Program Data

Program Data (g01jcce.d)

10.3  Program Results

Program Results (g01jcce.r)