rGamma

rGamma(*args)

Realization of a Gamma distribution on [0,+\infty[.

Parameters:
kfloat

Shape parameter k > 0 with k = (\mu - \gamma)^2 / \sigma^2.

sizeint

The number of realizations to generate.

Returns:
realizationsfloat or sequence of float

The realizations of the distribution.

Notes

The probability density function is defined as:

f_X(x) = \frac{1}{\Gamma(k)}
         \left(x )\right)^{k - 1}
         \exp\left(- x)\right),
         \quad x \in [0; +\infty[

This method is based on the algorithm (1979) described in [marsaglia2000] with a small optimization on the \beta parameter that appears in the squeezing function (1 + beta * x^4)*exp(-x^2/2). We also add the special treatment of the case k < 1.

Examples

>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> r = ot.DistFunc.rGamma(2.5)