
Oh, although the code was run with just one variate_generator, I transcribed in my post one line of the code erroneously: where is die(gen, normal) it should be rng(gen, normal) Anyway I got that strange output using just one variate_generator everywhere: variate_generator<std::mt19937 &,std::normal_distribution<> > rng(gen, normal); Steven, does your comment still applies in this case? 2011/1/28 Steven Watanabe <watanabesj@gmail.com>:
AMDG
On 1/27/2011 6:18 PM, Anton Skvorts wrote:
I'm still having some problems with boost::random, obviously because I don't fully understand all that s going on... Read the documentation and your post but still cannot find what is wrong with my code bellow:
Notice that you have two separate variate_generators, one in the main code, and one for each call to normalReseed. Each normal_distribution object has its own cache. When you call reset, you need to make sure that you call it on the distribution that you are using.
extern "C" __declspec(dllexport) double normalReseed(double mean, double sigma, uint32_t x){ boost::normal_distribution<> normal(mean,sigma); boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > rng(gen, normal); rng.engine().seed(x); rng.distribution().reset(); return rng(); } boost::mt19937 gen; boost::normal_distribution<> normal(0,1); boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > die(gen, normal); cout<< rng()<< endl; cout<< rng()<< endl; cout<< rng()<< endl; cout<< normalReseed(0, 1, 0)<< endl; cout<< rng()<< endl; <snip>
Possibly are again cached results from Box-Muller algorithm the reason for this pattern but still cannot see why we get these results, neither how to overcome this problem
In Christ, Steven Watanabe _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost