This time I am starting a real blog, devoted solely to the professional questions and tricky problems I have to deal with every day. Hopefully my enthusiasm will last a little longer this time.

hi i have a question about your code for random sampling a variable from a gamma distribution. i tried your code and the random numbers it gives me are greater than one. is this not a probability distribution?? I'm trying to figure out the math right now but i was wondering if you could tell me exactly how you came up with this code... thanks!

What I have posted is a sampling function. It draws samples of a random variable distributed according to Gamma distribution. The Gamma distribution is defined on [0;+∞). You might want to read this description of a sampling algorithm. I have not verified, though, if the algorithm described in the Wikipedia article is the same as implemented in my Java code.

## 2 comments:

hi i have a question about your code for random sampling a variable from a gamma distribution. i tried your code and the random numbers it gives me are greater than one. is this not a probability distribution?? I'm trying to figure out the math right now but i was wondering if you could tell me exactly how you came up with this code...

thanks!

Hi Erin,

What I have posted is a sampling function. It draws samples of a random variable distributed according to Gamma distribution. The Gamma distribution is defined on [0;+∞). You might want to read this description of a sampling algorithm. I have not verified, though, if the algorithm described in the Wikipedia article is the same as implemented in my Java code.

Post a Comment