Trait urandom::distributions::Distribution
source · Expand description
Types (distributions) that can be used to create a random instance of T
.
It is possible to sample from a distribution through both the
Distribution
trait and Random
struct, via distr.sample(&mut rng)
and
rng.sample(&distr)
. There’s also the Random::samples
method, which
produces an iterator that samples from the distribution.
All implementations are expected to be immutable; this has the significant advantage of not needing to consider thread safety, and for most distributions efficient state-less sampling algorithms are available.
Implementations are typically expected to be portable with reproducible results when used with a PRNG with fixed seed;
see the portability chapter of The Rust Rand Book. In some cases this does not apply,
e.g. the usize
type requires different sampling on 32-bit and 64-bit machines.