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_inv_cdf_chisq (g01fc)

## Purpose

nag_stat_inv_cdf_chisq (g01fc) returns the deviate associated with the given lower tail probability of the χ2${\chi }^{2}$-distribution with real degrees of freedom.

## Syntax

[result, ifail] = g01fc(p, df)
[result, ifail] = nag_stat_inv_cdf_chisq(p, df)

## Description

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

## References

Best D J and Roberts D E (1975) Algorithm AS 91. The percentage points of the χ2${\chi }^{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

## Parameters

### Compulsory Input Parameters

1:     p – double scalar
p$p$, the lower tail probability from the required χ2${\chi }^{2}$-distribution.
Constraint: 0.0p < 1.0$0.0\le {\mathbf{p}}<1.0$.
2:     df – double scalar
ν$\nu$, the degrees of freedom of the χ2${\chi }^{2}$-distribution.
Constraint: df > 0.0${\mathbf{df}}>0.0$.

None.

None.

### Output Parameters

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

## Error Indicators and Warnings

Note: nag_stat_inv_cdf_chisq (g01fc) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
If ${\mathbf{ifail}}={\mathbf{1}}$, 2${\mathbf{2}}$, 3${\mathbf{3}}$ or 5${\mathbf{5}}$ on exit, then nag_stat_inv_cdf_chisq (g01fc) returns 0.0$0.0$.

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

ifail = 1${\mathbf{ifail}}=1$
 On entry, p < 0.0${\mathbf{p}}<0.0$, or p ≥ 1.0${\mathbf{p}}\ge 1.0$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, df ≤ 0.0${\mathbf{df}}\le 0.0$.
ifail = 3${\mathbf{ifail}}=3$
p is too close to 0$0$ or 1$1$ for the result to be calculated.
W ifail = 4${\mathbf{ifail}}=4$
The solution has failed to converge. The result should be a reasonable approximation.
ifail = 5${\mathbf{ifail}}=5$
The series used to calculate the gamma function has failed to converge. This is an unlikely error exit.

## Accuracy

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

## Further Comments

For higher accuracy the relationship described in Section [Description] may be used and a direct call to nag_stat_inv_cdf_gamma (g01ff) made.

## Example

```function nag_stat_inv_cdf_chisq_example
p = 0.01;
df = 20;
[result, ifail] = nag_stat_inv_cdf_chisq(p, df)
```
```

result =

8.2604

ifail =

0

```
```function g01fc_example
p = 0.01;
df = 20;
[result, ifail] = g01fc(p, df)
```
```

result =

8.2604

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