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 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
g05kfc (for a repeatable sequence if computed sequentially) or
g05kgc (for a non-repeatable sequence) must be called prior to the first call to
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.
Background information to multithreading can be found in the
Multithreading documentation.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also 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
g05sjc, after initialization by
g05kfc.
None.