﻿ g01jd Method
g01jd calculates the lower tail probability for a linear combination of (central) ${\chi }^{2}$ variables.

Syntax

C#
```public static void g01jd(
string method,
int n,
double[] rlam,
double d,
double c,
out double prob,
out int ifail
)```
Visual Basic
```Public Shared Sub g01jd ( _
method As String, _
n As Integer, _
rlam As Double(), _
d As Double, _
c As Double, _
<OutAttribute> ByRef prob As Double, _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g01jd(
String^ method,
int n,
array<double>^ rlam,
double d,
double c,
[OutAttribute] double% prob,
[OutAttribute] int% ifail
)```
F#
```static member g01jd :
method : string *
n : int *
rlam : float[] *
d : float *
c : float *
prob : float byref *
ifail : int byref -> unit
```

Parameters

method
Type: System..::..String
On entry: indicates whether Pan's, Imhof's or an appropriately selected procedure is to be used.
${\mathbf{method}}=\text{"P"}$
Pan's method is used.
${\mathbf{method}}=\text{"I"}$
Imhof's method is used.
${\mathbf{method}}=\text{"D"}$
Pan's method is used if ${\lambda }_{\mathit{i}}^{*}$, for $\mathit{i}=1,2,\dots ,n$ are at least $1%$ distinct and $n\le 60$; otherwise Imhof's method is used.
Constraint: ${\mathbf{method}}=\text{"P"}$, $\text{"I"}$ or $\text{"D"}$.
n
Type: System..::..Int32
On entry: $n$, the number of independent standard Normal variates, (central ${\chi }^{2}$ variates).
Constraint: ${\mathbf{n}}\ge 1$.
rlam
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: the weights, ${\lambda }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$, of the central ${\chi }^{2}$ variables.
Constraint: ${\mathbf{rlam}}\left[\mathit{i}-1\right]\ne {\mathbf{d}}$ for at least one $\mathit{i}$. If ${\mathbf{method}}=\text{"P"}$, then the ${\lambda }_{\mathit{i}}^{*}$ must be at least $1%$ distinct; see [Further Comments], for $\mathit{i}=1,2,\dots ,n$.
d
Type: System..::..Double
On entry: $d$, the multiplier of the central ${\chi }^{2}$ variables.
Constraint: ${\mathbf{d}}\ge 0.0$.
c
Type: System..::..Double
On entry: $c$, the value of the constant.
prob
Type: System..::..Double%
On exit: the lower tail probability for the linear combination of central ${\chi }^{2}$ variables.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

Let ${u}_{1},{u}_{2},\dots ,{u}_{n}$ be independent Normal variables with mean zero and unit variance, so that ${u}_{1}^{2},{u}_{2}^{2},\dots ,{u}_{n}^{2}$ have independent ${\chi }^{2}$-distributions with unit degrees of freedom. g01jd evaluates the probability that
 $λ1u12+λ2u22+⋯+λnun2
If $c=0.0$ this is equivalent to the probability that
 $λ1u12+λ2u22+⋯+λnun2u12+u22+⋯+un2
Alternatively let
 $λi*=λi-d, ​i=1,2,…,n,$
then g01jd returns the probability that
 $λ1*u12+λ2*u22+⋯+λn*un2
Two methods are available. One due to Pan (1964) (see Farebrother (1980)) makes use of series approximations. The other method due to Imhof (1961) reduces the problem to a one-dimensional integral. If $n\ge 6$ then a non-adaptive method described in d01bd is used to compute the value of the integral otherwise d01aj is used.
Pan's procedure can only be used if the ${\lambda }_{i}^{*}$ are sufficiently distinct; g01jd requires the ${\lambda }_{i}^{*}$ to be at least $1%$ distinct; see [Further Comments]. If the ${\lambda }_{i}^{*}$ are at least $1%$ distinct and $n\le 60$, then Pan's procedure is recommended; otherwise Imhof's procedure is recommended.

References

Farebrother R W (1980) Algorithm AS 153. Pan's procedure for the tail probabilities of the Durbin–Watson statistic Appl. Statist. 29 224–227
Imhof J P (1961) Computing the distribution of quadratic forms in Normal variables Biometrika 48 419–426
Pan Jie–Jian (1964) Distributions of the noncircular serial correlation coefficients Shuxue Jinzhan 7 328–337

Error Indicators and Warnings

Errors or warnings detected by the method:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{n}}<1$, or ${\mathbf{d}}<0.0$, or ${\mathbf{method}}\ne \text{"P"}$, $\text{"I"}$ or $\text{"D"}$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{rlam}}\left[\mathit{i}-1\right]={\mathbf{d}}$ for all values of $\mathit{i}$, for $\mathit{i}=1,2,\dots ,n$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{method}}=\text{"P"}$ yet two successive values of the ordered ${\lambda }_{\mathit{i}}^{*}$, for $\mathit{i}=1,2,\dots ,n$, were not at least $1%$ distinct.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

Accuracy

On successful exit at least four decimal places of accuracy should be achieved.

Parallelism and Performance

None.

Pan's procedure can only work if the ${\lambda }_{i}^{*}$ are sufficiently distinct. g01jd uses the check $\left|{w}_{j}-{w}_{j-1}\right|\ge 0.01×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(\left|{w}_{j}\right|,\left|{w}_{j-1}\right|\right)$, where the ${w}_{j}$ are the ordered nonzero values of ${\lambda }_{i}^{*}$.
For the situation when all the ${\lambda }_{i}$ are positive g01jc may be used. If the probabilities required are for the Durbin–Watson test, then the bounds for the probabilities are given by g01ep.

Example

For $n=10$, the choice of method, values of $c$ and $d$ and the ${\lambda }_{i}$ are input and the probabilities computed and printed.

Example program (C#): g01jde.cs

Example program data: g01jde.d

Example program results: g01jde.r