nag_rand_beta (g05sbc) generates a vector of pseudorandom numbers taken from a beta distribution with parameters and .
The beta distribution has PDF (probability density function)
One of four algorithms is used to generate the variates depending on the values of
and
. Let
be the maximum and
be the minimum of
and
. Then the algorithms are as follows:
| (i) |
if , Johnk's algorithm is used, see for example Dagpunar (1988). This generates the beta variate as , where and are uniformly distributed random variates; |
| (ii) |
if , the algorithm BB given by Cheng (1978) is used. This involves the generation of an observation from a beta distribution of the second kind by the envelope rejection method using a log-logistic target distribution and then transforming it to a beta variate; |
| (iii) |
if and , the switching algorithm given by Atkinson (1979) is used. The two target distributions used are and , along with the approximation to the switching argument of ; |
| (iv) |
in all other cases, Cheng's BC algorithm (see Cheng (1978)) is used with modifications suggested by Dagpunar (1988). This algorithm is similar to BB, used when , but is tuned for small values of and . |
One of the initialization functions
nag_rand_init_repeatable (g05kfc) (for a repeatable sequence if computed sequentially) or
nag_rand_init_nonrepeatable (g05kgc) (for a non-repeatable sequence) must be called prior to the first call to nag_rand_beta (g05sbc).
Atkinson A C (1979) A family of switching algorithms for the computer generation of beta random variates Biometrika 66 141–5
Not applicable.
This example prints a set of five pseudorandom numbers from a beta distribution with parameters
and
, generated by a single call to nag_rand_beta (g05sbc), after initialization by
nag_rand_init_repeatable (g05kfc).
None.