# Generate random number from Gaussian, Cauchy and Levy distribution [closed]

I am working on Genetic Algorithm. I have to generate random number from above three distributions. How can I do this?

-
As a start, you may want to look at this. The procedure using the inverse cdf is definitely not best for Gaussian, Box-Muller is better. But inverse cdf should work quickly for the Cauchy. –  André Nicolas Jan 5 '12 at 20:06
Asked and answered on stats.SE quite recently. The same three distributions too! –  Dilip Sarwate Jan 5 '12 at 20:11
- To sample from standard normal distribution, you could use Box-Muller transform - To sample from the standard Cauchy, you either use $Z_1/Z_2$ where $Z_i$ are independent standard normals or, better, $\tan\left( \pi \left(U-\frac{1}{2}\right) \right)$, where $U$ is standard uniform. - To sample from standard Levy, use $Z^{-2}$ where $Z$ is standard normal variable. –  Sasha Jan 5 '12 at 20:16
I strongly recommend closure of this question. crucified soul asked the same question on stats.SE and accepted the answer there too! What is this, forum-shopping? –  Dilip Sarwate Jan 5 '12 at 20:20