Boost.Random.uniform_01 gives different number sequence in Boost 1.37 and Boost 1.45

Hi. It seems that uniform_01 generates different number sequences in version 1.37 and 1.45 Is this intentional, or is it a bug? This short program #include <iostream> #include "boost/random/mersenne_twister.hpp" #include "boost/random/uniform_01.hpp" int main() { boost::mt19937 random_generator(4315); boost::uniform_01< boost::mt19937, double > uniform_generator(random_generator); std::cout<<"Generating uniform distribution using Boost 1.45"<<std::endl; for (int i=0; i<10;++i) { std::cout<<uniform_generator()<<std::endl; } return 0; } Compiled with the two versions, gives the respective output: D:\dev\test_bed>uniform_dist_boost_1_37 Generating uniform distribution using Boost 1.37 0.239136 0.920749 0.889477 0.208172 0.169688 0.636659 0.78322 0.915117 0.25697 0.358218 D:\dev\\test_bed>uniform_dist_boost_1_45 Generating uniform distribution using Boost 1.45 0.306389 0.511291 0.496429 0.156168 0.910315 0.644836 0.331514 0.558632 0.723934 0.998796 As far as I can tell, Boost.mt19937 gives the same number sequence in both cases, but the output from Boost.uniform_01 differs. This topic has been briefly touched in the thread [boost] Random numbers question<154235.php> Anant Rao (2009-07-24 18:47:31) Where it seems like Rao got different numbers even between Boost 1.38 and Boost 1.39 We use Boost 1.37 in the previous release of our software, and Boost 1.45 in the current, and we have received a bug report from one of our clients that our current release has different behaviour. Is there any way to fix this, other than use the 1.37 version of Boost.uniform_01? Thanks, Martin Søvik

AMDG On 11/16/2011 05:28 AM, Martin.Sovik@Emerson.com wrote:
Hi. It seems that uniform_01 generates different number sequences in version 1.37 and 1.45 Is this intentional, or is it a bug?
This change is intentional. Here's what's happening: In 1.37, constructing uniform_generator calls seed to initialize the generator. In 1.45, it calls the copy constructor. Thus, the stored generator ends up in a different state. To get the old behavior add uniform_generator.base().seed(random_generator);
This short program
#include <iostream> #include "boost/random/mersenne_twister.hpp" #include "boost/random/uniform_01.hpp" int main() { boost::mt19937 random_generator(4315); boost::uniform_01< boost::mt19937, double > uniform_generator(random_generator); std::cout<<"Generating uniform distribution using Boost 1.45"<<std::endl; for (int i=0; i<10;++i) { std::cout<<uniform_generator()<<std::endl; } return 0; }
Compiled with the two versions, gives the respective output:
D:\dev\test_bed>uniform_dist_boost_1_37 Generating uniform distribution using Boost 1.37 0.239136 0.920749 0.889477 0.208172 0.169688 0.636659 0.78322 0.915117 0.25697 0.358218 D:\dev\\test_bed>uniform_dist_boost_1_45 Generating uniform distribution using Boost 1.45 0.306389 0.511291 0.496429 0.156168 0.910315 0.644836 0.331514 0.558632 0.723934 0.998796
As far as I can tell, Boost.mt19937 gives the same number sequence in both cases, but the output from Boost.uniform_01 differs.
This topic has been briefly touched in the thread
[boost] Random numbers question<154235.php> Anant Rao (2009-07-24 18:47:31) Where it seems like Rao got different numbers even between Boost 1.38 and Boost 1.39
We use Boost 1.37 in the previous release of our software, and Boost 1.45 in the current, and we have received a bug report from one of our clients that our current release has different behaviour. Is there any way to fix this, other than use the 1.37 version of Boost.uniform_01?
In Christ, Steven Watanabe
participants (2)
-
Martin.Sovik@Emerson.com
-
Steven Watanabe