Struct probability::prelude::Binomial
source · pub struct Binomial { /* private fields */ }
Expand description
A binomial distribution.
Implementations§
source§impl Binomial
impl Binomial
sourcepub fn new(n: usize, p: f64) -> Self
pub fn new(n: usize, p: f64) -> Self
Create a binomial distribution with n
trails and success probability
p
.
It should hold that p >= 0
and p <= 1
.
sourcepub fn with_failure(n: usize, q: f64) -> Self
pub fn with_failure(n: usize, q: f64) -> Self
Create a binomial distribution with n
trails and failure probability
q
.
It should hold that if q >= 0
or q <= 1
. This constructor is
preferable when q
is very small.
Trait Implementations§
source§impl Distribution for Binomial
impl Distribution for Binomial
source§impl Inverse for Binomial
impl Inverse for Binomial
source§fn inverse(&self, p: f64) -> usize
fn inverse(&self, p: f64) -> usize
Compute the inverse of the cumulative distribution function.
For small n
, a simple summation is utilized. For large n
and large
variances, a normal asymptotic approximation is used. Otherwise,
Newton’s method is employed.
References
- S. Moorhead, “Efficient evaluation of the inverse binomial cumulative distribution function where the number of trials is large,” Oxford University, 2013.