Here is my code. It suppose to generate normal_distribution
.
#include <iostream>
#include <random>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/normal_distribution.hpp>
int main(int argc, const char *argv[])
{
// Initialize seed .
std::mt19937 gena;
boost::random::mt19937 genb;
gena.seed( 10 );
genb.seed( 10 );
std::normal_distribution<> norma;
boost::random::normal_distribution<> normb;
std::cout << "STD BOOST" << std::endl;
for (size_t i = 0; i < 20; i++)
std::cout << norma(gena) << ' ' << normb(genb) << std::endl;
return 0;
}
I compile it with gcc-8.1
on arch-linux, and I get the following:
STD BOOST
-0.0512656 1.16196
-1.90693 -0.742973
1.23919 -1.10165
-0.212754 1.03149
-0.376303 0.597194
0.0660327 -0.12573
-1.01706 1.10728
0.907624 -0.370934
-0.682124 -0.404068
-0.461218 -0.46376
0.965666 -0.607265
0.560664 -1.44186
0.749932 0.449968
-0.31456 -0.268649
0.366249 0.986499
0.608089 -0.500526
-1.08684 -0.0215645
0.120559 -0.805144
1.40203 0.390409
-0.434259 0.0991071
I use the same code on a Mac machine (Apple LLVM version 7.0.2 (clang-700.1.81)
); and I get the following:
STD BOOST
-1.90693 1.16196
-0.0512656 -0.742973
-0.212754 -1.10165
1.23919 1.03149
0.0660327 0.597194
-0.376303 -0.12573
0.907624 1.10728
-1.01706 -0.370934
-0.461218 -0.404068
-0.682124 -0.46376
0.560664 -0.607265
0.965666 -1.44186
-0.31456 0.449968
0.749932 -0.268649
0.608089 0.986499
0.366249 -0.500526
0.120559 -0.0215645
-1.08684 -0.805144
-0.434259 0.390409
1.40203 0.0991071
Note the first column which uses std::random
is different; but if you look closely, first column have many elements common but seem to be shuffled.
I am worried after one test broke on Travis (that means, Ububtu-14.04 and xcode-9.2 will show the same results) after we replaced our old normal distribution generator in favor of std::random
.
Is it a bug? Or I am doing something wrong? BOOST is doing OK.