Module std::random

Random number generation

Example

This module consists of a protocol Rng which can be used to implement a random number generator that provides "raw randomness", Distribution protocol and various concrete implementations, such as Normal and Bernoulli that can be used to sample random values of a particular kind, and RngExt mixin which provides convenience methods for common use cases.

The module also provides a Pcg32, a decent general purpose pseudo-random generator, OsRng backed by the OS-provided random number generator, and thread_rng, a convenience thread-local random generator that does not need manual seeding.

Protocols

Rng
Random number generators
Probability distributions
Extension mixin for the Rng protocol

Structs

Iterator yielding random samples from a distribution.
Uniform distribution over a range of integers.
Bernoulli distribution. Returns true with probability p and false with probability 1 - p.
Weighted discrete distribution.
Uniform floating point distribution over the [0, 1) interval.
Uniform floating point distribution over the (0, 1] interval.
Uniform floating point distribution over the (0, 1) interval.
Normal (Gaussian) distribution over the real numbers.
Exponential distribution over the positive real numbers.
PCG-32 random number generator
RNG backed by a OS-provided random number generation facility

Functions

Types