Quant Memo
Core

The Box-Muller Transform

A trick for turning two ordinary, easy-to-generate uniform random numbers into two independent, exactly normally distributed random numbers, without needing to invert the normal CDF.

Computers generate uniform random numbers easily (any value equally likely between 0 and 1), but simulations — pricing an option, running a Monte Carlo risk model — need normally distributed random numbers instead. The normal distribution's cumulative distribution function has no simple closed-form inverse, so directly transforming a uniform draw into a normal one isn't straightforward. The Box-Muller transform sidesteps this by using two uniform draws at once and a bit of trigonometry to produce two independent standard normal draws exactly, with no approximation.

Given two independent uniform random numbers U1,U2U_1, U_2 on (0,1)(0,1), the transform computes

Z1=2lnU1cos(2πU2),Z2=2lnU1sin(2πU2),Z_1 = \sqrt{-2\ln U_1}\,\cos(2\pi U_2), \qquad Z_2 = \sqrt{-2\ln U_1}\,\sin(2\pi U_2),

and Z1,Z2Z_1, Z_2 are exactly independent, standard normal random variables. The 2lnU1\sqrt{-2\ln U_1} term generates a random radius and the 2πU22\pi U_2 term generates a random angle, so geometrically the pair (Z1,Z2)(Z_1, Z_2) is just a uniformly random angle at a radius drawn from the right distribution — which works out, after the math, to be exactly bivariate normal.

A worked example

Draw U1=0.5U_1 = 0.5 and U2=0.25U_2 = 0.25. Then 2ln0.5=1.3861.177\sqrt{-2\ln 0.5} = \sqrt{1.386} \approx 1.177, and 2π×0.25=π/22\pi \times 0.25 = \pi/2, so cos(π/2)=0\cos(\pi/2) = 0 and sin(π/2)=1\sin(\pi/2) = 1. This gives Z1=1.177×0=0Z_1 = 1.177 \times 0 = 0 and Z2=1.177×1=1.177Z_2 = 1.177 \times 1 = 1.177 — two standard normal draws obtained from nothing more than two uniform numbers and a square root, log, and pair of trig functions.

The Box-Muller transform converts two independent uniform random draws into two independent standard normal draws exactly, using a random-radius, random-angle geometric trick that avoids ever inverting the normal distribution's CDF.

Related concepts

Practice in interviews

Further reading

  • Box & Muller, A Note on the Generation of Random Normal Deviates (1958)
ShareTwitterLinkedIn