Boost Random Number LibraryRandom numbers are useful in a variety of applications. The Boost Random Number Library (Boost.Random for short) provides a vast variety of generators and distributions to produce random numbers having useful properties, such as uniform distribution. 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 Library OrganizationThe library is separated into several header files, all within the
A front-end class template called
<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. TestsAn extensive test suite for the pseudo-random number generators and distributions is available as random_test.cpp. Some performance results obtained using random_speed.cpp are also available. RationaleThe methods for generating and evaluating deterministic and non-deterministic random numbers differ radically. Furthermore, due to the inherent deterministic design of present-day computers, it is often difficult to implement non-deterministic random number generation facilities. Thus, the random number library is split into separate header files, mirroring the two different application domains. History and AcknowledgementsIn November 1999, Jeet Sukumaran proposed a framework based on virtual
functions, and later sketched a template-based approach. Ed Brey pointed
out that Microsoft Visual C++ does not support in-class member
initializations and suggested the 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 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
Revised 05 December, 2006 Copyright © 2000-2005 Jens Maurer 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) |