Convert Box-Muller in a nutshell:
First we get two independent uniform random numbers from the interval (0, 1], call them U and V.
Then you can get two independent distributed random numbers with unit normals from the formulas
X = sqrt(-2 * log(U)) * cos(2 * pi * V);
Y = sqrt(-2 * log(U)) * sin(2 * pi * V);
This gives you random numbers for mu = 0, sigma = 1; set sigma = s, multiply your random numbers by s; to set mu = m, add m to your random numbers.
source
share