Trait rv::traits::SuffStat [−][src]
pub trait SuffStat<X> { fn n(&self) -> usize; fn observe(&mut self, x: &X); fn forget(&mut self, x: &X); fn observe_many(&mut self, xs: &[X]) { ... } fn forget_many(&mut self, xs: &[X]) { ... } }
Is a sufficient statistic for a distribution.
Example
use rv::data::BernoulliSuffStat; use rv::traits::SuffStat; // Bernoulli sufficient statistics are the number of observations, n, and // the number of successes, k. let mut stat = BernoulliSuffStat::new(); assert!(stat.n == 0 && stat.k == 0); stat.observe(&true); // observe `true` assert!(stat.n == 1 && stat.k == 1); stat.observe(&false); // observe `false` assert!(stat.n == 2 && stat.k == 1); stat.forget_many(&vec![false, true]); // forget `true` and `false` assert!(stat.n == 0 && stat.k == 0);
Required Methods
fn n(&self) -> usize
Returns the number of observations
fn observe(&mut self, x: &X)
Assimilate the datum x
into the statistic
fn forget(&mut self, x: &X)
Remove the datum x
from the statistic
Provided Methods
fn observe_many(&mut self, xs: &[X])
Assimilate several observations
fn forget_many(&mut self, xs: &[X])
Forget several observations
Implementors
impl SuffStat<bool> for BernoulliSuffStat
impl SuffStat<u8> for BernoulliSuffStat
impl SuffStat<u16> for BernoulliSuffStat
impl SuffStat<u32> for BernoulliSuffStat
impl SuffStat<u64> for BernoulliSuffStat
impl SuffStat<usize> for BernoulliSuffStat
impl SuffStat<i8> for BernoulliSuffStat
impl SuffStat<i16> for BernoulliSuffStat
impl SuffStat<i32> for BernoulliSuffStat
impl SuffStat<i64> for BernoulliSuffStat
impl SuffStat<isize> for BernoulliSuffStat
impl<X: CategoricalDatum> SuffStat<X> for CategoricalSuffStat
impl SuffStat<f32> for GaussianSuffStat
impl SuffStat<f64> for GaussianSuffStat
impl SuffStat<DVector<f64>> for MvGaussianSuffStat
impl<X, Fx, Pr> SuffStat<X> for ConjugateModel<X, Fx, Pr> where
X: Debug,
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,