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

NAG Library Routine Document


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

G01FCF returns the deviate associated with the given lower tail probability of the χ2-distribution with real degrees of freedom, via the routine name.

2  Specification

REAL (KIND=nag_wp) G01FCF
REAL (KIND=nag_wp)  P, DF

3  Description

The deviate, xp, associated with the lower tail probability p of the χ2-distribution with ν degrees of freedom is defined as the solution to
PXxp:ν=p=12ν/2Γν/2 0xpe-X/2Xv/2-1dX,  0xp<;ν>0.
The required xp is found by using the relationship between a χ2-distribution and a gamma distribution, i.e., a χ2-distribution with ν degrees of freedom is equal to a gamma distribution with scale parameter 2 and shape parameter ν/2.
For very large values of ν, greater than 105, Wilson and Hilferty's normal approximation to the χ2 is used; see Kendall and Stuart (1969).

4  References

Best D J and Roberts D E (1975) Algorithm AS 91. The percentage points of the χ2 distribution Appl. Statist. 24 385–388
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
Kendall M G and Stuart A (1969) The Advanced Theory of Statistics (Volume 1) (3rd Edition) Griffin

5  Parameters

1:     P – REAL (KIND=nag_wp)Input
On entry: p, the lower tail probability from the required χ2-distribution.
Constraint: 0.0P<1.0.
2:     DF – REAL (KIND=nag_wp)Input
On entry: ν, the degrees of freedom of the χ2-distribution.
Constraint: DF>0.0.
3:     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: G01FCF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
If IFAIL=1, 2, 3 or 5 on exit, then G01FCF returns 0.0.
On entry,P<0.0,
On entry,DF0.0.
P is too close to 0 or 1 for the result to be calculated.
The solution has failed to converge. The result should be a reasonable approximation.
The series used to calculate the gamma function has failed to converge. This is an unlikely error exit.

7  Accuracy

The results should be accurate to five significant digits for most parameter values. Some accuracy is lost for p close to 0.0.

8  Further Comments

For higher accuracy the relationship described in Section 3 may be used and a direct call to G01FFF made.

9  Example

This example reads lower tail probabilities for several χ2-distributions, and calculates and prints the corresponding deviates until the end of data is reached.

9.1  Program Text

Program Text (g01fcfe.f90)

9.2  Program Data

Program Data (g01fcfe.d)

9.3  Program Results

Program Results (g01fcfe.r)

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

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