Sampling an integer-shape gamma distribution
= Sampling an integer-shape gamma distribution
If $m$ is a positive integer and $U_1,\ldots,U_m$ are independent uniform variables, then
$$
-\frac1r\sum_{j=1}^m\log U_j
$$
has the gamma distribution with shape $m$ and rate $r$, because each summand is exponential with rate $r$.