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:
- The 
Distributiontrait andDistIterhelper type - The 
Standard,Alphanumeric,Uniform,OpenClosed01,Open01,Bernoulli, andWeightedIndexdistributions 
§Distributions
This crate provides the following probability distributions:
- Related to real-valued quantities that grow linearly
(e.g. errors, offsets):
Normaldistribution, andStandardNormalas a primitiveSkewNormaldistributionCauchydistribution
 - Related to Bernoulli trials (yes/no events, with a given probability):
BinomialdistributionGeometricdistributionHypergeometricdistribution
 - Related to positive real-valued quantities that grow exponentially
(e.g. prices, incomes, populations):
LogNormaldistribution
 - Related to the occurrence of independent events at a given rate:
 - Gamma and derived distributions:
GammadistributionChiSquareddistributionStudentTdistributionFisherFdistribution
 - Triangular distribution:
BetadistributionTriangulardistribution
 - Multivariate probability distributions
DirichletdistributionUnitSpheredistributionUnitBalldistributionUnitCircledistributionUnitDiscdistribution
 - Alternative implementation for weighted index sampling
WeightedAliasIndexdistribution
 - Misc. distributions
InverseGaussiandistributionNormalInverseGaussiandistribution
 
Re-exports§
pub use weighted_alias::WeightedAliasIndex;pub use num_traits;
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
alphaandbeta. - The binomial distribution
Binomial(n, p). - The Cauchy distribution
Cauchy(median, scale). - The chi-squared distribution
χ²(k), wherekis the degrees of freedom. - The Dirichlet distribution
Dirichlet(alpha). - An iterator that generates random values of
Twith distributionD, usingRas 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 toExp::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 toGeometeric::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 toNormal::new(0.0, 1.0)but faster. - The Student t distribution,
t(nu), wherenuis 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§
- Error type returned from
Bernoulli::new. - Error type returned from
Beta::new. - Error type returned from
Binomial::new. - Error type returned from
Cauchy::new. - Error type returned from
ChiSquared::newandStudentT::new. - Error type returned from
Dirchlet::new. - Error type returned from
Exp::new. - Error type returned from
FisherF::new. - Error type returned from
Frechet::new. - Error type returned from
Gamma::new. - Error type returned from
Geometric::new. - Error type returned from
Gumbel::new. - Error type returned from
Hypergeometric::new. - Error type returned from
InverseGaussian::new - Error type returned from
Normal::newandLogNormal::new. - Error type returned from
NormalInverseGaussian::new - Error type returned from
Pareto::new. - Error type returned from
Pertconstructors. - Error type returned from
Poisson::new. - Error type returned from
SkewNormal::new. - Error type returned from
Triangular::new. - Error type returned from
Weibull::new. - Error type returned from
WeightedIndex::new. - Error type returned from
Zeta::new. - Error type returned from
Zipf::new. 
Traits§
- Types (distributions) that can be used to create a random instance of
T.