Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_stat_prob_f (g01ed)

## Purpose

nag_stat_prob_f (g01ed) returns the probability for the lower or upper tail of the F$F$ or variance-ratio distribution with real degrees of freedom.

## Syntax

[result, ifail] = g01ed(f, df1, df2, 'tail', tail)
[result, ifail] = nag_stat_prob_f(f, df1, df2, '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 F$F$, or variance-ratio distribution, with ν1${\nu }_{1}$ and ν2${\nu }_{2}$ degrees of freedom, P(Ff : ν1,ν2)$P\left(F\le f:{\nu }_{1},{\nu }_{2}\right)$, is defined by:
 f P(F ≤ f : ν1,ν2) = (ν1ν1 / 2ν2ν2 / 2 Γ ((ν1 + ν2) / 2) )/( Γ(ν1 / 2) Γ(ν2 / 2)) ∫ F(ν1 − 2) / 2(ν1F + ν2) − (ν1 + ν2) / 2dF, 0
$P(F≤f:ν1,ν2)=ν1ν1/2ν2ν2/2 Γ ((ν1+ν2)/2) Γ(ν1/2) Γ(ν2/2) ∫0fF(ν1-2)/2(ν1F+ν2)-( ν1+ν2)/2dF,$
for ν1${\nu }_{1}$, ν2 > 0${\nu }_{2}>0$, f0$f\ge 0$.
The probability is computed by means of a transformation to a beta distribution, Pβ(Bβ : a,b)${P}_{\beta }\left(B\le \beta :a,b\right)$:
 P(F ≤ f : ν1,ν2) = Pβ (B ≤ (ν1f)/(ν1f + ν2) : ν1 / 2,ν2 / 2) $P(F≤f:ν1,ν2)=Pβ (B≤ν1f ν1f+ν2 :ν1/2,ν2/2)$
and using a call to nag_stat_prob_beta (g01ee).
For very large values of both ν1${\nu }_{1}$ and ν2${\nu }_{2}$, greater than 105${10}^{5}$, a normal approximation is used. If only one of ν1${\nu }_{1}$ or ν2${\nu }_{2}$ is greater than 105${10}^{5}$ then a χ2${\chi }^{2}$ approximation is used, see Abramowitz and Stegun (1972).

## 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:     f – double scalar
f$f$, the value of the F$F$ variate.
Constraint: f0.0${\mathbf{f}}\ge 0.0$.
2:     df1 – double scalar
The degrees of freedom of the numerator variance, ν1${\nu }_{1}$.
Constraint: df1 > 0.0${\mathbf{df1}}>0.0$.
3:     df2 – double scalar
The degrees of freedom of the denominator variance, ν2${\nu }_{2}$.
Constraint: df2 > 0.0${\mathbf{df2}}>0.0$.

### Optional Input Parameters

1:     tail – string (length ≥ 1)
Indicates whether an upper or lower tail probability is required.
tail = 'L'${\mathbf{tail}}=\text{'L'}$
The lower tail probability is returned, i.e., P(Ff : ν1,ν2)$P\left(F\le f:{\nu }_{1},{\nu }_{2}\right)$.
tail = 'U'${\mathbf{tail}}=\text{'U'}$
The upper tail probability is returned, i.e., P(Ff : ν1,ν2)$P\left(F\ge f:{\nu }_{1},{\nu }_{2}\right)$.
Default: 'L'$\text{'L'}$
Constraint: tail = 'L'${\mathbf{tail}}=\text{'L'}$ or 'U'$\text{'U'}$.

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_prob_f (g01ed) 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}}$ or 3${\mathbf{3}}$ on exit, then nag_stat_prob_f (g01ed) returns 0.0$0.0$.
ifail = 1${\mathbf{ifail}}=1$
 On entry, tail ≠ 'L'${\mathbf{tail}}\ne \text{'L'}$ or 'U'$\text{'U'}$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, f < 0.0${\mathbf{f}}<0.0$.
ifail = 3${\mathbf{ifail}}=3$
 On entry, df1 ≤ 0.0${\mathbf{df1}}\le 0.0$, or df2 ≤ 0.0${\mathbf{df2}}\le 0.0$.
ifail = 4${\mathbf{ifail}}=4$
f is too far out into the tails for the probability to be evaluated exactly. The result tends to approach 1.0$1.0$ if f$f$ is large, or 0.0$0.0$ if f$f$ is small. The result returned is a good approximation to the required solution.

## Accuracy

The result should be accurate to five significant digits.

For higher accuracy nag_stat_prob_beta (g01ee) can be used along with the transformations given in Section [Description].

## Example

```function nag_stat_prob_f_example
tail = 'Lower';
f = 5.5;
df1 = 1.5;
df2 = 25.5;
[result, ifail] = nag_stat_prob_f(f, df1, df2)
```
```

result =

0.9837

ifail =

0

```
```function g01ed_example
tail = 'Lower';
f = 5.5;
df1 = 1.5;
df2 = 25.5;
[result, ifail] = g01ed(f, df1, df2)
```
```

result =

0.9837

ifail =

0

```