| 1 |
# rand_distr |
| 2 |
|
| 3 |
[](https://github.com/rust-random/rand/actions) |
| 4 |
[](https://crates.io/crates/rand_distr) |
| 5 |
[](https://rust-random.github.io/book/) |
| 6 |
[](https://rust-random.github.io/rand/rand_distr) |
| 7 |
[](https://docs.rs/rand_distr) |
| 8 |
[](https://github.com/rust-random/rand#rust-version-requirements) |
| 9 |
|
| 10 |
Implements a full suite of random number distribution sampling routines. |
| 11 |
|
| 12 |
This crate is a superset of the [rand::distributions] module, including support |
| 13 |
for sampling from Beta, Binomial, Cauchy, ChiSquared, Dirichlet, Exponential, |
| 14 |
FisherF, Gamma, Geometric, Hypergeometric, InverseGaussian, LogNormal, Normal, |
| 15 |
Pareto, PERT, Poisson, StudentT, Triangular and Weibull distributions. Sampling |
| 16 |
from the unit ball, unit circle, unit disc and unit sphere surfaces is also |
| 17 |
supported. |
| 18 |
|
| 19 |
It is worth mentioning the [statrs] crate which provides similar functionality |
| 20 |
along with various support functions, including PDF and CDF computation. In |
| 21 |
contrast, this `rand_distr` crate focuses on sampling from distributions. |
| 22 |
|
| 23 |
## Portability and libm |
| 24 |
|
| 25 |
The floating point functions from `num_traits` and `libm` are used to support |
| 26 |
`no_std` environments and ensure reproducibility. If the floating point |
| 27 |
functions from `std` are preferred, which may provide better accuracy and |
| 28 |
performance but may produce different random values, the `std_math` feature |
| 29 |
can be enabled. |
| 30 |
|
| 31 |
## Crate features |
| 32 |
|
| 33 |
- `std` (enabled by default): `rand_distr` implements the `Error` trait for |
| 34 |
its error types. Implies `alloc` and `rand/std`. |
| 35 |
- `alloc` (enabled by default): required for some distributions when not using |
| 36 |
`std` (in particular, `Dirichlet` and `WeightedAliasIndex`). |
| 37 |
- `std_math`: see above on portability and libm |
| 38 |
- `serde1`: implement (de)seriaialization using `serde` |
| 39 |
|
| 40 |
## Links |
| 41 |
|
| 42 |
- [API documentation (master)](https://rust-random.github.io/rand/rand_distr) |
| 43 |
- [API documentation (docs.rs)](https://docs.rs/rand_distr) |
| 44 |
- [Changelog](CHANGELOG.md) |
| 45 |
- [The Rand project](https://github.com/rust-random/rand) |
| 46 |
|
| 47 |
|
| 48 |
[statrs]: https://github.com/boxtown/statrs |
| 49 |
[rand::distributions]: https://rust-random.github.io/rand/rand/distributions/index.html |
| 50 |
|
| 51 |
## License |
| 52 |
|
| 53 |
`rand_distr` is distributed under the terms of both the MIT license and the |
| 54 |
Apache License (Version 2.0). |
| 55 |
|
| 56 |
See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and |
| 57 |
[COPYRIGHT](COPYRIGHT) for details. |