/* 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_generator& gen) { double sum=0; for (int i=0;i<100000;i++) sum += gen(); return sum; } // create a buffered_generator template void simulate_it() { typedef boost::variate_generator > gen_type; RNG engine; boost::basic_buffered_generator gen(gen_type(engine,boost::normal_distribution<>())); std::cout << simulate(gen) << "\n"; } // call the simulation with two different generators int main() { simulate_it(); simulate_it(); }