Randomness comes flat — uniform between 0 and 1. The bell curve that runs all of statistics does not. Box–Muller is the exact spell that turns two flat numbers into two perfect Gaussians, using nothing but a square root, a log, and a circle. And I-13 already computes one of the three — the square root, by the Newton dart.
THE TECHNIQUE two uniforms → two Gaussians
Take two flat random numbers u₁, u₂ in (0,1]. Then z₀ = √(−2 ln u₁) · cos(2πu₂) and z₁ = √(−2 ln u₁) · sin(2πu₂) are two independent standard normals. Flat in, bell out. Watch the histogram fill the curve. live demo
r = √(−2 · ln u₁) // radius (Rayleigh)
z₀ = r · cos(2π u₂) // one normal
z₁ = r · sin(2π u₂) // a second, free
HISTORY & CREDIT a one-page note that stuck
A famous name and a footnote-length paper — the kind of result that is too simple to be important, and became universal anyway. cited
1958 · George E. P. Box & Mervin E. Muller publish a one-page note giving the exact transform — clean, closed-form, correct. the trick · it works because a 2-D Gaussian is radially symmetric: its radius follows a Rayleigh law (that is the √−2ln part) and its angle is uniform (the 2πu₂ part). later · George Marsaglia’s polar form drops the sin/cos by rejection sampling — faster on old hardware. the name · Box is the same statistician of “all models are wrong, some are useful” — a taste for the useful-and-exact shows here.
Sixty-odd years on, most “draw a normal” calls in the world still run this or its polar twin. universal
RECOMMEND FOR I-13 one of three already runs
Box–Muller needs three functions: √, ln, cos. I-13 already computes the square root — the Newton dart (026) proved it, to full f64 precision, with nothing but + − * / and recursion:
$ i13 run newton.i13 # from dart 026, still on main
root2 = 1.414213562373095 # √ needs no new primitive
The other two, ln and cos, are the same wall Metropolis (031) hit — not in the language:
Recommend: the transcendental stdlib, again — ln and cos as bounded Taylor/CORDIC functions written in I-13 (CORDIC was dart 009; Newton already gives √). No new opcodes, no new alphabet. With that one library, Box–Muller runs end-to-end but for the seeded PRNG. The pattern across this batch: Buffon wants random, Metropolis wants exp+random, Rabin–Miller wants bignum+random, Box–Muller wants ln+cos+random. Two asks recur — a seeded PRNG and a transcendental library — and both are additions on top of the 13 symbols, not changes to them. The core stays counted; the reach grows around it.