Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_stat_prob_chisq_noncentral_lincomb (g01jc)

## Purpose

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

## Syntax

[p, pdf, ifail] = g01jc(a, mult, rlamda, c, 'n', n, 'tol', tol, 'maxit', maxit)
[p, pdf, ifail] = nag_stat_prob_chisq_noncentral_lincomb(a, mult, rlamda, c, 'n', n, 'tol', tol, 'maxit', maxit)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: tol now optional (default 0)
.

## Description

For a linear combination of noncentral χ2${\chi }^{2}$ random variables with integer degrees of freedom the lower tail probability is
P
 ( n ) ∑ ajχ2(mj,λj) ≤ c j = 1
,
$P (∑j=1najχ2(mj,λj)≤c) ,$
(1)
where aj${a}_{j}$ and c$c$ are positive constants and where χ2(mj,λj)${\chi }^{2}\left({m}_{j},{\lambda }_{j}\right)$ represents an independent χ2${\chi }^{2}$ random variable with mj${m}_{j}$ degrees of freedom and noncentrality parameter λj${\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
 ∞ ∑ dkF(m + 2k,c / β), k = 0
$∑k=0∞dkF (m+2k,c/β) ,$
(2)
where F (m + 2k,c / β) = P (χ2(m + 2k) < c / β) $F\left(m+2k,c/\beta \right)=P\left({\chi }^{2}\left(m+2k\right), i.e., the probability that a central χ2${\chi }^{2}$ is less than c / β$c/\beta$.
The value of β$\beta$ is set at
 β = βB = 2/( (1 / amin + 1 / amax) ) $β=βB=2(1/amin+1/amax)$
unless βB > 1.8amin${\beta }_{B}>1.8{a}_{\mathrm{min}}$, in which case
 β = βA = amin $β=βA=amin$
is used, where amin = min {aj}${a}_{\mathrm{min}}=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left\{{a}_{j}\right\}$ and amax = max {aj}${a}_{\mathrm{max}}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left\{{a}_{j}\right\}$, for j = 1,2,,n$\mathit{j}=1,2,\dots ,n$.

## References

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

## Parameters

### Compulsory Input Parameters

1:     a(n) – double array
n, the dimension of the array, must satisfy the constraint n1${\mathbf{n}}\ge 1$.
The weights, a1,a2,,an${a}_{1},{a}_{2},\dots ,{a}_{n}$.
Constraint: a(i) > 0.0${\mathbf{a}}\left(\mathit{i}\right)>0.0$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,n$.
2:     mult(n) – int64int32nag_int array
n, the dimension of the array, must satisfy the constraint n1${\mathbf{n}}\ge 1$.
The degrees of freedom, m1,m2,,mn${m}_{1},{m}_{2},\dots ,{m}_{n}$.
Constraint: mult(i)1${\mathbf{mult}}\left(\mathit{i}\right)\ge 1$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
3:     rlamda(n) – double array
n, the dimension of the array, must satisfy the constraint n1${\mathbf{n}}\ge 1$.
The noncentrality parameters, λ1,λ2,,λn${\lambda }_{1},{\lambda }_{2},\dots ,{\lambda }_{n}$.
Constraint: rlamda(i)0.0${\mathbf{rlamda}}\left(\mathit{i}\right)\ge 0.0$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,n$.
4:     c – double scalar
c$c$, the point for which the lower tail probability is to be evaluated.
Constraint: c0.0${\mathbf{c}}\ge 0.0$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the arrays a, mult, rlamda. (An error is raised if these dimensions are not equal.)
n$n$, the number of χ2${\chi }^{2}$ random variables in the combination, i.e., the number of terms in equation (1).
Constraint: n1${\mathbf{n}}\ge 1$.
2:     tol – double scalar
The relative accuracy required by you in the results. If nag_stat_prob_chisq_noncentral_lincomb (g01jc) is entered with tol greater than or equal to 1.0$1.0$ or less than 10 × machine precision (see nag_machine_precision (x02aj)), then the value of 10 × machine precision is used instead.
Default: 0$0$
3:     maxit – int64int32nag_int scalar
The maximum number of terms that should be used during the summation.
Default: 500$500$.
Constraint: maxit1${\mathbf{maxit}}\ge 1$.

wrk

### Output Parameters

1:     p – double scalar
The lower tail probability associated with the linear combination of n$n$ χ2${\chi }^{2}$ random variables with mj${m}_{\mathit{j}}$ degrees of freedom, and noncentrality parameters λj${\lambda }_{\mathit{j}}$, for j = 1,2,,n$\mathit{j}=1,2,\dots ,n$.
2:     pdf – double scalar
The value of the probability density function of the linear combination of χ2${\chi }^{2}$ variables.
3:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Note: nag_stat_prob_chisq_noncentral_lincomb (g01jc) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
If on exit ${\mathbf{ifail}}={\mathbf{1}}$ or 2${\mathbf{2}}$, then nag_stat_prob_chisq_noncentral_lincomb (g01jc) returns 0.0$0.0$.

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

ifail = 1${\mathbf{ifail}}=1$
 On entry, n < 1${\mathbf{n}}<1$, or maxit < 1${\mathbf{maxit}}<1$, or c < 0.0${\mathbf{c}}<0.0$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, a has an element ≤ 0.0$\text{}\le 0.0$, or mult has an element < 1$\text{}<1$, or rlamda has an element < 0.0$\text{}<0.0$.
ifail = 3${\mathbf{ifail}}=3$
The central χ2${\chi }^{2}$ calculation has failed to converge. This is an unlikely exit. A larger value of tol should be tried.
W ifail = 4${\mathbf{ifail}}=4$
The solution has failed to converge within maxit iterations. A larger value of maxit or tol should be used. The returned value should be a reasonable approximation to the correct value.
W ifail = 5${\mathbf{ifail}}=5$
The solution appears to be too close to 0$0$ or 1$1$ for accurate calculation. The value returned is 0$0$ or 1$1$ as appropriate.

## Accuracy

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

None.

## Example

```function nag_stat_prob_chisq_noncentral_lincomb_example
a = [6;
3;
1];
mult = [int64(1);1;1];
rlamda = [0;
0;
0];
c = 20;
[p, pdf, ifail] = nag_stat_prob_chisq_noncentral_lincomb(a, mult, rlamda, c)
```
```

p =

0.8760

pdf =

0.0129

ifail =

0

```
```function g01jc_example
a = [6;
3;
1];
mult = [int64(1);1;1];
rlamda = [0;
0;
0];
c = 20;
[p, pdf, ifail] = g01jc(a, mult, rlamda, c)
```
```

p =

0.8760

pdf =

0.0129

ifail =

0

```