= Solution
One route is <inverse transform sampling>: if $\Phi$ is the standard normal <cumulative distribution function>, then $\mu+\sigma\Phi^{-1}(U)$ has the <normal distribution> with mean $\mu$ and <variance> $\sigma^2$.
Alternatively the <Box-Muller transform> uses two independent uniform inputs $U_1,U_2\in(0,1)$:
$$
\boxed{Z_1=\sqrt{-2\log U_1}\cos(2\pi U_2),\qquad Z_2=\sqrt{-2\log U_1}\sin(2\pi U_2).}
$$
To verify this, set $R=\sqrt{-2\log U_1}$ and $\Theta=2\pi U_2$. The radial density is $re^{-r^2/2}$ for $r>0$, and the angle is independent and uniform. Their joint density is $re^{-r^2/2}/(2\pi)$. Changing to Cartesian coordinates divides by the <Jacobian determinant> $r$, giving
$$
f_{Z_1,Z_2}(x,y)=\frac1{2\pi}e^{-(x^2+y^2)/2}.
$$
This factors into two standard normal densities, proving both normality and independence. Then $\mu+\sigma Z_j$ provides the required means and variances. Implementations must avoid the zero input to the logarithm; ideal continuous uniforms hit it with probability zero.
Back to article page