@article{JSSv003i03, title={The Monty Python Method for Generating Gamma Variables}, volume={3}, url={https://www.jstatsoft.org/index.php/jss/article/view/v003i03}, doi={10.18637/jss.v003.i03}, abstract={The Monty Python Method for generating random variables takes a decreasing density, cuts it into three pieces, then, using area-preserving transformations, folds it into a rectangle of area 1. A random point (x,y) from that rectangle is used to provide a variate from the given density, most of the time as itself or a linear function of x . The decreasing density is usually the right half of a symmetric density. The Monty Python method has provided short and fast generators for normal, t and von Mises densities, requiring, on the average, from 1.5 to 1.8 uniform variables. In this article, we apply the method to non-symmetric densities, particularly the important gamma densities. We lose some of the speed and simplicity of the symmetric densities, but still get a method for γ<sub>α</sub> variates that is simple and fast enough to provide beta variates in the form γ<sub>a</sub>/(γ<sub>a</sub>+γ<sub>b</sub>). We use an average of less than 1.7 uniform variates to produce a gamma variate whenever α ≥ 1 . Implementation is simpler and from three to five times as fast as a recent method reputed to be the best for changing α’s.}, number={3}, journal={Journal of Statistical Software}, author={Marsaglia, George and Tsang, Wai Wan}, year={1999}, pages={1–8} }