[−][src]Struct rv::dist::Binomial
Binomial distribution with success probability p
Examples
use rv::prelude::*; let binom = Binomial::new(4, 0.5).unwrap(); let cdf = binom.cdf(&2_u8); assert_eq!(cdf, binom.pmf(&0_u8) + binom.pmf(&1_u8) + binom.pmf(&2_u8))
Values outside the support of [0, n] can cause panics in certain functions
let n = 4; let binom = Binomial::new(n, 0.5).unwrap(); assert!(!binom.supports(&5_u8))
The maximum allowed value is 4, so the PMF of 5 cannot be computed
binom.pmf(&5_u8); // panics
Fields
n: u64
Total number of trials
p: f64
Probability of a success
Methods
impl Binomial
[src]
pub fn new(n: u64, p: f64) -> Result<Self>
[src]
pub fn uniform(n: u64) -> Self
[src]
A Binomial distribution with a 50% chance of success
pub fn q(&self) -> f64
[src]
The complement of p
, i.e. (1 - p)
.
Trait Implementations
impl Rv<u8> for Binomial
[src]
fn ln_f(&self, k: &u8) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> u8
[src]
fn f(&self, x: &X) -> f64
[src]
Probability function Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
Multiple draws of the Rv
Read more
impl Rv<u16> for Binomial
[src]
fn ln_f(&self, k: &u16) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> u16
[src]
fn f(&self, x: &X) -> f64
[src]
Probability function Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
Multiple draws of the Rv
Read more
impl Rv<u32> for Binomial
[src]
fn ln_f(&self, k: &u32) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> u32
[src]
fn f(&self, x: &X) -> f64
[src]
Probability function Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
Multiple draws of the Rv
Read more
impl Rv<u64> for Binomial
[src]
fn ln_f(&self, k: &u64) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> u64
[src]
fn f(&self, x: &X) -> f64
[src]
Probability function Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
Multiple draws of the Rv
Read more
impl Rv<usize> for Binomial
[src]
fn ln_f(&self, k: &usize) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> usize
[src]
fn f(&self, x: &X) -> f64
[src]
Probability function Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
Multiple draws of the Rv
Read more
impl Rv<i8> for Binomial
[src]
fn ln_f(&self, k: &i8) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> i8
[src]
fn f(&self, x: &X) -> f64
[src]
Probability function Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
Multiple draws of the Rv
Read more
impl Rv<i16> for Binomial
[src]
fn ln_f(&self, k: &i16) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> i16
[src]
fn f(&self, x: &X) -> f64
[src]
Probability function Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
Multiple draws of the Rv
Read more
impl Rv<i32> for Binomial
[src]
fn ln_f(&self, k: &i32) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> i32
[src]
fn f(&self, x: &X) -> f64
[src]
Probability function Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
Multiple draws of the Rv
Read more
impl Rv<i64> for Binomial
[src]
fn ln_f(&self, k: &i64) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> i64
[src]
fn f(&self, x: &X) -> f64
[src]
Probability function Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
Multiple draws of the Rv
Read more
impl Support<u8> for Binomial
[src]
impl Support<u16> for Binomial
[src]
impl Support<u32> for Binomial
[src]
impl Support<u64> for Binomial
[src]
impl Support<usize> for Binomial
[src]
impl Support<i8> for Binomial
[src]
impl Support<i16> for Binomial
[src]
impl Support<i32> for Binomial
[src]
impl Support<i64> for Binomial
[src]
impl Cdf<u8> for Binomial
[src]
impl Cdf<u16> for Binomial
[src]
impl Cdf<u32> for Binomial
[src]
impl Cdf<u64> for Binomial
[src]
impl Cdf<usize> for Binomial
[src]
impl Cdf<i8> for Binomial
[src]
impl Cdf<i16> for Binomial
[src]
impl Cdf<i32> for Binomial
[src]
impl Cdf<i64> for Binomial
[src]
impl DiscreteDistr<u8> for Binomial
[src]
fn pmf(&self, x: &X) -> f64
[src]
Probability mass function (PMF) at x
Read more
fn ln_pmf(&self, x: &X) -> f64
[src]
Natural logarithm of the probability mass function (PMF) Read more
impl DiscreteDistr<u16> for Binomial
[src]
fn pmf(&self, x: &X) -> f64
[src]
Probability mass function (PMF) at x
Read more
fn ln_pmf(&self, x: &X) -> f64
[src]
Natural logarithm of the probability mass function (PMF) Read more
impl DiscreteDistr<u32> for Binomial
[src]
fn pmf(&self, x: &X) -> f64
[src]
Probability mass function (PMF) at x
Read more
fn ln_pmf(&self, x: &X) -> f64
[src]
Natural logarithm of the probability mass function (PMF) Read more
impl DiscreteDistr<u64> for Binomial
[src]
fn pmf(&self, x: &X) -> f64
[src]
Probability mass function (PMF) at x
Read more
fn ln_pmf(&self, x: &X) -> f64
[src]
Natural logarithm of the probability mass function (PMF) Read more
impl DiscreteDistr<usize> for Binomial
[src]
fn pmf(&self, x: &X) -> f64
[src]
Probability mass function (PMF) at x
Read more
fn ln_pmf(&self, x: &X) -> f64
[src]
Natural logarithm of the probability mass function (PMF) Read more
impl DiscreteDistr<i8> for Binomial
[src]
fn pmf(&self, x: &X) -> f64
[src]
Probability mass function (PMF) at x
Read more
fn ln_pmf(&self, x: &X) -> f64
[src]
Natural logarithm of the probability mass function (PMF) Read more
impl DiscreteDistr<i16> for Binomial
[src]
fn pmf(&self, x: &X) -> f64
[src]
Probability mass function (PMF) at x
Read more
fn ln_pmf(&self, x: &X) -> f64
[src]
Natural logarithm of the probability mass function (PMF) Read more
impl DiscreteDistr<i32> for Binomial
[src]
fn pmf(&self, x: &X) -> f64
[src]
Probability mass function (PMF) at x
Read more
fn ln_pmf(&self, x: &X) -> f64
[src]
Natural logarithm of the probability mass function (PMF) Read more
impl DiscreteDistr<i64> for Binomial
[src]
fn pmf(&self, x: &X) -> f64
[src]
Probability mass function (PMF) at x
Read more
fn ln_pmf(&self, x: &X) -> f64
[src]
Natural logarithm of the probability mass function (PMF) Read more
impl Mean<f64> for Binomial
[src]
impl Variance<f64> for Binomial
[src]
impl Skewness for Binomial
[src]
impl Kurtosis for Binomial
[src]
impl PartialOrd<Binomial> for Binomial
[src]
fn partial_cmp(&self, other: &Binomial) -> Option<Ordering>
[src]
fn lt(&self, other: &Binomial) -> bool
[src]
fn le(&self, other: &Binomial) -> bool
[src]
fn gt(&self, other: &Binomial) -> bool
[src]
fn ge(&self, other: &Binomial) -> bool
[src]
impl<'_> From<&'_ Binomial> for String
[src]
impl PartialEq<Binomial> for Binomial
[src]
impl Clone for Binomial
[src]
fn clone(&self) -> Binomial
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Display for Binomial
[src]
impl Debug for Binomial
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ApiReady for T where
T: Clone + Debug + PartialOrd<T> + PartialEq<T>,
[src]
T: Clone + Debug + PartialOrd<T> + PartialEq<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,