title: How to generate a random number with a specific probability density function?
body: <p>I am trying to model shadowing and fast fading for mobile wireless networks. For fast fading, Rayleigh fading is a reasonable model to use. The envelope of the channel response will be Rayleigh distributed. Calling this random variable R, it will have a probability density function (PDF) of </p>
  
  <p>PR(r) = ((2r)/Ω)*exp(-r^2/Ω), r >= 0, Ω = 2σ^2</p>
  
  <p><a href="http://en.wikipedia.org/wiki/Rayleigh_fading" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Rayleigh_fading</a> to see the equation written nicely. </p>
  
  <p>So, I have the PDF, now I am just wondering how to get the random variable from it?</p>
  
  <p>I have looked at these questions:</p>
  
  <p><a href="https://stackoverflow.com/questions/4550758/generate-array-of-numbers-that-fit-to-a-probability-distribution-in-ruby">Generate Array of Numbers that fit to a Probability Distribution in Ruby?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3109670/generate-random-numbers-with-probabilistic-distribution">Generate Random Numbers with Probabilistic Distribution</a></p>
  
  <p>but I am still not sure how to do it. It has taken me forever to understand PDF's so if anyone knows a way in Java to get a random variable with a specific PDF, that would be much appreciated!</p>