Fix random::normal_distribution: actually use mean & stddev instead of always generating N(0,1)
This commit is contained in:
parent
04443b1e3a
commit
752593a589
1 changed files with 2 additions and 2 deletions
|
|
@ -64,8 +64,8 @@ namespace psemek::random
|
|||
T const r = std::sqrt(- 2 * std::log(u1));
|
||||
T const th = 2 * geom::pi * u2;
|
||||
|
||||
T const z1 = r * std::cos(th);
|
||||
T const z2 = r * std::sin(th);
|
||||
T const z1 = mean_ + stddev_ * r * std::cos(th);
|
||||
T const z2 = mean_ + stddev_ * r * std::sin(th);
|
||||
|
||||
cached_ = z2;
|
||||
return z1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue