/* boost random_test.cpp various tests * * Copyright Matthias Troyer 2006 * Distributed under the Boost Software License, Version 1.0. (See * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * $Id$ */ #include #include #include // A simple example simulation - usually it will be much more complex double simulate(boost::buffered_uniform_01& gen) { double sum=0; for (int i=0;i<100000;i++) sum += gen(); typedef boost::variate_generator&,boost::normal_distribution<> > gen_type; gen_type gauss(gen,boost::normal_distribution<>()); for (int i=0;i<100000;i++) sum += gauss(); return sum; } // create a buffered_generator template void simulate_it() { boost::basic_buffered_uniform_01 gen; std::cout << simulate(gen) << "\n"; } // call the simulation with two different generators int main() { simulate_it(); simulate_it(); }