# Rejection sampling from gamma distribution

1. Dec 19, 2009

### coolnessitself

1. The problem statement, all variables and given/known data
So this isn't homework, but it's on the level of a homework question, so I'll put it here. I'm trying to figure out how to sample just one value from a gamma distribution using rejection sampling.

2. Relevant equations
How to do it:
page 10
http://www.thefutureofmath.com/matlabstuff/matlabintro.pdf [Broken]

3. The attempt at a solution
I understand the loop until a value is found, and I understand finding a maximum to compare [gammadistribution] against a [maxval*uniform(0,1)].
But for x in the gammadistribution, they use $$\left|kt^2 \mathrm{randn} +kt \right|$$ as x. What is this? Shape parameter times scale parameter squared times a normal distribution plus the scale parameter times the shape parameter? What? My eventual goal is to sample from an arbitrary function, and I think if I can figure out where they're picking this x from I understand the rest.

Last edited by a moderator: May 4, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Threads - Rejection sampling gamma Date
Sampling Distribution Question Feb 23, 2018
Calculate the time out of sample points with set frequency Jan 19, 2018
Reject Value (Stats) ( ) May 21, 2011
Choosing and rejecting inequality Jan 25, 2009