I'm using the mt19937 generator to generate normal random numbers as shown below:
normal_distribution<double> normalDistr(0, 1);
mt19937 generator(123);
vector<double> randNums(1000000);
for (size_t i = 0; i != 1000000; ++i)
{
randNums[i] = normalDistr(generator);
}
The above code works, however since I'm generating more than 100 million normal random numbers in my code, the above is very slow.
Is there a faster way to generate normal random numbers?
The following is some background on how the code would be used:
- Quality of the random numbers is not that important
- Precision of the numbers is not that important, either
doubleorfloatis OK - The normal distribution always has mean = 0 and sigma = 1
Aucun commentaire:
Enregistrer un commentaire