So, you use the Box-Muller method to pseudo-randomly select a random random variable. For this transformation to work, r1
it r2
must be evenly distributed independently of each other in [0,1].
r1/r2
[0,20], sqrt
, a > 1, nans.
double r1 = fRand(0, 1);
double r2 = fRand(0, 1);
, ++ 11 <random>
; fRand
- rand()
-to- double
. , .
FYI, , ++ 11
#include <random>
#include <iostream>
int main()
{
auto engine = std::default_random_engine{ std::random_device{}() };
auto variate = std::normal_distribution<>{ 0., 1. };
while(true)
std::cout << variate(engine) << std::endl;
}