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_inv_cdf_beta (g01fe)

Purpose

nag_stat_inv_cdf_beta (g01fe) returns the deviate associated with the given lower tail probability of the beta distribution.

Syntax

[result, ifail] = g01fe(p, a, b, 'tol', tol)
[result, ifail] = nag_stat_inv_cdf_beta(p, a, b, 'tol', tol)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: tol now optional (default 0)
.

Description

The deviate, βp${\beta }_{p}$, associated with the lower tail probability, p$p$, of the beta distribution with parameters a$a$ and b$b$ is defined as the solution to
 βp P(B ≤ βp : a,b) = p = (Γ(a + b))/(Γ(a)Γ(b)) ∫ Ba − 1(1 − B)b − 1dB,  0 ≤ βp ≤ 1;a,b > 0. 0
$P(B≤βp:a,b)=p=Γ(a+b) Γ(a)Γ(b) ∫0βpBa-1(1-B)b-1dB, 0≤βp≤1;a,b>0.$
The algorithm is a modified version of the Newton–Raphson method, following closely that of Cran et al. (1977).
An initial approximation, β0${\beta }_{0}$, to βp${\beta }_{p}$ is found (see Cran et al. (1977)), and the Newton–Raphson iteration
 βi = βi − 1 − (f(βi − 1))/(f′(βi − 1)), $βi=βi-1-f(βi-1) f′(βi-1) ,$
where f(β) = P(Bβ : a,b)p$f\left(\beta \right)=P\left(B\le \beta :a,b\right)-p$ is used, with modifications to ensure that β$\beta$ remains in the range (0,1)$\left(0,1\right)$.

References

Cran G W, Martin K J and Thomas G E (1977) Algorithm AS 109. Inverse of the incomplete beta function ratio Appl. Statist. 26 111–114
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth

Parameters

Compulsory Input Parameters

1:     p – double scalar
p$p$, the lower tail probability from the required beta distribution.
Constraint: 0.0p1.0$0.0\le {\mathbf{p}}\le 1.0$.
2:     a – double scalar
a$a$, the first parameter of the required beta distribution.
Constraint: 0.0 < a106$0.0<{\mathbf{a}}\le {10}^{6}$.
3:     b – double scalar
b$b$, the second parameter of the required beta distribution.
Constraint: 0.0 < b106$0.0<{\mathbf{b}}\le {10}^{6}$.

Optional Input Parameters

1:     tol – double scalar
The relative accuracy required by you in the result. If nag_stat_inv_cdf_beta (g01fe) is entered with tol greater than or equal to 1.0$1.0$ or less than 10 × machine precision (see nag_machine_precision (x02aj)), then the value of 10 × machine precision is used instead.
Default: 0.0$0.0$

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_beta (g01fe) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
If on exit ${\mathbf{ifail}}={\mathbf{1}}$ or 2${\mathbf{2}}$, then nag_stat_inv_cdf_beta (g01fe) 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}}>1.0$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, a ≤ 0.0${\mathbf{a}}\le 0.0$, or a > 106${\mathbf{a}}>{10}^{6}$, or b ≤ 0.0${\mathbf{b}}\le 0.0$, or b > 106${\mathbf{b}}>{10}^{6}$.
W ifail = 3${\mathbf{ifail}}=3$
There is doubt concerning the accuracy of the computed result. 100$100$ iterations of the Newton–Raphson method have been performed without satisfying the accuracy criterion (see Section [Accuracy]). The result should be a reasonable approximation of the solution.
W ifail = 4${\mathbf{ifail}}=4$
Requested accuracy not achieved when calculating beta probability. The result should be a reasonable approximation to the correct solution. You should try setting tol larger.

Accuracy

The required precision, given by tol, should be achieved in most circumstances.

The typical timing will be several times that of nag_stat_prob_beta (g01ee) and will be very dependent on the input parameter values. See nag_stat_prob_beta (g01ee) for further comments on timings.

Example

```function nag_stat_inv_cdf_beta_example
p = 0.5;
a = 1;
b = 2;
[result, ifail] = nag_stat_inv_cdf_beta(p, a, b)
```
```

result =

0.2929

ifail =

0

```
```function g01fe_example
p = 0.5;
a = 1;
b = 2;
[result, ifail] = g01fe(p, a, b)
```
```

result =

0.2929

ifail =

0

```