nag_rand_gamma (g05sjc) generates a vector of pseudorandom numbers taken from a gamma distribution with parameters 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 argument, , is taken as . This is similar to 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_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_gamma (g05sjc).
Ahrens J H and Dieter U (1974) Computer methods for sampling from gamma, beta, Poisson and binomial distributions Computing 12 223–46
Not applicable.
nag_rand_gamma (g05sjc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the
Users' Note for your implementation for any additional implementation-specific information.
None.
This example prints a set of five pseudorandom numbers from a gamma distribution with parameters
and
, generated by a single call to nag_rand_gamma (g05sjc), after initialization by
nag_rand_init_repeatable (g05kfc).
None.