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.
impl Copy 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