ID EN
Random

gammavariate

Python 3.11

Gamma distribution. (Not the gamma function!) The shape and scale parameters, alpha and beta, must have positive values. (Calling conventions vary and some sources define ‘beta’ as the inverse of the scale).

Syntax

PYTHON
random.gammavariate(alpha, beta)

Examples

Example 1
PYTHON
x ** (alpha - 1) * math.exp(-x / beta)
pdf(x) =  --------------------------------------
            math.gamma(alpha) * beta ** alpha