Struct statrs::distribution::Binomial
source · [−]pub struct Binomial { /* private fields */ }
Expand description
Implementations
Constructs a new binomial distribution
with a given p
probability of success of n
trials.
Errors
Returns an error if p
is NaN
, less than 0.0
,
greater than 1.0
, or if n
is less than 0
Examples
use statrs::distribution::Binomial;
let mut result = Binomial::new(0.5, 5);
assert!(result.is_ok());
result = Binomial::new(-0.5, 5);
assert!(result.is_err());
Returns the probability of success p
of
the binomial distribution.
Examples
use statrs::distribution::Binomial;
let n = Binomial::new(0.5, 5).unwrap();
assert_eq!(n.p(), 0.5);
Trait Implementations
Calculates the probability mass function for the binomial
distribution at x
Formula
(n choose k) * p^k * (1 - p)^(n - k)
Calculates the cumulative distribution function for the
binomial distribution at x
Formula
I_(1 - p)(n - x, 1 + x)
where I_(x)(a, b)
is the regularized incomplete beta function
Due to issues with rounding and floating-point accuracy the default implementation may be ill-behaved Specialized inverse cdfs should be used whenever possible. Read more
Generate a random value of T
, using rng
as the source of randomness.
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
Returns the entropy of the binomial distribution
Formula
(1 / 2) * ln (2 * π * e * n * p * (1 - p))
Auto Trait Implementations
impl RefUnwindSafe for Binomial
impl UnwindSafe for Binomial
Blanket Implementations
Mutably borrows from an owned value. Read more
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
Checks if self
is actually part of its subset T
(and can be converted to it).
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
The inclusion map: converts self
to the equivalent element of its superset.