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:
- http://commons.apache.org/math/apidocs/org/apache/commons/math3/distribution/WeibullDistribution.html
- http://www.iro.umontreal.ca/~simardr/ssj/doc/html/umontreal/iro/lecuyer/randvar/WeibullGen.html
- http://www.icsa.inf.ed.ac.uk/research/groups/hase/simjava/distributions/doc/eduni/distributions/Weibull.html
- http://www.ee.ucl.ac.uk/~mflanaga/java/PsRandom.html
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.