12 releases
new 0.5.0-beta.1 | Nov 27, 2024 |
---|---|
0.5.0-alpha.3 | Jul 31, 2024 |
0.5.0-alpha.1 | Mar 18, 2024 |
0.4.3 | Jan 18, 2022 |
0.2.1 |
|
#1222 in Algorithms
1,915,419 downloads per month
Used in 2,183 crates
(521 directly)
620KB
11K
SLoC
rand_distr
Implements a full suite of random number distribution sampling routines.
This crate is a superset of the rand::distr module, including support for sampling from Beta, Binomial, Cauchy, ChiSquared, Dirichlet, Exponential, FisherF, Gamma, Geometric, Hypergeometric, InverseGaussian, LogNormal, Normal, Pareto, PERT, Poisson, StudentT, Triangular and Weibull distributions. Sampling from the unit ball, unit circle, unit disc and unit sphere surfaces is also supported.
It is worth mentioning the statrs crate which provides similar functionality
along with various support functions, including PDF and CDF computation. In
contrast, this rand_distr
crate focuses on sampling from distributions.
Portability and libm
The floating point functions from num_traits
and libm
are used to support
no_std
environments and ensure reproducibility. If the floating point
functions from std
are preferred, which may provide better accuracy and
performance but may produce different random values, the std_math
feature
can be enabled. (Note that any other crate depending on num-traits
with the
std
feature (default-enabled) will have the same effect.)
Crate features
std
(enabled by default):rand_distr
implements theError
trait for its error types. Impliesalloc
andrand/std
.alloc
(enabled by default): required for some distributions when not usingstd
(in particular,Dirichlet
andWeightedAliasIndex
).std_math
: see above on portability and libmserde
: implement (de)seriaialization usingserde
Links
License
rand_distr
is distributed under the terms of both the MIT license and the
Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT, and COPYRIGHT for details.
Dependencies
~1.4–2MB
~30K SLoC