Boost logo

Boost Users :

From: Kevin Martin (kev82_at_[hidden])
Date: 2008-06-03 09:00:41


I found this in the archive:

http://thread.gmane.org/gmane.comp.lib.boost.user/26685

I am experiencing the same problem. However it works with
variate_generator - see attached code. Is this simply a documentation
bug which should say `Must always use variate_generator' or are the
distributions supposed to work with any source of randomness? In which
case they don't in 1.35.0 and I will go report it.

Thanks,
Kevin Martin

#include <boost/random.hpp>
#include <iostream>

template<typename Randmoness_>void func1(Randmoness_ &r) {
     boost::normal_distribution<> x(180, 60);
     boost::uniform_real<> X(5.0, 10.0);

     std::cout << x(r) << " " << X(r) << std::endl;
}

template<typename Randmoness_>void func2(Randmoness_ &r) {
     boost::normal_distribution<> x(180, 60);
     boost::variate_generator<Randmoness_ &,
boost::normal_distribution<> > y(r, x);

     boost::uniform_real<> X(5.0,10.0);
     boost::variate_generator<Randmoness_ &, boost::uniform_real<> >
Y(r, X);

     std::cout << y() << " " << Y() << std::endl;
}

int main() {
     boost::mt19937 rng;
     func1(rng);
     func2(rng);

     return 0;
}


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