Want to share your content on R-bloggers? click here if you have a blog, or here if you don't. By some piece of luck I came across a paper by the late George Marsaglia, genial contributor to the field of simulation, and Wai Wan Tang, entitled The Monty Python method for generating random variables. As shown by the below illustration, the concept is to flip the piece H outside the rectangle back inside the rectangle, exploiting the remaining area above the density. The fantastic part is actually that “since areas of the rectangle add to 1, the slim in-between area is exactly the tail area”! So the tiny bit between G and the flipped H is the remaining tail. In the case of a Gamma Ga(a,1) variate, the authors express this variate as the transform of another variate with a nearly symmetry density, on which the Monty Python method applies. The transform is $q(x)=(a-1/3)(1 + x/\sqrt{16a})^3$

with -√16a(The case of a<1 has to be processed by the indirect of multiplying a Ga(a+1,1) by a uniform variate to the power 1/a.) I also found out that there exists a Monte Python software, which is an unrelated Monte Carlo code in python [hence the name] for cosmological inference. Including nested sampling, unsurprisingly.

Filed under: Books, Kids, pictures, R, Statistics, University life Tagged: gamma distribution, George Marsaglia, John Cleese, Monte Python, Monty Python, pseudo-random generator, silly walks, simulation  