boost pseudo-random number generator

generator

length of cycle

approx. memory requirements

approx. speed compared to fastest

header file

minstd_rand0

231-2

sizeof(int32_t)

16%

boost/random/linear_congruential.hpp

minstd_rand

231-2

sizeof(int32_t)

16%

boost/random/linear_congruential.hpp

rand48

248-1

sizeof(uint64_t)

64%

boost/random/linear_congruential.hpp

ecuyer1988

approx. 261

2*sizeof(int32_t)

7%

boost/random/additive_combine.hpp

knuth_b

?

257*sizeof(uint32_t)

12%

boost/random/shuffle_order.hpp

kreutzer1986

?

98*sizeof(uint32_t)

37%

boost/random/shuffle_order.hpp

taus88

~288

3*sizeof(uint32_t)

100%

boost/random/taus88.hpp

hellekalek1995

231-1

sizeof(int32_t)

2%

boost/random/inversive_congruential.hpp

mt11213b

211213-1

352*sizeof(uint32_t)

100%

boost/random/mersenne_twister.hpp

mt19937

219937-1

625*sizeof(uint32_t)

93%

boost/random/mersenne_twister.hpp

mt19937_64

219937-1

312*sizeof(uint64_t)

38%

boost/random/mersenne_twister.hpp

lagged_fibonacci607

~232000

607*sizeof(double)

59%

boost/random/lagged_fibonacci.hpp

lagged_fibonacci1279

~267000

1279*sizeof(double)

59%

boost/random/lagged_fibonacci.hpp

lagged_fibonacci2281

~2120000

2281*sizeof(double)

61%

boost/random/lagged_fibonacci.hpp

lagged_fibonacci3217

~2170000

3217*sizeof(double)

62%

boost/random/lagged_fibonacci.hpp

lagged_fibonacci4423

~2230000

4423*sizeof(double)

59%

boost/random/lagged_fibonacci.hpp

lagged_fibonacci9689

~2510000

9689*sizeof(double)

61%

boost/random/lagged_fibonacci.hpp

lagged_fibonacci19937

~21050000

19937*sizeof(double)

59%

boost/random/lagged_fibonacci.hpp

lagged_fibonacci23209

~21200000

23209*sizeof(double)

61%

boost/random/lagged_fibonacci.hpp

lagged_fibonacci44497

~22300000

44497*sizeof(double)

59%

boost/random/lagged_fibonacci.hpp

ranlux3

~10171

24*sizeof(int)

5%

boost/random/ranlux.hpp

ranlux4

~10171

24*sizeof(int)

3%

boost/random/ranlux.hpp

ranlux64_3

~10171

24*sizeof(int64_t)

5%

boost/random/ranlux.hpp

ranlux64_4

~10171

24*sizeof(int64_t)

3%

boost/random/ranlux.hpp

ranlux3_01

~10171

24*sizeof(float)

5%

boost/random/ranlux.hpp

ranlux4_01

~10171

24*sizeof(float)

3%

boost/random/ranlux.hpp

ranlux64_3_01

~10171

24*sizeof(double)

5%

boost/random/ranlux.hpp

ranlux64_4_01

~10171

24*sizeof(double)

3%

boost/random/ranlux.hpp

ranlux24

~10171

24*sizeof(uint32_t)

5%

boost/random/ranlux.hpp

ranlux48

~10171

12*sizeof(uint64_t)

3%

boost/random/ranlux.hpp

Table 33.6. Uniform Distributions

distribution

explanation

example

header

uniform_smallint

discrete uniform distribution on a small set of integers (much smaller than the range of the underlying generator)

drawing from an urn

boost/random/uniform_smallint.hpp

uniform_int_distribution

discrete uniform distribution on a set of integers; the underlying generator may be called several times to gather enough randomness for the output

drawing from an urn

boost/random/uniform_int_distribution.hpp

uniform_01

continuous uniform distribution on the range [0,1); important basis for other distributions

-

boost/random/uniform_01.hpp

uniform_real_distribution

continuous uniform distribution on some range [min, max) of real numbers

for the range [0, 2pi): randomly dropping a stick and measuring its angle in radians (assuming the angle is uniformly distributed)

boost/random/uniform_real_distribution.hpp


Table 33.7. Bernoulli Distributions

distribution

explanation

example

header

bernoulli_distribution

Bernoulli experiment: discrete boolean valued distribution with configurable probability

tossing a coin (p=0.5)

boost/random/bernoulli_distribution.hpp

binomial_distribution

counts outcomes of repeated Bernoulli experiments

tossing a coin 20 times and counting how many front sides are shown

boost/random/binomial_distribution.hpp

geometric_distribution

measures distance between outcomes of repeated Bernoulli experiments

throwing a die several times and counting the number of tries until a "6" appears for the first time

boost/random/geometric_distribution.hpp

negative_binomial_distribution

Counts the number of failures of repeated Bernoulli experiments required to get some constant number of successes.

flipping a coin and counting the number of heads that show up before we get 3 tails

boost/random/negative_binomial_distribution.hpp


Table 33.8. Poisson Distributions

distribution

explanation

example

header

poisson_distribution

poisson distribution

counting the number of alpha particles emitted by radioactive matter in a fixed period of time

boost/random/poisson_distribution.hpp

exponential_distribution

exponential distribution

measuring the inter-arrival time of alpha particles emitted by radioactive matter

gamma_distribution

gamma distribution

-

hyperexponential_distribution

hyperexponential distribution

service time of k-parallel servers each with a given service rate and probability to be chosen

weibull_distribution

weibull distribution

-

extreme_value_distribution

extreme value distribution

-

beta_distribution

beta distribution

-

laplace_distribution

laplace distribution

-


Table 33.9. Normal Distributions

distribution

explanation

example

normal_distribution

counts outcomes of (infinitely) repeated Bernoulli experiments

tossing a coin 10000 times and counting how many front sides are shown

lognormal_distribution

lognormal distribution (sometimes used in simulations)

measuring the job completion time of an assembly line worker

chi_squared_distribution

chi-squared distribution

-

non_central_chi_squared_distribution

non-central chi-squared distribution

-

cauchy_distribution

Cauchy distribution

-

fisher_f_distribution

Fisher F distribution

-

student_t_distribution

Student t distribution

-


Table 33.10. Sampling Distributions

distribution

explanation

example

discrete_distribution

discrete distribution with specific probabilities

rolling an unfair die

piecewise_constant_distribution

-

-

piecewise_linear_distribution

-

-


Table 33.11. Miscellaneous Distributions

distribution

explanation

example

triangle_distribution

triangle distribution

-

uniform_on_sphere

uniform distribution on a unit sphere of arbitrary dimension

choosing a random point on Earth (assumed to be a sphere) where to spend the next vacations