Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for an effective method to sample from a Gamma distribution that has the shape parameter not integer.

However, I found everywhere the method to sample from a Gamma with an integer shape (that is as a matter of fact an Erlang distribution).

I found this paper about an method for sampling from a Gamma. Unfortunately, I don't understand how to implement it!

Any suggestion?

share|cite|improve this question
up vote 1 down vote accepted

See Devroye "Non-Uniform Random Variate Generation" Section IX.3.2 (it is freely available online). Several algorithms are explained in detail there with pseudo-code, so it will be quick to code.

-- Monseigneur Myriel

share|cite|improve this answer
Thank you so much! The book is great! – Roberto Trunfio Dec 19 '12 at 11:46
You are welcome! – Learner Dec 19 '12 at 12:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.