This header introduces random number generation facilities.

This library allows to produce random numbers using combinations of generators and distributions:
  • Generators: Objects that generate uniformly distributed numbers.
  • Distributions: Objects that transform sequences of numbers generated by a generator into sequences of numbers that follow a specific random variable distribution, such as uniform, Normal or Binomial.

Distribution objects generate random numbers by means of their operator() member, which takes a generator object as argument:
std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(1,6);
int dice_roll = distribution(generator);  // generates number in the range 1..6 

For repeated uses, both can be bound together:
auto dice = std::bind ( distribution, generator );
int wisdom = dice()+dice()+dice();

Except for random_device, all standard generators defined in the library are random number engines, which are a kind of generators that use a particular algorithm to generate series of pseudo-random numbers. These algorithms need a seed as a source of randomness, and this seed can either be a single value or an object with a very specific generate() member function (see seed_seq for more info). A typical source of randomness for trivial tasks is time, such as the information provided by time or system_clock::now (for a typical example, see uniform_int_distribution::operator()).

As an alternative, trivial random numbers can also be generated using cstdlib's functions rand and srand.


Pseudo-random number engines (templates)

Generators that use an algorithm to generate pseudo-random numbers based on an initial seed:

Engine adaptors

They adapt an engine, modifying the way numbers are generated with it:

Pseudo-random number engines (instantiations)

Particular instantiations of generator engines and adaptors:

Random number generators

Non-deterministic random number generator:



Related to Bernoulli (yes/no) trials:

Rate-based distributions:

Related to Normal distribution:

Piecewise distributions:


<var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var>
<ins id="pwjBlLZ"></ins>
<ins id="pwjBlLZ"></ins>
<cite id="pwjBlLZ"><dl id="pwjBlLZ"></dl></cite>
<ins id="pwjBlLZ"></ins>
<cite id="pwjBlLZ"></cite><var id="pwjBlLZ"><dl id="pwjBlLZ"></dl></var><ins id="pwjBlLZ"><strike id="pwjBlLZ"><menuitem id="pwjBlLZ"></menuitem></strike></ins>
<menuitem id="pwjBlLZ"><dl id="pwjBlLZ"><progress id="pwjBlLZ"></progress></dl></menuitem><var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var><ins id="pwjBlLZ"><strike id="pwjBlLZ"><menuitem id="pwjBlLZ"></menuitem></strike></ins>
<var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var>
<var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var>
<ins id="pwjBlLZ"><video id="pwjBlLZ"><menuitem id="pwjBlLZ"></menuitem></video></ins>
<ins id="pwjBlLZ"><strike id="pwjBlLZ"></strike></ins>
<cite id="pwjBlLZ"></cite>
<var id="pwjBlLZ"><dl id="pwjBlLZ"><progress id="pwjBlLZ"></progress></dl></var><cite id="pwjBlLZ"><strike id="pwjBlLZ"><thead id="pwjBlLZ"></thead></strike></cite>
<ins id="pwjBlLZ"></ins><var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var><var id="pwjBlLZ"></var>
  • 8957701587 2018-02-23
  • 3891941586 2018-02-23
  • 6039851585 2018-02-23
  • 2573991584 2018-02-23
  • 7728781583 2018-02-23
  • 3731582 2018-02-23
  • 1007451581 2018-02-22
  • 8908121580 2018-02-22
  • 141161579 2018-02-22
  • 9421578 2018-02-22
  • 2826901577 2018-02-22
  • 3647361576 2018-02-22
  • 5717551575 2018-02-22
  • 523811574 2018-02-22
  • 6439871573 2018-02-22
  • 8109431572 2018-02-22
  • 8757321571 2018-02-22
  • 5265111570 2018-02-22
  • 3351351569 2018-02-22
  • 5109361568 2018-02-22