[−][src]Struct rv::dist::BetaBinomial
Beta Binomial distribution over k in {0, ..., n}
Example
use std::f64; use rv::prelude::*; let a = 3.0; let b = 2.0; let n = 20; let beta = Beta::new(a, b).unwrap(); let beta_binom = BetaBinomial::new(n, a, b).unwrap(); let beta_mean: f64 = beta.mean().unwrap(); let beta_binom_mean: f64 = beta_binom.mean().unwrap(); assert!( (beta_mean * f64::from(n) - beta_binom_mean).abs() < 1E-12 );
Some functions will panic when given data outside the supported range: [0, n]
let beta_binom = BetaBinomial::new(20, 3.0, 2.0).unwrap(); assert!(!beta_binom.supports(&21_u32));
The following will panic because 21 is out of the support
beta_binom.pmf(&21_u32); // panics
Methods
impl BetaBinomial
[src]
pub fn set_n(&mut self, val: u32) -> &mut Self
[src]
Total number of trials
pub fn set_alpha(&mut self, val: f64) -> &mut Self
[src]
Analogous to Beta Distribution α parameter.
pub fn set_beta(&mut self, val: f64) -> &mut Self
[src]
Analogous to Beta Distribution β parameter
impl BetaBinomial
[src]
pub fn new(n: u32, alpha: f64, beta: f64) -> Result<Self, BetaBinomialError>
[src]
Create a beta-binomal distirbution
Arguments
- n: the total number of trials
- alpha: the prior pseudo obersvations of success
- beta: the prior pseudo obersvations of failure
pub fn new_unchecked(n: u32, alpha: f64, beta: f64) -> Self
[src]
Creates a new BetaBinomial without checking whether the parameters are valid.
pub fn n(&self) -> u32
[src]
Get n
, the number of trials.
Example
use rv::dist::BetaBinomial; let bb = BetaBinomial::new(10, 1.0, 2.0).unwrap(); assert_eq!(bb.n(), 10);
pub fn alpha(&self) -> f64
[src]
Get the alpha
parameter
Example
use rv::dist::BetaBinomial; let bb = BetaBinomial::new(10, 1.0, 2.0).unwrap(); assert_eq!(bb.alpha(), 1.0);
pub fn beta(&self) -> f64
[src]
Get the beta
parameter
Example
use rv::dist::BetaBinomial; let bb = BetaBinomial::new(10, 1.0, 2.0).unwrap(); assert_eq!(bb.beta(), 2.0);
Trait Implementations
impl Cdf<i16> for BetaBinomial
[src]
impl Cdf<i32> for BetaBinomial
[src]
impl Cdf<i64> for BetaBinomial
[src]
impl Cdf<i8> for BetaBinomial
[src]
impl Cdf<u16> for BetaBinomial
[src]
impl Cdf<u32> for BetaBinomial
[src]
impl Cdf<u64> for BetaBinomial
[src]
impl Cdf<u8> for BetaBinomial
[src]
impl Cdf<usize> for BetaBinomial
[src]
impl Clone for BetaBinomial
[src]
fn clone(&self) -> BetaBinomial
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for BetaBinomial
[src]
impl DiscreteDistr<i16> for BetaBinomial
[src]
impl DiscreteDistr<i32> for BetaBinomial
[src]
impl DiscreteDistr<i64> for BetaBinomial
[src]
impl DiscreteDistr<i8> for BetaBinomial
[src]
impl DiscreteDistr<u16> for BetaBinomial
[src]
impl DiscreteDistr<u32> for BetaBinomial
[src]
impl DiscreteDistr<u64> for BetaBinomial
[src]
impl DiscreteDistr<u8> for BetaBinomial
[src]
impl DiscreteDistr<usize> for BetaBinomial
[src]
impl Display for BetaBinomial
[src]
impl<'_> From<&'_ BetaBinomial> for String
[src]
fn from(bb: &BetaBinomial) -> String
[src]
impl Mean<f64> for BetaBinomial
[src]
impl PartialEq<BetaBinomial> for BetaBinomial
[src]
fn eq(&self, other: &BetaBinomial) -> bool
[src]
fn ne(&self, other: &BetaBinomial) -> bool
[src]
impl PartialOrd<BetaBinomial> for BetaBinomial
[src]
fn partial_cmp(&self, other: &BetaBinomial) -> Option<Ordering>
[src]
fn lt(&self, other: &BetaBinomial) -> bool
[src]
fn le(&self, other: &BetaBinomial) -> bool
[src]
fn gt(&self, other: &BetaBinomial) -> bool
[src]
fn ge(&self, other: &BetaBinomial) -> bool
[src]
impl Rv<i16> for BetaBinomial
[src]
fn ln_f(&self, k: &i16) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> i16
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<i16>
[src]
fn f(&self, x: &X) -> f64
[src]
impl Rv<i32> for BetaBinomial
[src]
fn ln_f(&self, k: &i32) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> i32
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<i32>
[src]
fn f(&self, x: &X) -> f64
[src]
impl Rv<i64> for BetaBinomial
[src]
fn ln_f(&self, k: &i64) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> i64
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<i64>
[src]
fn f(&self, x: &X) -> f64
[src]
impl Rv<i8> for BetaBinomial
[src]
fn ln_f(&self, k: &i8) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> i8
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<i8>
[src]
fn f(&self, x: &X) -> f64
[src]
impl Rv<u16> for BetaBinomial
[src]
fn ln_f(&self, k: &u16) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> u16
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<u16>
[src]
fn f(&self, x: &X) -> f64
[src]
impl Rv<u32> for BetaBinomial
[src]
fn ln_f(&self, k: &u32) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> u32
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<u32>
[src]
fn f(&self, x: &X) -> f64
[src]
impl Rv<u64> for BetaBinomial
[src]
fn ln_f(&self, k: &u64) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> u64
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<u64>
[src]
fn f(&self, x: &X) -> f64
[src]
impl Rv<u8> for BetaBinomial
[src]
fn ln_f(&self, k: &u8) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> u8
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<u8>
[src]
fn f(&self, x: &X) -> f64
[src]
impl Rv<usize> for BetaBinomial
[src]
fn ln_f(&self, k: &usize) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> usize
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<usize>
[src]
fn f(&self, x: &X) -> f64
[src]
impl StructuralPartialEq for BetaBinomial
[src]
impl Support<i16> for BetaBinomial
[src]
impl Support<i32> for BetaBinomial
[src]
impl Support<i64> for BetaBinomial
[src]
impl Support<i8> for BetaBinomial
[src]
impl Support<u16> for BetaBinomial
[src]
impl Support<u32> for BetaBinomial
[src]
impl Support<u64> for BetaBinomial
[src]
impl Support<u8> for BetaBinomial
[src]
impl Support<usize> for BetaBinomial
[src]
impl Variance<f64> for BetaBinomial
[src]
Auto Trait Implementations
impl RefUnwindSafe for BetaBinomial
impl Send for BetaBinomial
impl Sync for BetaBinomial
impl Unpin for BetaBinomial
impl UnwindSafe for BetaBinomial
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Fx, X> Cdf<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Cdf<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Cdf<X>,
impl<Fx, X> DiscreteDistr<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: DiscreteDistr<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: DiscreteDistr<X>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<Fx, X> Mean<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Mean<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Mean<X>,
impl<Fx, X> Rv<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Rv<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Rv<X>,
fn ln_f(&Self, &X) -> f64
[src]
fn f(&Self, &X) -> f64
[src]
fn draw<R>(&Self, &mut R) -> X where
R: Rng,
[src]
R: Rng,
fn sample<R>(&Self, usize, &mut R) -> Vec<X> where
R: Rng,
[src]
R: Rng,
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>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<Fx, X> Support<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Support<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Support<X>,
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> 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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<Fx, X> Variance<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Variance<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Variance<X>,