Crate rand_distr

source ·
Expand description

Generating random samples from probability distributions.

§Re-exports

This crate is a super-set of the rand::distributions module. See the rand::distributions module documentation for an overview of the core Distribution trait and implementations.

The following are re-exported:

§Distributions

This crate provides the following probability distributions:

Re-exports§

Modules§

  • A distribution uniformly sampling numbers within a given range.
  • This module contains an implementation of alias method for sampling random indices with probabilities proportional to a collection of weights.

Structs§

  • Sample a u8, uniformly distributed over ASCII letters and numbers: a-z, A-Z and 0-9.
  • The Bernoulli distribution.
  • The Beta distribution with shape parameters alpha and beta.
  • The binomial distribution Binomial(n, p).
  • The Cauchy distribution Cauchy(median, scale).
  • The chi-squared distribution χ²(k), where k is the degrees of freedom.
  • The Dirichlet distribution Dirichlet(alpha).
  • An iterator that generates random values of T with distribution D, using R as the source of randomness.
  • The exponential distribution Exp(lambda).
  • Samples floating-point numbers according to the exponential distribution, with rate parameter λ = 1. This is equivalent to Exp::new(1.0) or sampling with -rng.gen::<f64>().ln(), but faster.
  • The Fisher F distribution F(m, n).
  • Samples floating-point numbers according to the Fréchet distribution
  • The Gamma distribution Gamma(shape, scale) distribution.
  • The geometric distribution Geometric(p) bounded to [0, u64::MAX].
  • Samples floating-point numbers according to the Gumbel distribution
  • The hypergeometric distribution Hypergeometric(N, K, n).
  • The log-normal distribution ln N(mean, std_dev**2).
  • The normal distribution N(mean, std_dev**2).
  • A distribution to sample floating point numbers uniformly in the open interval (0, 1), i.e. not including either endpoint.
  • A distribution to sample floating point numbers uniformly in the half-open interval (0, 1], i.e. including 1 but not 0.
  • Samples floating-point numbers according to the Pareto distribution
  • The PERT distribution.
  • The Poisson distribution Poisson(lambda).
  • The skew normal distribution SN(location, scale, shape).
  • A generic random value distribution, implemented for many primitive types. Usually generates values with a numerically uniform distribution, and with a range appropriate to the type.
  • Samples integers according to the geometric distribution with success probability p = 0.5. This is equivalent to Geometeric::new(0.5), but faster.
  • Samples floating-point numbers according to the normal distribution N(0, 1) (a.k.a. a standard normal, or Gaussian). This is equivalent to Normal::new(0.0, 1.0) but faster.
  • The Student t distribution, t(nu), where nu is the degrees of freedom.
  • The triangular distribution.
  • Sample values uniformly between two bounds.
  • Samples uniformly from the unit ball (surface and interior) in three dimensions.
  • Samples uniformly from the edge of the unit circle in two dimensions.
  • Samples uniformly from the unit disc in two dimensions.
  • Samples uniformly from the surface of the unit sphere in three dimensions.
  • Samples floating-point numbers according to the Weibull distribution
  • A distribution using weighted sampling of discrete items
  • Samples integers according to the zeta distribution.
  • Samples integers according to the Zipf distribution.

Enums§

Traits§

  • Types (distributions) that can be used to create a random instance of T.