문제

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

PR(r) = ((2r)/Ω)*exp(-r^2/Ω), r >= 0, Ω = 2σ^2

http://en.wikipedia.org/wiki/Rayleigh_fading to see the equation written nicely.

So, I have the PDF, now I am just wondering how to get the random variable from it?

I have looked at these questions:

Generate Array of Numbers that fit to a Probability Distribution in Ruby?

Generate Random Numbers with Probabilistic Distribution

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!

도움이 되었습니까?

해결책

Rayleigh distribution is a special case of the Weibull distribution. If you google around, there are lots of Weibull generators written in Java, for example:

One way to generate a random number from a given distribution is to generate a random number uniformly distributed between zero and one, and apply the target distribution's inverse CDF to that random number. See Wikipedia.

다른 팁

For your case, something like this:

 Random generator = new Random();
 double r = Math.sqrt(-Omega*Math.log(1-generator.nextDouble()));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top