nag_prob_chi_sq (g01ecc) (PDF version)
g01 Chapter Contents
g01 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_prob_chi_sq (g01ecc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_prob_chi_sq (g01ecc) returns the lower or upper tail probability for the χ2-distribution with real degrees of freedom.

2  Specification

#include <nag.h>
#include <nagg01.h>
double  nag_prob_chi_sq (Nag_TailProbability tail, double x, double df, NagError *fail)

3  Description

The lower tail probability for the χ2-distribution with ν degrees of freedom, PXx:ν is defined by:
PXx:ν=12ν/2Γν/2 0.0xXν/2-1e-X/2dX,  x0,ν>0.  
To calculate PXx:ν a transformation of a gamma distribution is employed, i.e., a χ2-distribution with ν degrees of freedom is equal to a gamma distribution with scale parameter 2 and shape parameter ν/2.

4  References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth

5  Arguments

1:     tail Nag_TailProbabilityInput
On entry: indicates whether the upper or lower tail probability is required.
tail=Nag_LowerTail
The lower tail probability is returned, i.e., PXx:ν.
tail=Nag_UpperTail
The upper tail probability is returned, i.e., PXx:ν.
Constraint: tail=Nag_LowerTail or Nag_UpperTail.
2:     x doubleInput
On entry: x, the value of the χ2 variate with ν degrees of freedom.
Constraint: x0.0.
3:     df doubleInput
On entry: ν, the degrees of freedom of the χ2-distribution.
Constraint: df>0.0.
4:     fail NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALG_NOT_CONV
The series used to calculate the gamma probabilities has failed to converge. The result returned should represent an approximation to the solution.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.2.1.2 in the Essential Introduction for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 3.6.6 in the Essential Introduction for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 3.6.5 in the Essential Introduction for further information.
NE_REAL_ARG_LE
On entry, df=value.
Constraint: df>0.0.
NE_REAL_ARG_LT
On entry, x=value.
Constraint: x0.0.

7  Accuracy

A relative accuracy of five significant figures is obtained in most cases.

8  Parallelism and Performance

Not applicable.

9  Further Comments

For higher accuracy the transformation described in Section 3 may be used with a direct call to nag_incomplete_gamma (s14bac).

10  Example

Values from various χ2-distributions are read, the lower tail probabilities calculated, and all these values printed out, until the end of data is reached.

10.1  Program Text

Program Text (g01ecce.c)

10.2  Program Data

Program Data (g01ecce.d)

10.3  Program Results

Program Results (g01ecce.r)


nag_prob_chi_sq (g01ecc) (PDF version)
g01 Chapter Contents
g01 Chapter Introduction
NAG Library Manual

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