Box-Muller Transform
Overview
The Box-Muller transform converts a pair of independent uniform random numbers into a pair of independent standard normal samples. It is the sampler behind every Gaussian draw in this app — most prominently the input-noise perturbations of the Robustness widget — chosen because it is exact (not an approximation), branch-free, and easy to make reproducible on top of the app's deterministic ChaCha8-based RNG.
Formula
Given two independent uniform variates :
Then and they are independent.
The construction is a change of variables to polar coordinates: gives the squared radius the chi-squared distribution with 2 degrees of freedom (the distribution of for a standard bivariate normal), while picks the angle uniformly. Mapping the pair back to Cartesian coordinates yields two independent standard normals.
A general Gaussian sample is obtained by scaling and shifting: .
Characteristics
- Exact: the output follows the normal distribution exactly (up to floating-point error), unlike approximations such as summing twelve uniforms.
- Domain care: requires . Since the underlying generator returns values in , Tunny Dashboard feeds (which lies in ) to the logarithm, so a raw draw of exactly cannot produce .
- This app uses only the cosine branch ( ) and discards , trading a factor-of-two efficiency for a simpler, stateless call. The cost is irrelevant at the sample counts involved (thousands per analysis).
- Reproducibility: driven by the seeded ChaCha8 RNG, the same seed always yields the same Gaussian sequence — which is what makes robustness-analysis results deterministic for fixed settings.
- Tail behavior is limited by the resolution of near : with 53-bit doubles the largest attainable is about , far beyond anything relevant at the sample sizes used here.
Where It Is Used in the App
- Robustness widget: generates the Gaussian input-noise perturbations around the candidate design, and (when "Model uncertainty" is enabled) the draws from the GP posterior.
References
- Box, G. E. P., & Muller, M. E. (1958). A Note on the Generation of Random Normal Deviates. Annals of Mathematical Statistics, 29(2), 610–611. https://doi.org/10.1214/aoms/1177706645