https://github.com/stainless-steel/probability
Probability-theory toolbox
https://github.com/stainless-steel/probability
probability random sampling
Last synced: about 1 year ago
JSON representation
Probability-theory toolbox
- Host: GitHub
- URL: https://github.com/stainless-steel/probability
- Owner: stainless-steel
- License: other
- Created: 2014-10-18T14:04:40.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2024-01-26T22:05:26.000Z (about 2 years ago)
- Last Synced: 2024-04-25T22:20:59.232Z (almost 2 years ago)
- Topics: probability, random, sampling
- Language: Rust
- Homepage:
- Size: 431 KB
- Stars: 52
- Watchers: 4
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Probability [![Package][package-img]][package-url] [![Documentation][documentation-img]][documentation-url] [![Build][build-img]][build-url]
The package provides a probability-theory toolbox.
## Example
```rust
use probability::prelude::*;
let mut source = source::default(42);
let distribution = Uniform::new(0.0, 1.0);
let sampler = Independent(&distribution, &mut source);
let samples = sampler.take(10).collect::>();
```
Sources of randomness are provided by the [`random`][random] crate via the
`source` module. In addition, one can make use of those sources that are
available in the [`rand`][rand] crate as illustrated below:
```rust
use probability::prelude::*;
struct Source(T);
impl source::Source for Source {
fn read_u64(&mut self) -> u64 {
self.0.next_u64()
}
}
let mut source = Source(rand::rngs::OsRng::new().unwrap());
let distribution = Uniform::new(0.0, 1.0);
let sampler = Independent(&distribution, &mut source);
let samples = sampler.take(10).collect::>();
```
## Contribution
Your contribution is highly appreciated. Do not hesitate to open an issue or a
pull request. Note that any contribution submitted for inclusion in the project
will be licensed according to the terms given in [LICENSE.md](LICENSE.md).
[rand]: https://crates.io/crates/rand
[random]: https://crates.io/crates/random
[build-img]: https://github.com/stainless-steel/probability/workflows/build/badge.svg
[build-url]: https://github.com/stainless-steel/probability/actions/workflows/build.yml
[documentation-img]: https://docs.rs/probability/badge.svg
[documentation-url]: https://docs.rs/probability
[package-img]: https://img.shields.io/crates/v/probability.svg
[package-url]: https://crates.io/crates/probability