Main Page | See live article | Alphabetical index

Box-Muller transform

A Box-Muller transform is a method of generating pairs of independent normally distributed random numbers, given a source of uniformly distributed random numbers. There are two kinds:

  1. Given r and φ independently uniformly distributed in (0,1], compute:
    and
  2. Given x and y independently uniformly distributed in [-1,1], set r = x2+y2. If r = 0 or r > 1, throw them away and try another pair (x, y). Thus, all points left after this filtering process will be uniformly distributed within a unit circle. Then, for these filtered points, compute:
    and

The second method is faster because it uses only one transcendental function instead of three, even though it throws away 21% of the numbers.

External links