Sample Normal⚠ unverified
General Calculations / Monte Carlo · Draw a sample from a normal distribution using the Box-Muller transform
Parameters
| Input | Symbol | Unit | Default | Description |
|---|---|---|---|---|
| mu | μ | — | 1.0 | Mean of the normal distribution |
| sigma | σ | — | 1.0 | Standard deviation of the normal distribution |
| Output | Symbol | Unit | Description |
|---|---|---|---|
| result | z | — | A single random sample from the normal distribution |
The science & history
Understanding the Parameters
-
Mean $\mu$ and standard deviation $\sigma$ — the two parameters of the target distribution (Normal Distribution PDF). The transform first produces a standard normal $z \sim \mathcal N(0,1)$, then shifts and scales it: $x = \mu + \sigma z$. So $\mu$ locates the samples and $\sigma$ sets their spread, exactly as in the PDF.
-
The uniform inputs $U_1, U_2$ — not user parameters but internally-drawn uniform random numbers on $(0,1)$ (the output of a pseudo-random generator). They are the "raw randomness" the transform converts into a Gaussian.
-
The output $x$ — a single realisation. On its own it is just one random number; its distribution over many calls is normal with the requested mean and variance. In a Monte Carlo study each model input is sampled this way every iteration.
-
Why sample at all. When a model is too complex for analytic uncertainty propagation, Monte Carlo replaces the math with brute force: sample the inputs from their distributions, evaluate the model, and read the output distribution empirically. Gaussian sampling is the most common ingredient because so many quantities are normal (central limit theorem).
Derivation (Approaching a Proof)
The Box–Muller transform converts two independent uniforms into two independent standard normals. Consider a standard 2-D Gaussian, whose joint density is $\frac{1}{2\pi}e^{-(z_1^2+z_2^2)/2}$. In polar coordinates $(R, \theta)$ with $z_1 = R\cos\theta$, $z_2 = R\sin\theta$, the density factorises: $\theta$ is uniform on $[0, 2\pi)$, and the radius satisfies $P(R > r) = e^{-r^2/2}$ (a Rayleigh distribution), so $R^2$ is exponential with mean $2$.
To generate these from uniforms $U_1, U_2 \sim \text{Uniform}(0,1)$: draw the exponential radius by inverse transform, $R = \sqrt{-2\ln U_1}$ (since $-2\ln U_1$ is exponential with mean $2$), and the uniform angle, $\theta = 2\pi U_2$. Then
$$z = R\cos\theta = \sqrt{-2\ln U_1}\,\cos(2\pi U_2)$$
is standard normal. (The sine component gives a second independent normal, discarded here.) Applying the location–scale property of the normal — if $z \sim \mathcal N(0,1)$ then $\mu + \sigma z \sim \mathcal N(\mu, \sigma^2)$ — yields the sample
$$x = \mu + \sigma z. \qquad\blacksquare$$
Dimensional check. $z$ is a dimensionless standard normal; $\sigma$ carries the measurand's units, so $x = \mu + \sigma z$ has the same units as $\mu$. $\checkmark$
History and Development
-
Box and Muller, 1958. George Box and Mervin Muller published the transform as an exact, elegant way to generate normal deviates from uniform ones — a staple of simulation ever since. Its only cost is the transcendental functions ($\ln$, $\cos$); the Marsaglia polar and Ziggurat methods later traded them for speed.
-
Monte Carlo method. Named for the casino and developed by Ulam, von Neumann, and Metropolis at Los Alamos in the 1940s, Monte Carlo simulation uses repeated random sampling to solve problems intractable analytically — neutron transport originally, now everything from finance to uncertainty propagation (Sample Uniform, Sample Weibull).
-
In engineering uncertainty. Monte Carlo is the GUM's "Supplement 1" method for uncertainty propagation: sample every input from its distribution, push through the model, and read off the output uncertainty directly — invaluable when the model is nonlinear and linear propagation (Relative Uncertainty, Expanded Uncertainty) breaks down.
Related Concepts: Normal Distribution PDF, Sample Uniform, Sample Weibull, Expanded Uncertainty, Relative Uncertainty
Notes: Registry calculator sample-normal (unverified). Stochastic sampler — returns a new random draw
each call (not reproducible); use many draws. Box–Muller: $z = \sqrt{-2\ln U_1}\cos(2\pi U_2)$ then
$x = \mu + \sigma z$ (latex shows only the $z$ step). Building block of Monte Carlo uncertainty propagation.