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_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βp, associated with the lower tail probability, pp, of the beta distribution with parameters aa and bb is defined as the solution to
βp
P(Bβp : a,b) = p = (Γ(a + b))/(Γ(a)Γ(b))Ba1(1B)b1dB,  0βp1;a,b > 0.
0
P(Bβp:a,b)=p=Γ(a+b) Γ(a)Γ(b) 0βpBa-1(1-B)b-1dB,  0βp1;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β0, to βpβp is found (see Cran et al. (1977)), and the Newton–Raphson iteration
βi = βi1(f(βi1))/(f(βi1)),
βi=βi-1-f(βi-1) f(βi-1) ,
where f(β) = P(Bβ : a,b)pf(β)=P(Bβ:a,b)-p is used, with modifications to ensure that ββ remains in the range (0,1)(0,1).

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
pp, the lower tail probability from the required beta distribution.
Constraint: 0.0p1.00.0p1.0.
2:     a – double scalar
aa, the first parameter of the required beta distribution.
Constraint: 0.0 < a1060.0<a106.
3:     b – double scalar
bb, the second parameter of the required beta distribution.
Constraint: 0.0 < b1060.0<b106.

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.01.0 or less than 10 × machine precision10×machine precision (see nag_machine_precision (x02aj)), then the value of 10 × machine precision10×machine precision is used instead.
Default: 0.00.0

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_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 ifail = 1ifail=1 or 22, then nag_stat_inv_cdf_beta (g01fe) returns 0.00.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 = 1ifail=1
On entry,p < 0.0p<0.0,
orp > 1.0p>1.0.
  ifail = 2ifail=2
On entry,a0.0a0.0,
ora > 106a>106,
orb0.0b0.0,
orb > 106b>106.
W ifail = 3ifail=3
There is doubt concerning the accuracy of the computed result. 100100 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 = 4ifail=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.

Further Comments

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



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