I am doing some random number generation and getting fishy behaviour. Here is my code:
// initialized earlier... in the constructor of a class
boost::mt19937 *rng = new boost::mt19937();
rng->seed(time(NULL));
// actual use here.
for (int i = 0; i < 10; ++i)
{
test();
}
void test()
{
boost::normal_distribution<> distribution(10, 10);
boost::variate_generator< boost::mt19937, boost::normal_distribution<> > resampler(*rng, distribution);
const double sample = (resampler)(); // always the same value.
}
Am I misusing the random sampling in boost? What have I done wrong to make that always be the same value. I initialize the random number generator in the constructor so it should always spit out a different value (not getting reinitialized)