probability

Crates.ioprobability
lib.rsprobability
version0.20.3
sourcesrc
created_at2014-11-20 20:42:16.481503
updated_at2022-12-24 21:08:07.3937
descriptionThe package provides a probability-theory toolbox.
homepagehttps://github.com/stainless-steel/probability
repositoryhttps://github.com/stainless-steel/probability
max_upload_size
id144
size136,485
Owners (github:buoyantio:owners)

documentation

https://docs.rs/probability

README

Probability Package Documentation Build

The package provides a probability-theory toolbox.

Example

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::<Vec<_>>();

Sources of randomness are provided by the random crate via the source module. In addition, one can make use of those sources that are available in the rand crate as illustrated below:

use probability::prelude::*;

struct Source<T>(T);

impl<T: rand::RngCore> source::Source for Source<T> {
    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::<Vec<_>>();

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.

Commit count: 384

cargo fmt