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

NAG Library Routine Document

G01GCF

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.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

G01GCF returns the probability associated with the lower tail of the noncentral χ2-distribution via the routine name.

2  Specification

FUNCTION G01GCF ( X, DF, RLAMDA, TOL, MAXIT, IFAIL)
REAL (KIND=nag_wp) G01GCF
INTEGER  MAXIT, IFAIL
REAL (KIND=nag_wp)  X, DF, RLAMDA, TOL

3  Description

The lower tail probability of the noncentral χ2-distribution with ν degrees of freedom and noncentrality parameter λ, PXx:ν;λ, is defined by
PXx:ν;λ=j=0e-λ/2λ/2jj! PXx:ν+2j;0, (1)
where PXx:ν+2j;0 is a central χ2-distribution with ν+2j degrees of freedom.
The value of j at which the Poisson weight, e-λ/2 λ/2jj! , is greatest is determined and the summation (1) is made forward and backward from that value of j.
The recursive relationship:
PXx:a+2;0=PXx:a;0-xa/2e-x/2 Γa+1 (2)
is used during the summation in (1).

4  References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications

5  Parameters

1:     X – REAL (KIND=nag_wp)Input
On entry: the deviate from the noncentral χ2-distribution with ν degrees of freedom and noncentrality parameter λ.
Constraint: X0.0.
2:     DF – REAL (KIND=nag_wp)Input
On entry: ν, the degrees of freedom of the noncentral χ2-distribution.
Constraint: DF0.0.
3:     RLAMDA – REAL (KIND=nag_wp)Input
On entry: λ, the noncentrality parameter of the noncentral χ2-distribution.
Constraint: RLAMDA0.0 if DF>0.0 or RLAMDA>0.0 if DF=0.0.
4:     TOL – REAL (KIND=nag_wp)Input
On entry: the required accuracy of the solution. If G01GCF is entered with TOL greater than or equal to 1.0 or less than 10×machine precision (see X02AJF), then the value of 10×machine precision is used instead.
5:     MAXIT – INTEGERInput
On entry: the maximum number of iterations to be performed.
Suggested value: 100. See Section 9 for further discussion.
Constraint: MAXIT1.
6:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ 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​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if IFAIL0 on exit, the recommended value is -1. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Note: G01GCF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
If on exit IFAIL=1, 2, 4 or 5, then G01GCF returns 0.0.
IFAIL=1
On entry,DF<0.0,
orRLAMDA<0.0,
orDF=0.0 and RLAMDA=0.0,
orX<0.0,
orMAXIT<1.
IFAIL=2
The initial value of the Poisson weight used in the summation (1) was too small to be calculated. The value of PXx:ν;λ is likely to be zero.
IFAIL=3
The solution has failed to converge in MAXIT iterations.
IFAIL=4
The value of a term required in (2) is too large to be evaluated accurately. The most likely cause of this error is both X and RLAMDA being very large.
IFAIL=5
The calculations for the central χ2 probability has failed to converge. This is an unlikely error exit. A larger value of TOL should be used.
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.
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.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

The summations described in Section 3 are made until an upper bound on the truncation error relative to the current summation value is less than TOL.

8  Parallelism and Performance

Not applicable.

9  Further Comments

The number of terms in (1) required for a given accuracy will depend on the following factors:
(i) The rate at which the Poisson weights tend to zero. This will be slower for larger values of λ.
(ii) The rate at which the central χ2 probabilities tend to zero. This will be slower for larger values of ν and x.

10  Example

This example reads values from various noncentral χ2-distributions, calculates the lower tail probabilities and prints all these values until the end of data is reached.

10.1  Program Text

Program Text (g01gcfe.f90)

10.2  Program Data

Program Data (g01gcfe.d)

10.3  Program Results

Program Results (g01gcfe.r)


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

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015