You should read the concepts documentation for an introduction and the definition of the basic concepts. For a quick start, it may be sufficient to have a look at random_demo.cpp.
For a very quick start, here's an example:
boost::mt19937 rng; // produces randomness out of thin air // see pseudo-random number generators boost::uniform_int<> six(1,6) // distribution that maps to 1..6 // see random number distributions boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(rng, six); // glues randomness with mapping int x = die(); // simulate rolling a die
boost/random/directory. Additionally, a convenience header file which includes all other headers in
boost/random/is available as
A front-end class template called
provided; please read the
documentation about it.
<boost/nondet_random.hpp>. Documentation is also available.
In order to map the interface of the generators and distribution functions to other concepts, some decorators are available.
Some performance results obtained using random_speed.cpp are also available.
enumworkaround. Dave Abrahams highlighted quantization issues.
The first public release of this random number library materialized in
March 2000 after extensive discussions on the boost mailing list.
Many thanks to Beman Dawes for his original
class, portability fixes, documentation suggestions, and general
guidance. Harry Erwin sent a header file which provided additional
insight into the requirements. Ed Brey and Beman Dawes wanted an
Beman Dawes managed the formal review, during which Matthias Troyer, Csaba Szepesvari, and Thomas Holenstein gave detailed comments. The reviewed version became an official part of boost on 17 June 2000.
Gary Powell contributed suggestions for code cleanliness. Dave
Abrahams and Howard Hinnant suggested to move the basic generator
templates from namespace
Ed Brey asked to remove superfluous warnings and helped with
uint64_t handling. Andreas Scherer tested with MSVC.
Matthias Troyer contributed a lagged Fibonacci generator. Michael
Stevens found a bug in the copy semantics of normal_distribution and
suggested documentation improvements.