Module 9Random NumbersLesson 7 of 824 min
Box-Muller Normals
From uniforms to standard normals; check mean/std.
Box-Muller
Z0 = sqrt(-2 ln U1) cos(2 pi U2)
Z1 with sin — two normals per pair.
Sanity check
Large sample: mean≈0, std≈1.
Challenge
Generate lognormal spots S*exp((r-0.5sig^2)t + sig*sqrt(t)*Z).
Tips
- Two Zs per pair
- Check moments
- rand_distr::StandardNormal offline
Try it live
Box-Muller NormalsRust 2021
Loading editor…
Output
Press Run to compile and execute.