NAG Library Routine Document

g01fef  (inv_cdf_beta)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

g01fef returns the deviate associated with the given lower tail probability of the beta distribution, via the routine name.

2
Specification

Fortran Interface
Function g01fef ( p, a, b, tol, ifail)
Real (Kind=nag_wp):: g01fef
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: p, a, b, tol
C Header Interface
#include nagmk26.h
double  g01fef_ ( const double *p, const double *a, const double *b, const double *tol, Integer *ifail)

3
Description

The deviate, βp, associated with the lower tail probability, p, of the beta distribution with parameters a and b is defined as the solution to
PBβp:a,b=p=Γa+b ΓaΓb 0βpBa-11-Bb-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, to βp is found (see Cran et al. (1977)), and the Newton–Raphson iteration
βi=βi-1-fβi-1 fβi-1 ,  
where fβ=PBβ:a,b-p is used, with modifications to ensure that β remains in the range 0,1.

4
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

5
Arguments

1:     p – Real (Kind=nag_wp)Input
On entry: p, the lower tail probability from the required beta distribution.
Constraint: 0.0p1.0.
2:     a – Real (Kind=nag_wp)Input
On entry: a, the first parameter of the required beta distribution.
Constraint: 0.0<a106.
3:     b – Real (Kind=nag_wp)Input
On entry: b, the second parameter of the required beta distribution.
Constraint: 0.0<b106.
4:     tol – Real (Kind=nag_wp)Input
On entry: the relative accuracy required by you in the result. If g01fef is entered with tol greater than or equal to 1.0 or less than 10×machine precision (see x02ajf), the value of 10×machine precision is used instead.
5:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, because for this routine the values of the output arguments may be useful even if ifail0 on exit, the recommended value is -1. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Note: g01fef may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
If on exit ifail=1 or 2, then g01fef returns 0.0.
ifail=1
On entry, p=value.
Constraint: p1.0.
On entry, p=value.
Constraint: p0.0.
ifail=2
On entry, a=value and b=value.
Constraint: a>0.0.
On entry, a=value and b=value.
Constraint: a106.
On entry, a=value and b=value.
Constraint: b>0.0.
On entry, a=value and b=value.
Constraint: b106.
ifail=3
The solution has failed to converge. However, the result should be a reasonable approximation. Requested accuracy not achieved when calculating beta probability. You should try setting tol larger.
ifail=4
The requested accuracy has not been achieved. Use a larger value of tol. There is doubt concerning the accuracy of the computed result. 100 iterations of the Newton–Raphson method have been performed without satisfying the accuracy criterion (see Section 9). The result should be a reasonable approximation of the solution.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

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

8
Parallelism and Performance

g01fef is not threaded in any implementation.

9
Further Comments

The typical timing will be several times that of g01eef and will be very dependent on the input argument values. See g01eef for further comments on timings.

10
Example

This example reads lower tail probabilities for several beta distributions and calculates and prints the corresponding deviates until the end of data is reached.

10.1
Program Text

Program Text (g01fefe.f90)

10.2
Program Data

Program Data (g01fefe.d)

10.3
Program Results

Program Results (g01fefe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017