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

#111 in Algorithms

Download history 6011/week @ 2023-12-17 870/week @ 2023-12-24 5341/week @ 2023-12-31 9032/week @ 2024-01-07 7804/week @ 2024-01-14 6246/week @ 2024-01-21 5475/week @ 2024-01-28 7097/week @ 2024-02-04 7636/week @ 2024-02-11 4760/week @ 2024-02-18 11586/week @ 2024-02-25 12437/week @ 2024-03-03 12390/week @ 2024-03-10 9725/week @ 2024-03-17 10304/week @ 2024-03-24 9577/week @ 2024-03-31

42,507 downloads per month
Used in 32 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

~450KB