Boost logo

Boost Users :

From: Greg Landrum (greg.landrum_at_[hidden])
Date: 2008-04-13 11:57:13


Dear all,

After moving from boost 1.34.1 to 1.35.0 I have noticed that the
sequence of values returned by the minstd_rand generator has changed.
The following code snippet generates different values with 1.35.0 than
it did with 1.34.x and 1.33.x:

//-------------------------
  typedef boost::minstd_rand rng_type;
  typedef boost::uniform_int<> distrib_type;
  typedef boost::variate_generator<rng_type &,distrib_type> source_type;
  rng_type generator(42u);

  unsigned int seeds[] = {12,23,42};

  distrib_type dist(0,INT_MAX);
  source_type randomSource(generator,dist);

  for(unsigned int i=0;i<3;++i){
    generator.seed(seeds[i]);
    std::cerr << seeds[i];
    for(unsigned int j=0;j<5;++j){
      unsigned int bit = randomSource();
      std::cerr<<" "<<bit%1024;
    }
    std::cerr<<std::endl;
  }
//-------------------------

Output with v1.35.0:
12 691 854 1010 690 696
23 444 337 394 1000 751
42 404 8 37 977 972

and with v1.34.1:
12 691 844 854 975 292
23 214 852 444 337 394
42 883 404 943 348 8

If I use the mt19937 generator instead of minstd_rand, the sequences
are the same across versions. In the event it matters, I'm using g++
v4.1.3 on an Ubuntu Linux system.

Is this user error, the result of a bug fix in Boost.Random, a new bug
in Boost.Random, or is my expectation that the output of the RNG
should not change across releases unreasonable?

Thanks in advance for any help.

Best Regards,
-greg


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net