The crate family
┌ statrs
getrandom ┐ ├ rand_distr
└ rand_core ┬─────────────┬ rand ┘
├ rand_chacha ┘
├ rand_pcg
└ [other RNG crates]
Interfaces
rand_core defines RngCore and other core traits, as well as several helpers for implementing RNGs.
The getrandom crate provides a low-level API around platform-specific
random-number sources.
Pseudo-random generators
The following crates implement pseudo-random number generators (see Our RNGs):
rand_chachaprovides generators using the ChaCha cipherrand_hcimplements a generator using the HC-128 cipherrand_isaacimplements the ISAAC generatorsrand_pcgimplements a small selection of PCG generatorsrand_xoshiroimplements the SplitMix and Xoshiro generatorsrand_xorshiftimplements the basic Xorshift generator
Exceptionally, SmallRng is implemented directly in rand.
rand (main crate)
The rand crate is designed for easy usage of common random-number
functionality. This has several aspects:
- the
rngsmodule provides a few convenient generators - the
distrmodule concerns sampling of random values - the
seqmodule concerns sampling from and shuffling sequences - the
Rngtrait provides a few convenience methods for generating random values - the
randomfunction provides convenient generation in a single call
Distributions
The rand crate only implements sampling from the most common random
number distributions: uniform and weighted sampling. For everything else,
rand_distrprovides fast sampling from a variety of other distributions, including Normal (Gauss), Binomial, Poisson, UnitCircle, and many morestatrsis a port of the C# Math.NET library, implementing many of the same distributions (plus/minus a few), along with PDF and CDF functions, the error, beta, gamma and logistic special functions, plus a few utilities. (For clarity,statrsis not part of the Rand library.)