We have the following code to generate normally distributed random numbers.
double average = 10.0; double spread = 4.0;
std::mt19937 generator;
generator.seed(1);
std::normal_distribution<double> distribution(average, spread);
for (uint i = 0; i < 10; i++)
cout << "randomNumber=" << distribution(generator) << endl;
This should produce the same exact sequence on Linux and Windows. But it doesn't. The sequences are identical when rerun on the same OS. But the sequences are different when run on Linux vs. Windows. The generators are the same and the seeds are the same, so they should give identical sequences.
What's missing or incorrect that would allow the code to create identical sequences on both operating systems?
Windows 10. Visual Studio 2010.
Ubuntu 14.04. g++ (gcc 4.9.2)
Windows Output:
randomNumber=10.6243
randomNumber=11.2256
randomNumber=7.72784
randomNumber=8.30245
randomNumber=6.77485
randomNumber=9.18181
randomNumber=5.19982
randomNumber=8.28505
randomNumber=5.24899
randomNumber=15.2219
Linux Output:
randomNumber=7.80102
randomNumber=4.38851
randomNumber=16.331
randomNumber=5.81941
randomNumber=11.0304
randomNumber=2.16242
randomNumber=3.96877
randomNumber=8.73883
randomNumber=13.4327
randomNumber=10.2854
Aucun commentaire:
Enregistrer un commentaire