1. PF Contest - Win "Conquering the Physics GRE" book! Click Here to Enter
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Rejection sampling from gamma distribution

  1. Dec 19, 2009 #1
    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 [tex]\left|kt^2 \mathrm{randn} +kt \right|[/tex] 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
  2. jcsd
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