Skip to content

Box Muller Transformation

  • Converts two uniform(0,1) random numbers into two normally distributed random numbers.
  • Simple to implement and commonly used in statistical and mathematical applications where normal samples are needed.
  • Works with uniformly generated inputs (e.g., from a linear congruential generator) to produce outputs with mean 0 and standard deviation 1 in the example shown.

The Box-Muller Transformation is a method used to generate normally distributed random numbers by transforming two uniformly distributed random numbers into two normally distributed random numbers.

The transformation uses the following equations:

z1=2ln(x)cos(2πy)z_1 = \sqrt{-2\ln(x)}\cos(2\pi y) z2=2ln(x)sin(2πy)z_2 = \sqrt{-2\ln(x)}\sin(2\pi y)

where ln is the natural logarithm and π is the mathematical constant.

  • Start with two uniformly distributed random numbers, typically in the interval (0, 1). These can be produced by a uniform random number generator such as a linear congruential generator (which uses a seed, multiplies by a constant, adds another constant, and takes the remainder after dividing by a modulus to produce a sequence).
  • The Box-Muller Transformation maps the pair of uniform samples (x, y) to a pair of normally distributed values (z1, z2) using the two equations above.
  • The transformation is based on the source statement that “the sum of two independent uniformly distributed random variables has a normal distribution” and leverages trigonometric functions with a radial transform to produce normally distributed outputs.
  • The method is simple to implement and can be integrated into statistical and mathematical applications that require normally distributed random samples.

Using x = 0.5 and y = 0.5 and the equations above:

z1=2ln(0.5)cos(2π0.5)=0.73cos(π)=0.73z_1 = \sqrt{-2\ln(0.5)}\cos(2\pi \cdot 0.5) = 0.73\cos(\pi) = -0.73 z2=2ln(0.5)sin(2π0.5)=0.73sin(π)=0z_2 = \sqrt{-2\ln(0.5)}\sin(2\pi \cdot 0.5) = 0.73\sin(\pi) = 0

Thus the two normally distributed random numbers obtained are -0.73 and 0, with a mean of 0 and a standard deviation of 1 in this example.

  • Generating normally distributed random numbers for statistical and mathematical applications.
  • Applicable when many real-world phenomena that are modeled follow a normal distribution.
  • Linear congruential generator
  • Uniform distribution
  • Normal distribution