Struct rand_distr::Binomial
source · [−]pub struct Binomial { /* private fields */ }Expand description
The binomial distribution Binomial(n, p).
This distribution has density function:
f(k) = n!/(k! (n-k)!) p^k (1-p)^(n-k) for k >= 0.
Example
use rand_distr::{Binomial, Distribution};
let bin = Binomial::new(20, 0.3).unwrap();
let v = bin.sample(&mut rand::thread_rng());
println!("{} is from a binomial distribution", v);Implementations
Trait Implementations
Generate a random value of T, using rng as the source of randomness.
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘ where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘ where
R: Rng,
Create an iterator that generates random values of T, using rng as
the source of randomness. Read more
Auto Trait Implementations
impl RefUnwindSafe for Binomial
impl UnwindSafe for Binomial
Blanket Implementations
Mutably borrows from an owned value. Read more
