1# rand_distr 2 3[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rand/actions) 4[![Latest version](https://img.shields.io/crates/v/rand_distr.svg)](https://crates.io/crates/rand_distr) 5[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) 6[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_distr) 7[![API](https://docs.rs/rand_distr/badge.svg)](https://docs.rs/rand_distr) 8[![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) 9 10Implements a full suite of random number distribution sampling routines. 11 12This crate is a superset of the [rand::distributions] module, including support 13for sampling from Beta, Binomial, Cauchy, ChiSquared, Dirichlet, Exponential, 14FisherF, Gamma, Geometric, Hypergeometric, InverseGaussian, LogNormal, Normal, 15Pareto, PERT, Poisson, StudentT, Triangular and Weibull distributions. Sampling 16from the unit ball, unit circle, unit disc and unit sphere surfaces is also 17supported. 18 19It is worth mentioning the [statrs] crate which provides similar functionality 20along with various support functions, including PDF and CDF computation. In 21contrast, this `rand_distr` crate focuses on sampling from distributions. 22 23## Portability and libm 24 25The floating point functions from `num_traits` and `libm` are used to support 26`no_std` environments and ensure reproducibility. If the floating point 27functions from `std` are preferred, which may provide better accuracy and 28performance but may produce different random values, the `std_math` feature 29can 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 54Apache License (Version 2.0). 55 56See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and 57[COPYRIGHT](COPYRIGHT) for details. 58