Standard library header <random>
This header is part of the pseudo-random number generation library.
Random number engines | |
(C++11) |
implements linear congruential algorithm (class template) |
(C++11) |
implements Mersenne twister algorithm (class template) |
(C++11) |
implements subtract with carry (a lagged Fibonacci) algorithm (class template) |
Random number engine adaptors | |
(C++11) |
discards some output of a random number engine (class template) |
(C++11) |
packs the output of a random number engine into blocks of specified number of bits (class template) |
(C++11) |
delivers the output of a random number engine in different order (class template) |
Predefined generators | |
minstd_rand0
|
std::linear_congruential_engine<std::uint_fast32_t, 16807, 0, 2147483647> Discovered in 1969 by Lewis, Goodman and Miller, adopted as "Minimal standard" in 1988 by Park and Miller |
minstd_rand
|
std::linear_congruential_engine<std::uint_fast32_t, 48271, 0, 2147483647> Newer "Minimum standard", recommended by Park, Miller, and Stockmeyer in 1993 |
mt19937
|
std::mersenne_twister_engine<std::uint_fast32_t, 32, 624, 397, 31, |
mt19937_64
|
std::mersenne_twister_engine<std::uint_fast64_t, 64, 312, 156, 31, |
ranlux24_base
|
std::subtract_with_carry_engine<std::uint_fast32_t, 24, 10, 24> |
ranlux48_base
|
std::subtract_with_carry_engine<std::uint_fast64_t, 48, 5, 12> |
ranlux24
|
std::discard_block_engine<std::ranlux24_base, 223, 23> 24-bit RANLUX generator by Martin Lüscher and Fred James, 1994 |
ranlux48
|
std::discard_block_engine<std::ranlux48_base, 389, 11> 48-bit RANLUX generator by Martin Lüscher and Fred James, 1994 |
knuth_b
|
std::shuffle_order_engine<std::minstd_rand0, 256> |
default_random_engine
|
implementation-defined |
Non-deterministic random numbers | |
non-deterministic random number generator using hardware entropy source (class) | |
Uniform distributions | |
(C++11) |
produces integer values evenly distributed across a range (class template) |
(C++11) |
produces real values evenly distributed across a range (class template) |
Bernoulli distributions | |
(C++11) |
produces bool values on a Bernoulli distribution. (class) |
(C++11) |
produces integer values on a binomial distribution. (class template) |
produces integer values on a negative binomial distribution. (class template) | |
(C++11) |
produces integer values on a geometric distribution. (class template) |
Poisson distributions | |
(C++11) |
produces integer values on a poisson distribution. (class template) |
(C++11) |
produces real values on an exponential distribution. (class template) |
(C++11) |
produces real values on an gamma distribution. (class template) |
(C++11) |
produces real values on a Weibull distribution. (class template) |
(C++11) |
produces real values on an extreme value distribution. (class template) |
Normal distributions | |
(C++11) |
produces real values on a standard normal (Gaussian) distribution. (class template) |
(C++11) |
produces real values on a lognormal distribution. (class template) |
(C++11) |
produces real values on a chi-squared distribution. (class template) |
(C++11) |
produces real values on a Cauchy distribution. (class template) |
(C++11) |
produces real values on a Fisher's F-distribution. (class template) |
(C++11) |
produces real values on a Student's t-distribution. (class template) |
Sampling distributions | |
(C++11) |
produces random integers on a discrete distribution. (class template) |
produces real values distributed on constant subintervals. (class template) | |
produces real values distributed on defined subintervals. (class template) | |
Utilities | |
(C++11) |
evenly distributes real values of given precision across [0, 1) (function template) |
(C++11) |
general-purpose bias-eliminating scrambled seed sequence generator (class) |
Synopsis
#include <initializer_list> namespace std { // class template linear_congruential_engine template<class UIntType, UIntType a, UIntType c, UIntType m> class linear_congruential_engine; // class template mersenne_twister_engine template<class UIntType, size_t w, size_t n, size_t m, size_t r, UIntType a, size_t u, UIntType d, size_t s, UIntType b, size_t t, UIntType c, size_t l, UIntType f> class mersenne_twister_engine; // class template subtract_with_carry_engine template<class UIntType, size_t w, size_t s, size_t r> class subtract_with_carry_engine; // class template discard_block_engine template<class Engine, size_t p, size_t r> class discard_block_engine; // class template independent_bits_engine template<class Engine, size_t w, class UIntType> class independent_bits_engine; // class template shuffle_order_engine template<class Engine, size_t k> class shuffle_order_engine; // engines and engine adaptors with predefined parameters using minstd_rand0 = /*see description*/ ; using minstd_rand = /*see description*/ ; using mt19937 = /*see description*/ ; using mt19937_64 = /*see description*/ ; using ranlux24_base = /*see description*/ ; using ranlux48_base = /*see description*/ ; using ranlux24 = /*see description*/ ; using ranlux48 = /*see description*/ ; using knuth_b = /*see description*/ ; using default_random_engine = /*see description*/ ; // class random_device class random_device; // class seed_seq class seed_seq; // function template generate_canonical template<class RealType, size_t bits, class URBG> RealType generate_canonical(URBG& g); // class template uniform_int_distribution template<class IntType = int> class uniform_int_distribution; // class template uniform_real_distribution template<class RealType = double> class uniform_real_distribution; // class bernoulli_distribution class bernoulli_distribution; // class template binomial_distribution template<class IntType = int> class binomial_distribution; // class template geometric_distribution template<class IntType = int> class geometric_distribution; // class template negative_binomial_distribution template<class IntType = int> class negative_binomial_distribution; // class template poisson_distribution template<class IntType = int> class poisson_distribution; // class template exponential_distribution template<class RealType = double> class exponential_distribution; // class template gamma_distribution template<class RealType = double> class gamma_distribution; // class template weibull_distribution template<class RealType = double> class weibull_distribution; // class template extreme_value_distribution template<class RealType = double> class extreme_value_distribution; // class template normal_distribution template<class RealType = double> class normal_distribution; // class template lognormal_distribution template<class RealType = double> class lognormal_distribution; // class template chi_squared_distribution template<class RealType = double> class chi_squared_distribution; // class template cauchy_distribution template<class RealType = double> class cauchy_distribution; // class template fisher_f_distribution template<class RealType = double> class fisher_f_distribution; // class template student_t_distribution template<class RealType = double> class student_t_distribution; // class template discrete_distribution template<class IntType = int> class discrete_distribution; // class template piecewise_constant_distribution template<class RealType = double> class piecewise_constant_distribution; // class template piecewise_linear_distribution template<class RealType = double> class piecewise_linear_distribution; }