nag_deviates_beta_vector (g01tec) returns a number of deviates associated with given probabilities of the beta distribution.
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:
– IntegerInput
-
On entry: the length of the array
tail.
Constraint:
.
- 2:
– const Nag_TailProbabilityInput
-
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:
– IntegerInput
-
On entry: the length of the array
p.
Constraint:
.
- 4:
– const doubleInput
-
On entry:
, the probability of the required beta distribution as defined by
tail with
,
.
Constraint:
, for .
- 5:
– IntegerInput
-
On entry: the length of the array
a.
Constraint:
.
- 6:
– const doubleInput
-
On entry: , the first parameter of the required beta distribution with , .
Constraint:
, for .
- 7:
– IntegerInput
-
On entry: the length of the array
b.
Constraint:
.
- 8:
– const doubleInput
-
On entry: , the second parameter of the required beta distribution with , .
Constraint:
, for .
- 9:
– doubleInput
-
On entry: the relative accuracy required by you in the results. If nag_deviates_beta_vector (g01tec) is entered with
tol greater than or equal to
or less than
(see
nag_machine_precision (X02AJC)), then the value of
is used instead.
- 10:
– doubleOutput
-
Note: the dimension,
dim, of the array
beta
must be at least
.
On exit: , the deviates for the beta distribution.
- 11:
– IntegerOutput
-
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 3.6 in the Essential Introduction).
The required precision, given by
tol, should be achieved in most circumstances.
Not applicable.
The typical timing will be several times that of
nag_prob_beta_vector (g01sec) and will be very dependent on the input argument values. See
nag_prob_beta_vector (g01sec) for further comments on timings.
This example reads lower tail probabilities for several beta distributions and calculates and prints the corresponding deviates.