nag_rngs_gamma (g05lfc) generates a vector of pseudorandom numbers taken from a gamma distribution with and .
The gamma distribution has PDF (probability density function)
One of three algorithms is used to generate the variates depending upon the value of
:
| (i) |
if , a switching algorithm described by Dagpunar (1988) (called G6) is used. The target distributions are and , where , and the switching parameter, , is taken as . This is Ahrens and Dieter's GS algorithm (see Ahrens and Dieter (1974)) in which ; |
| (ii) |
if , the gamma distribution reduces to the exponential distribution and the method based on the logarithmic transformation of a uniform random variate is used; |
| (iii) |
if , the algorithm given by Best (1978) is used. This is based on using a Student's -distribution with two degrees of freedom as the target distribution in an envelope rejection method. |
One of the initialization functions
nag_rngs_init_repeatable (g05kbc) (for a repeatable sequence if computed sequentially) or
nag_rngs_init_nonrepeatable (g05kcc) (for a non-repeatable sequence) must be called prior to the first call to nag_rngs_gamma (g05lfc).
Ahrens J H and Dieter U (1974) Computer methods for sampling from gamma, beta, Poisson and binomial distributions Computing 12 223–46
Not applicable.
None.
This example prints a set of five pseudorandom numbers from a gamma distribution with parameters
and
, generated by a single call to nag_rngs_gamma (g05lfc), after initialization by
nag_rngs_init_repeatable (g05kbc).
None.