= Solution
One method applies <inverse transform sampling> to the standard normal <cumulative distribution function>: $Z_i=\Phi^{-1}(U_i)$, followed by $X_i=\mu+\sigma Z_i$ for mean $\mu$ and <standard deviation> $\sigma>0$. Numerical approximations to $\Phi^{-1}$ are needed, and the endpoints $U=0,1$ must be avoided.
A convenient alternative is the <Box-Muller transform>. From independent uniforms $U_1,U_2\in(0,1)$ set
$$
R=\sqrt{-2\log U_1},\quad\Theta=2\pi U_2,\qquad
\boxed{Z_1=R\cos\Theta,\quad Z_2=R\sin\Theta.}
$$
The radial <probability density function> is $re^{-r^2/2}$ for $r>0$, and the angle is independently uniform on $[0,2\pi)$. Dividing their joint density by the polar-coordinate <Jacobian determinant> $r$ gives
$$
p(z_1,z_2)=\frac1{2\pi}e^{-(z_1^2+z_2^2)/2}
=\phi(z_1)\phi(z_2).
$$
Thus the outputs are independent standard <normal distribution> draws. Apply $\mu+\sigma Z_j$ to obtain other normal means and <variances>. With finite <pseudorandom number generators>, this is an approximation to the ideal independent-uniform model; poor dependence in the input stream is not cured by the transform.
Back to article page