pub struct Binomial { /* private fields */ }
Expand description
The binomial distribution Binomial(n, p)
.
The binomial distribution is a discrete probability distribution
which describes the probability of seeing k
successes in n
independent trials, each of which has success probability p
.
§Density function
f(k) = n!/(k! (n-k)!) p^k (1-p)^(n-k)
for k >= 0
.
§Plot
The following plot of the binomial distribution illustrates the
probability of k
successes out of n = 10
trials with p = 0.2
and p = 0.6
for 0 <= k <= n
.
§Example
use rand_distr::{Binomial, Distribution};
let bin = Binomial::new(20, 0.3).unwrap();
let v = bin.sample(&mut rand::rng());
println!("{} is from a binomial distribution", v);
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Binomial
impl<'de> Deserialize<'de> for Binomial
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Distribution<u64> for Binomial
impl Distribution<u64> for Binomial
impl Copy for Binomial
impl StructuralPartialEq for Binomial
Auto Trait Implementations§
impl Freeze for Binomial
impl RefUnwindSafe for Binomial
impl Send for Binomial
impl Sync for Binomial
impl Unpin for Binomial
impl UnwindSafe for Binomial
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more