Struct probability::distribution::Binomial
[−]
[src]
pub struct Binomial { // some fields omitted }
A binomial distribution.
Methods
impl Binomial
[src]
fn new(n: usize, p: f64) -> Binomial
Create a binomial distribution with n
trails and success probability
p
.
It should hold that p >= 0
and p <= 1
.
fn with_failure(n: usize, q: f64) -> Binomial
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.
fn n(&self) -> usize
Return the number of trials.
fn p(&self) -> f64
Return the success probability.
fn q(&self) -> f64
Return the failure probability.
Trait Implementations
impl Copy for Binomial
[src]
impl Clone for Binomial
[src]
fn clone(&self) -> Binomial
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Distribution for Binomial
[src]
type Value = usize
The type of outcomes.
fn cdf(&self, x: f64) -> f64
Compute the cumulative distribution function.
The implementation is based on the incomplete beta function.
impl Discrete for Binomial
[src]
fn pmf(&self, x: usize) -> f64
Compute the probability mass function.
For large n
, a saddle-point expansion is used for more accurate
computation.
References
- C. Loader, “Fast and Accurate Computation of Binomial Probabilities,” 2000.
impl Entropy for Binomial
[src]
impl Inverse for Binomial
[src]
fn inv_cdf(&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, the
Newton 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.