
Hi, Sorry, wait!!! int main() { double p = 0.5; boost::mt19937 rng; boost::bernoulli_distribution<> d(p); boost::variate_generator< boost::mt19937&, boost::bernoulli_distribution<>
g(rng, d);
for(int i = 0; i < 10; ++i) { std::cout << g() << std::endl; } } This really works. but If I write this in a function: int genB() { double p = 0.5; boost::mt19937 rng; boost::bernoulli_distribution<> d(p); boost::variate_generator< boost::mt19937&, boost::bernoulli_distribution<>
g(rng, d);
return g() ; } int main(){ for(int i = 0; i < 10; ++i) { std::cout << genB() << std::endl; } } I'll got always 0.... Why? On Tue, Mar 31, 2009 at 2:06 PM, Barco You <barcojie@gmail.com> wrote:
Hi Steven,
Fine now! Thanks a lot!
On Tue, Mar 31, 2009 at 11:11 AM, Steven Watanabe <watanabesj@gmail.com>wrote:
AMDG
Barco You wrote:
I call it 1000 time, and all output is 0.
Works for me...
#include <boost/random.hpp> #include <iostream>
int main() { double p = 0.5; boost::mt19937 rng; boost::bernoulli_distribution<> d(p); boost::variate_generator< boost::mt19937&, boost::bernoulli_distribution<>
g(rng, d);
for(int i = 0; i < 10; ++i) { std::cout << g() << std::endl;
} }
In Christ, Steven Watanabe
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- ------------------------------- Enjoy life! Barco You
-- ------------------------------- Enjoy life! Barco You