G01JDF (PDF version)
G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG01JDF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

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

## 2  Specification

 SUBROUTINE G01JDF ( METHOD, N, RLAM, D, C, PROB, WORK, IFAIL)
 INTEGER N, IFAIL REAL (KIND=nag_wp) RLAM(N), D, C, PROB, WORK(N+1) CHARACTER(1) METHOD

## 3  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. G01JDF evaluates the probability that
 $λ1u12+λ2u22+⋯+λnun2
If $c=0.0$ this is equivalent to the probability that
 $λ1u12+λ2u22+⋯+λnun2 u12+u22+⋯+un2
Alternatively let
 $λi*=λi-d, ​ i= 1,2,…,n,$
then G01JDF 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 D01BDF is used to compute the value of the integral otherwise D01AJF is used.
Pan's procedure can only be used if the ${\lambda }_{i}^{*}$ are sufficiently distinct; G01JDF requires the ${\lambda }_{i}^{*}$ to be at least $1%$ distinct; see Section 9. 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.
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

## 5  Parameters

1:     $\mathrm{METHOD}$ – CHARACTER(1)Input
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'}$.
2:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the number of independent standard Normal variates, (central ${\chi }^{2}$ variates).
Constraint: ${\mathbf{N}}\ge 1$.
3:     $\mathrm{RLAM}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput
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}\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 Section 9, for $\mathit{i}=1,2,\dots ,n$.
4:     $\mathrm{D}$ – REAL (KIND=nag_wp)Input
On entry: $d$, the multiplier of the central ${\chi }^{2}$ variables.
Constraint: ${\mathbf{D}}\ge 0.0$.
5:     $\mathrm{C}$ – REAL (KIND=nag_wp)Input
On entry: $c$, the value of the constant.
6:     $\mathrm{PROB}$ – REAL (KIND=nag_wp)Output
On exit: the lower tail probability for the linear combination of central ${\chi }^{2}$ variables.
7:     $\mathrm{WORK}\left({\mathbf{N}}+1\right)$ – REAL (KIND=nag_wp) arrayWorkspace
8:     $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\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}\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}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

## 7  Accuracy

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

## 8  Parallelism and Performance

G01JDF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

## 9  Further Comments

Pan's procedure can only work if the ${\lambda }_{i}^{*}$ are sufficiently distinct. G01JDF 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 G01JCF may be used. If the probabilities required are for the Durbin–Watson test, then the bounds for the probabilities are given by G01EPF.

## 10  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.

### 10.1  Program Text

Program Text (g01jdfe.f90)

### 10.2  Program Data

Program Data (g01jdfe.d)

### 10.3  Program Results

Program Results (g01jdfe.r)

G01JDF (PDF version)
G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual