NAG Library Routine Document

g01gcf (prob_chisq_noncentral)

1
Purpose

g01gcf returns the probability associated with the lower tail of the noncentral χ2-distribution.

2
Specification

Fortran Interface
Function g01gcf ( x, df, rlamda, tol, maxit, ifail)
Real (Kind=nag_wp):: g01gcf
Integer, Intent (In):: maxit
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: x, df, rlamda, tol
C Header Interface
#include <nagmk26.h>
double  g01gcf_ (const double *x, const double *df, const double *rlamda, const double *tol, const Integer *maxit, Integer *ifail)

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

NIST Digital Library of Mathematical Functions

5
Arguments

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), 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 argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 arguments 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=value.
Constraint: df0.0.
On entry, df=0.0 and rlamda=0.0.
Constraint: rlamda>0.0 if df=0.0.
On entry, maxit=value.
Constraint: maxit1.
On entry, rlamda=value.
Constraint: rlamda0.0.
On entry, x=value.
Constraint: x0.0.
ifail=2
The initial value of the Poisson weight used in the summation of (1) (see Section 3) was too small to be calculated. The computed probability is likely to be zero.
ifail=3
The solution has failed to converge in value iterations. Consider increasing maxit or tol.
ifail=4
The value of a term required in (2) (see Section 3) is too large to be evaluated accurately. The most likely cause of this error is both x and rlamda are too large.
ifail=5
The calculations for the central chi-square probability has failed to converge. 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.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation 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

g01gcf is not threaded in any implementation.

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)