62 releases

Uses old Rust 2015

0.20.3 Dec 24, 2022
0.20.1 Nov 7, 2022
0.18.0 Mar 6, 2022
0.17.0 Jul 6, 2019
0.0.1 Nov 20, 2014

#251 in Algorithms

Download history 10927/week @ 2024-07-28 9317/week @ 2024-08-04 11913/week @ 2024-08-11 11129/week @ 2024-08-18 11457/week @ 2024-08-25 7125/week @ 2024-09-01 14447/week @ 2024-09-08 10117/week @ 2024-09-15 11152/week @ 2024-09-22 9196/week @ 2024-09-29 10027/week @ 2024-10-06 7371/week @ 2024-10-13 12996/week @ 2024-10-20 8664/week @ 2024-10-27 7233/week @ 2024-11-03 5733/week @ 2024-11-10

34,731 downloads per month
Used in 30 crates (20 directly)

Apache-2.0/MIT

125KB
4K SLoC

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.

Dependencies

~440KB