Hand Calculations logo Hand Calculations All help pages ▾

Sample Normal⚠ unverified

General Calculations / Monte Carlo · Draw a sample from a normal distribution using the Box-Muller transform

Parameters

InputSymbolUnitDefaultDescription
muμ1.0Mean of the normal distribution
sigmaσ1.0Standard deviation of the normal distribution
OutputSymbolUnitDescription
resultzA single random sample from the normal distribution

The science & history

Understanding the Parameters

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

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.

← Back to the workspace  ·  All help pages  ·  Getting started