pub struct Binomial { /* private fields */ }
Expand description
Binomial distribution: X ~ Bin(n, p)
Implementations§
Trait Implementations§
Source§impl Distribution for Binomial
impl Distribution for Binomial
Source§fn cf(&self, t: f64) -> Complex<f64>
fn cf(&self, t: f64) -> Complex<f64>
Characteristic function of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
let cf = binomial.cf(1.0);
assert_approx_equal!(cf.re, -0.2014034, 1e-7);
assert_approx_equal!(cf.im, 0.4969347, 1e-7);
Source§fn pdf(&self, x: f64) -> f64
fn pdf(&self, x: f64) -> f64
Probability density function of the Binomial distribution. Note: Identical to the probability mass function.
§Examples
let binomial = Binomial::new(5, 0.4);
let pdf = binomial.pdf(3.0);
let pmf = binomial.pmf(3.0);
assert_approx_equal!(pdf, 0.2304000, 1e-7);
assert_approx_equal!(pdf, pmf, 1e-7);
Source§fn pmf(&self, k: f64) -> f64
fn pmf(&self, k: f64) -> f64
Probability mass function of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
let pmf = binomial.pmf(3.0);
assert_approx_equal!(pmf, 0.2304000, 1e-7);
Source§fn cdf(&self, k: f64) -> f64
fn cdf(&self, k: f64) -> f64
Cumulative distribution function of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
assert_approx_equal!(binomial.cdf(3.0), 0.9129600, 1e-7);
Source§fn inv_cdf(&self, p: f64) -> f64
fn inv_cdf(&self, p: f64) -> f64
Inverse distribution (quantile) function of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
assert_eq!(binomial.inv_cdf(0.5), 2.0);
Source§fn mean(&self) -> f64
fn mean(&self) -> f64
Mean of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
assert_eq!(binomial.mean(), 2.0);
Source§fn median(&self) -> f64
fn median(&self) -> f64
Median of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
assert_eq!(binomial.median(), 2.0);
Source§fn mode(&self) -> f64
fn mode(&self) -> f64
Mode of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
assert_eq!(binomial.mode(), 2.0);
Source§fn variance(&self) -> f64
fn variance(&self) -> f64
Variance of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
assert_eq!(binomial.variance(), 1.2);
Source§fn skewness(&self) -> f64
fn skewness(&self) -> f64
Skewness of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
assert_approx_equal!(binomial.skewness(), 0.1825742, 1e-7);
Source§fn kurtosis(&self) -> f64
fn kurtosis(&self) -> f64
Kurtosis of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
assert_approx_equal!(binomial.kurtosis(), -0.3666667, 1e-7);
Source§fn entropy(&self) -> f64
fn entropy(&self) -> f64
Entropy of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
assert_approx_equal!(binomial.entropy(), 1.510099, 1e-6);
Source§fn mgf(&self, t: f64) -> f64
fn mgf(&self, t: f64) -> f64
Moment generating function of the Binomial distribution.
§Examples
let binomial = Binomial::new(5, 0.4);
assert_approx_equal!(binomial.mgf(1.0), 13.67659, 1e-5);
Source§fn sample(&self, n: usize) -> Result<Vec<f64>, RustQuantError>
fn sample(&self, n: usize) -> Result<Vec<f64>, RustQuantError>
Generates a random sample from a Binomial distribution.
§Examples
let binomial = Binomial::new(100, 0.4);
let sample = binomial.sample(100).unwrap();
let mean = sample.iter().sum::<f64>() / sample.len() as f64;
assert_approx_equal!(mean, binomial.mean(), 1.0);
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.