cpp/numeric/random

The random number library provides classes that generate random and pseudo-random numbers. These classes include:
 * Uniform random bit generators (URBGs), which include both random number engines, which are pseudo-random number generators that generate integer sequences with a uniform distribution, and true random number generators if available;
 * Random number distributions (e.g., , or s) which convert the output of URBGs into various statistical distributions.

URBGs and distributions are designed to be used together to produce random values. All of the random number engines may be specifically seeded, serialized, and de-serialized for use with repeatable simulators.

Uniform random bit generators
A uniform random bit generator is a function object returning unsigned integer values such that each value in the range of possible results has (ideally) equal probability of being returned.

All uniform random bit generators meet the requirements. C++20 also defines a concept.

Random number engines
Random number engines generate pseudo-random numbers using seed data as entropy source. Several different classes of pseudo-random number generation algorithms are implemented as templates that can be customized.

The choice of which engine to use involves a number of trade-offs: the engine is moderately fast and has a very small storage requirement for state. The generators are very fast even on processors without advanced arithmetic instruction sets, at the expense of greater state storage and sometimes less desirable spectral characteristics. The is slower and has greater state storage requirements but with the right parameters has the longest non-repeating sequence with the most desirable spectral characteristics (for a given definition of desirable).

Random number engine adaptors
Random number engine adaptors generate pseudo-random numbers using another random number engine as entropy source. They are generally used to alter the spectral characteristics of the underlying engine.

Predefined random number generators
Several specific popular algorithms are predefined.

Non-deterministic random numbers
std is a non-deterministic uniform random bit generator, although implementations are allowed to implement std using a pseudo-random number engine if there is no support for non-deterministic random number generation.

Random number distributions
A random number distribution post-processes the output of a URBG in such a way that resulting output is distributed according to a defined statistical probability density function.

Random number distributions satisfy.

C random library
In addition to the engines and distributions described above, the functions and constants from the C random library are also available though not recommended: