Commit cd86feb
committed
fix: implement Normal sampling via Box-Muller using rand 0.10 primitives only
rand::distr::StandardNormal does not exist in rand 0.10 — StandardNormal
is only in rand_distr, which conflicts with rand 0.10.
Instead, implement sample_normal() using the Box-Muller transform:
z = sqrt(-2 * ln(u1)) * cos(2π * u2) where u1,u2 ~ Uniform(0,1)
This uses only rand::distr::Uniform and rand::Rng from rand 0.10,
requiring no external crates.1 parent 7024190 commit cd86feb
1 file changed
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | | - | |
| 8 | + | |
10 | 9 | | |
11 | 10 | | |
12 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
25 | | - | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
0 commit comments