Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Random Number Generators and Distributions.

#include <boost/tr1/random.hpp>

or

#include <random>

The random number library is divided into three parts: generators, which are nullary functors producing uniform random number distributions. Distributions, which are unary functors that adapt a generator to some specific kind of distribution. And the class template variate_generator which combines a generator with a distribution, to create a new generator. For more information see the Boost.Random documentation.

namespace std {
namespace tr1 {

// [5.1.3] Class template variate_generator
template<class UniformRandomNumberGenerator, class Distribution>
class variate_generator;

// [5.1.4.1] Class template linear_congruential
template<class IntType, IntType a, IntType c, IntType m>
class linear_congruential;

// [5.1.4.2] Class template mersenne_twister
template<class UIntType, int w, int n, int m, int r,
UIntType a, int u, int s, UIntType b, int t, UIntType c, int l>
class mersenne_twister;

// [5.1.4.3] Class template substract_with_carry
template<class IntType, IntType m, int s, int r>
class subtract_with_carry;

// [5.1.4.4] Class template substract_with_carry_01
template<class RealType, int w, int s, int r>
class subtract_with_carry_01;

// [5.1.4.5] Class template discard_block
template<class UniformRandomNumberGenerator, int p, int r>
class discard_block;

// [5.1.4.6] Class template xor_combine
template<class UniformRandomNumberGenerator1, int s1,
class UniformRandomNumberGenerator2, int s2>
class xor_combine;

// [5.1.5] Predefined generators
typedef linear_congruential<
            implementation-defined ,
            16807,
            0,
            2147483647> minstd_rand0;

typedef linear_congruential<
            implementation-defined ,
            48271,
            0,
            2147483647> minstd_rand;

typedef mersenne_twister<
            implementation-defined ,
            32, 624, 397, 31,
            0x9908b0df, 11, 7,
            0x9d2c5680, 15,
            0xefc60000, 18> mt19937;

typedef subtract_with_carry_01<
            float,
            24,
            10,
            24> ranlux_base_01;

typedef subtract_with_carry_01<
            double,
            48,
            10,
            24> ranlux64_base_01;

typedef discard_block<
            subtract_with_carry<
                  implementation-defined ,
                  (1<<24),
                  10,
                  24>,
            223,
            24> ranlux3;

typedef discard_block<
            subtract_with_carry<
                  implementation-defined,
                  (1<<24),
                  10,
                  24>,
            389,
            24> ranlux4;

typedef discard_block<
            subtract_with_carry_01<
                  float,
                  24,
                  10,
                  24>,
            223,
            24> ranlux3_01;

typedef discard_block<
            subtract_with_carry_01<
                  float,
                  24,
                  10,
                  24>,
            389,
            24> ranlux4_01;

// [5.1.6] Class random_device
class random_device;

// [5.1.7.1] Class template uniform_int
template<class IntType = int>
class uniform_int;

// [5.1.7.2] Class bernoulli_distribution
class bernoulli_distribution;

// [5.1.7.3] Class template geometric_distribution
template<class IntType = int, class RealType = double>
class geometric_distribution;

// [5.1.7.4] Class template poisson_distribution
template<class IntType = int, class RealType = double>
class poisson_distribution;

// [5.1.7.5] Class template binomial_distribution
template<class IntType = int, class RealType = double>
class binomial_distribution;

// [5.1.7.6] Class template uniform_real
template<class RealType = double>
class uniform_real;

// [5.1.7.7] Class template exponential_distribution
template<class RealType = double>
class exponential_distribution;

// [5.1.7.8] Class template normal_distribution
template<class RealType = double>
class normal_distribution;

// [5.1.7.9] Class template gamma_distribution
template<class RealType = double>
class gamma_distribution;

} // namespace tr1
} // namespace std

Configuration: Boost.Config should (automatically) define the macro BOOST_HAS_TR1_RANDOM if your standard library implements this part of TR1.

Standard Conformity: The Boost implementation has the following limitations:

Note also that most of the Random number generators have been re-implemented as thin wrappers around the Boost versions in order to provide a standard conforming interface (the Boost versions all take an additional, redundant, template parameter, and are initialized by iterators rather than functors).


PrevUpHomeNext