The crate family

statrs
getrandom ┐                                ├ rand_distrrand_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_chacha provides generators using the ChaCha cipher
  • rand_hc implements a generator using the HC-128 cipher
  • rand_isaac implements the ISAAC generators
  • rand_pcg implements a small selection of PCG generators
  • rand_xoshiro implements the SplitMix and Xoshiro generators
  • rand_xorshift implements 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 rngs module provides a few convenient generators
  • the distributions module concerns sampling of random values
  • the seq module concerns sampling from and shuffling sequences
  • the Rng trait provides a few convenience methods for generating random values
  • the random function 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_distr provides fast sampling from a variety of other distributions, including Normal (Gauss), Binomial, Poisson, UnitCircle, and many more
  • statrs is 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, statrs is not part of the Rand library.)