[][src]Crate rand_distr

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

uniform

A distribution uniformly sampling numbers within a given range.

weighted

This module contains different algorithms for sampling random indices with probabilities proportional to a collection of weights.

Structs

Alphanumeric

Sample a char, uniformly distributed over ASCII letters and numbers: a-z, A-Z and 0-9.

Bernoulli

The Bernoulli distribution.

Beta

The Beta distribution with shape parameters alpha and beta.

Binomial

The binomial distribution Binomial(n, p).

Cauchy

The Cauchy distribution Cauchy(median, scale).

ChiSquared

The chi-squared distribution χ²(k), where k is the degrees of freedom.

Dirichlet

The dirichelet distribution Dirichlet(alpha).

DistIter

An iterator that generates random values of T with distribution D, using R as the source of randomness.

Exp

The exponential distribution Exp(lambda).

Exp1

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.

FisherF

The Fisher F distribution F(m, n).

Gamma

The Gamma distribution Gamma(shape, scale) distribution.

LogNormal

The log-normal distribution ln N(mean, std_dev**2).

Normal

The normal distribution N(mean, std_dev**2).

Open01

A distribution to sample floating point numbers uniformly in the open interval (0, 1), i.e. not including either endpoint.

OpenClosed01

A distribution to sample floating point numbers uniformly in the half-open interval (0, 1], i.e. including 1 but not 0.

Pareto

Samples floating-point numbers according to the Pareto distribution

Pert

The PERT distribution.

Poisson

The Poisson distribution Poisson(lambda).

Standard

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.

StandardNormal

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.

StudentT

The Student t distribution, t(nu), where nu is the degrees of freedom.

Triangular

The triangular distribution.

Uniform

Sample values uniformly between two bounds.

UnitBall

Samples uniformly from the unit ball (surface and interior) in three dimensions.

UnitCircle

Samples uniformly from the edge of the unit circle in two dimensions.

UnitDisc

Samples uniformly from the unit disc in two dimensions.

UnitSphere

Samples uniformly from the surface of the unit sphere in three dimensions.

Weibull

Samples floating-point numbers according to the Weibull distribution

Enums

BetaError

Error type returned from Beta::new.

BinomialError

Error type returned from Binomial::new.

CauchyError

Error type returned from Cauchy::new.

ChiSquaredError

Error type returned from ChiSquared::new and StudentT::new.

DirichletError

Error type returned from Dirchlet::new.

ExpError

Error type returned from Exp::new.

FisherFError

Error type returned from FisherF::new.

GammaError

Error type returned from Gamma::new.

NormalError

Error type returned from Normal::new and LogNormal::new.

ParetoError

Error type returned from Pareto::new.

PertError

Error type returned from Pert constructors.

PoissonError

Error type returned from Poisson::new.

TriangularError

Error type returned from Triangular::new.

WeibullError

Error type returned from Weibull::new.

Traits

Distribution

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

Float

Trait for floating-point scalar types