hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_stat_prob_chisq (g01ec)

Purpose

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

Syntax

[result, ifail] = g01ec(x, df, 'tail', tail)
[result, ifail] = nag_stat_prob_chisq(x, df, 'tail', tail)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: tail now optional (default 'l')
.

Description

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

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

Parameters

Compulsory Input Parameters

1:     x – double scalar
xx, the value of the χ2χ2 variate with νν degrees of freedom.
Constraint: x0.0x0.0.
2:     df – double scalar
νν, the degrees of freedom of the χ2χ2-distribution.
Constraint: df > 0.0df>0.0.

Optional Input Parameters

1:     tail – string (length ≥ 1)
Indicates whether the upper or lower tail probability is required.
tail = 'L'tail='L'
The lower tail probability is returned, i.e., P(Xx : ν)P(Xx:ν).
tail = 'U'tail='U'
The upper tail probability is returned, i.e., P(Xx : ν)P(Xx:ν).
Default: 'L''L'
Constraint: tail = 'L'tail='L' or 'U''U'.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     result – double scalar
The result of the function.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Note: nag_stat_prob_chisq (g01ec) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
If ifail = 1ifail=1, 22 or 33 on exit, then nag_stat_prob_chisq (g01ec) returns 0.00.0.
  ifail = 1ifail=1
On entry,tail'L'tail'L' or 'U''U'.
  ifail = 2ifail=2
On entry,x < 0.0x<0.0.
  ifail = 3ifail=3
On entry,df0.0df0.0.
  ifail = 4ifail=4
The solution has failed to converge while calculating the gamma variate. The result returned should represent an approximation to the solution.

Accuracy

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

Further Comments

For higher accuracy the transformation described in Section [Description] may be used with a direct call to nag_specfun_gamma_incomplete (s14ba).

Example

function nag_stat_prob_chisq_example
tail = 'Lower';
x = 8.26;
df = 20;
[result, ifail] = nag_stat_prob_chisq(x, df)
 

result =

    0.0100


ifail =

                    0


function g01ec_example
tail = 'Lower';
x = 8.26;
df = 20;
[result, ifail] = g01ec(x, df)
 

result =

    0.0100


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013