| Home | Libraries | People | FAQ | More

## Chapter 21. Boost.Random

### Jens Maurer

Copyright © 2000-2005 Jens Maurer

Copyright © 2009, 2010 Steven Watanabe

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)

## Introduction

Random numbers are useful in a variety of applications. The Boost Random Number Library (Boost.Random for short) provides a 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::random::mt19937 rng;         // produces randomness out of thin air
                                        // see pseudo-random number generators
    boost::random::uniform_int_distribution<> six(1,6);
                                        // distribution that maps to 1..6
                                        // see random number distributions
    int x = six(rng);                   // simulate rolling a die

Last revised: February 20, 2012 at 20:51:25 GMT |