The deviate,
, associated with the lower tail probability,
, of the beta distribution with parameters
and
is defined as the solution to
The algorithm is a modified version of the Newton–Raphson method, following closely that of
Cran et al. (1977).
An initial approximation,
, to
is found (see
Cran et al. (1977)), and the Newton–Raphson iteration
where
is used, with modifications to ensure that
remains in the range
.
The input arrays to this function are designed to allow maximum flexibility in the supply of vector arguments by re-using elements of any arrays that are shorter than the total number of evaluations required. See
Section 2.6 in the
G01 Chapter Introduction for further information.
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
-
1:
– Integer
Input
-
On entry: the length of the array
tail.
Constraint:
.
-
2:
– const Nag_TailProbability
Input
-
On entry: indicates which tail the supplied probabilities represent. For
, for
:
- The lower tail probability, i.e., .
- The upper tail probability, i.e., .
Constraint:
or , for .
-
3:
– Integer
Input
-
On entry: the length of the array
p.
Constraint:
.
-
4:
– const double
Input
-
On entry:
, the probability of the required beta distribution as defined by
tail with
,
.
Constraint:
, for .
-
5:
– Integer
Input
-
On entry: the length of the array
a.
Constraint:
.
-
6:
– const double
Input
-
On entry: , the first parameter of the required beta distribution with , .
Constraint:
, for .
-
7:
– Integer
Input
-
On entry: the length of the array
b.
Constraint:
.
-
8:
– const double
Input
-
On entry: , the second parameter of the required beta distribution with , .
Constraint:
, for .
-
9:
– double
Input
-
On entry: the relative accuracy required by you in the results. If
g01tec is entered with
tol greater than or equal to
or less than
(see
X02AJC), the value of
is used instead.
-
10:
– double
Output
-
Note: the dimension,
dim, of the array
beta
must be at least
.
On exit: , the deviates for the beta distribution.
-
11:
– Integer
Output
-
Note: the dimension,
dim, of the array
ivalid
must be at least
.
On exit:
indicates any errors with the input arguments, with
- No error.
- On entry, invalid value supplied in tail when calculating .
- On entry, , or, .
- On entry, , or, , or, , or, .
- The solution has not converged but the result should be a reasonable approximation to the solution.
- Requested accuracy not achieved when calculating the beta probability. The result should be a reasonable approximation to the correct solution.
-
12:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
The required precision, given by
tol, should be achieved in most circumstances.
The typical timing will be several times that of
g01sec and will be very dependent on the input argument values. See
g01sec for further comments on timings.
This example reads lower tail probabilities for several beta distributions and calculates and prints the corresponding deviates.