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:

  • Related to real-valued quantities that grow linearly (e.g. errors, offsets):
  • Related to Bernoulli trials (yes/no events, with a given probability):
  • Related to positive real-valued quantities that grow exponentially (e.g. prices, incomes, populations):
  • Related to the occurrence of independent events at a given rate:
  • Gamma and derived distributions:
  • Triangular distribution:
  • Multivariate probability distributions

Modules§

  • A distribution uniformly sampling numbers within a given range.
  • Weighted index sampling

Structs§

  • Sample a char, 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 dirichelet 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).
  • The Gamma distribution Gamma(shape, scale) distribution.
  • 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).
  • 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 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

Enums§

Traits§

  • Types (distributions) that can be used to create a random instance of T.
  • Trait for floating-point scalar types