Skip to content

Random Number Generation

Uniform Distribution of Numbers

This visualization generates and plots 500 integers in the range [0, 10).

Normal distribution of numbers

Box-Muller Transform for Generating Gaussian-Distributed Numbers

  • Wikipedia - Box-Muller Transform

  • Summary of steps

    1. Generate two uniformly distributed random numbers in range (0, 1): U_1, U_2
    2. Let R^2 = -2 * lnU_1
    3. Let \theta = 2\pi U_2
    4. Then Z_1 = R * cos(\theta) and Z_2 = R * sin(\theta) are two independent numbers with a standard normal distribution.
  • Play with it below! 🕹
    • When the mouse is within the grey area (1x1 rectangle), mouse x is used as U_1 and mouse y is used as U_2.
    • Result Z_1 is drawn on top, and Z_2 is drawn on the right