Struct rv::ConjugateModel
source · pub struct ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,{ /* private fields */ }
Expand description
A wrapper for a complete conjugate model
Paramters
X
: The type of the data/observations to be modeled
Fx
: The type of the likelihood, f(x|θ)
Pr
: The type of the prior on the parameters of Fx
, π(θ)
Implementations§
source§impl<X, Fx, Pr> ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
impl<X, Fx, Pr> ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
sourcepub fn posterior(&self) -> Pr::Posterior
pub fn posterior(&self) -> Pr::Posterior
Return the posterior distribution
Example
use std::sync::Arc;
use rv::prelude::*;
use rv::ConjugateModel;
let flips: Vec<bool> = vec![true, false, true, false, false, false];
let pr = Arc::new(Beta::new(1.0, 1.0).unwrap());
let fx = Bernoulli::uniform();
let mut model = ConjugateModel::<bool, Bernoulli, Beta>::new(&fx, pr);
model.observe_many(&flips);
let post = model.posterior();
assert_eq!(post, Beta::new(3.0, 5.0).unwrap());
Trait Implementations§
source§impl<X: Clone, Fx, Pr> Clone for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X> + Clone,
Pr: ConjugatePrior<X, Fx> + Clone,
Fx::Stat: Clone,
impl<X: Clone, Fx, Pr> Clone for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X> + Clone,
Pr: ConjugatePrior<X, Fx> + Clone,
Fx::Stat: Clone,
source§fn clone(&self) -> ConjugateModel<X, Fx, Pr>
fn clone(&self) -> ConjugateModel<X, Fx, Pr>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<X: Debug, Fx, Pr> Debug for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X> + Debug,
Pr: ConjugatePrior<X, Fx> + Debug,
Fx::Stat: Debug,
impl<X: Debug, Fx, Pr> Debug for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X> + Debug,
Pr: ConjugatePrior<X, Fx> + Debug,
Fx::Stat: Debug,
source§impl<X: PartialEq, Fx, Pr> PartialEq<ConjugateModel<X, Fx, Pr>> for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X> + PartialEq,
Pr: ConjugatePrior<X, Fx> + PartialEq,
Fx::Stat: PartialEq,
impl<X: PartialEq, Fx, Pr> PartialEq<ConjugateModel<X, Fx, Pr>> for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X> + PartialEq,
Pr: ConjugatePrior<X, Fx> + PartialEq,
Fx::Stat: PartialEq,
source§fn eq(&self, other: &ConjugateModel<X, Fx, Pr>) -> bool
fn eq(&self, other: &ConjugateModel<X, Fx, Pr>) -> bool
source§impl<X: PartialOrd, Fx, Pr> PartialOrd<ConjugateModel<X, Fx, Pr>> for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X> + PartialOrd,
Pr: ConjugatePrior<X, Fx> + PartialOrd,
Fx::Stat: PartialOrd,
impl<X: PartialOrd, Fx, Pr> PartialOrd<ConjugateModel<X, Fx, Pr>> for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X> + PartialOrd,
Pr: ConjugatePrior<X, Fx> + PartialOrd,
Fx::Stat: PartialOrd,
source§fn partial_cmp(&self, other: &ConjugateModel<X, Fx, Pr>) -> Option<Ordering>
fn partial_cmp(&self, other: &ConjugateModel<X, Fx, Pr>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<X, Fx, Pr> Rv<X> for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
impl<X, Fx, Pr> Rv<X> for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
source§impl<X, Fx, Pr> SuffStat<X> for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
impl<X, Fx, Pr> SuffStat<X> for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
source§fn observe_many(&mut self, xs: &[X])
fn observe_many(&mut self, xs: &[X])
Assimilate several observations
source§fn forget_many(&mut self, xs: &[X])
fn forget_many(&mut self, xs: &[X])
Forget several observations
impl<X, Fx, Pr> StructuralPartialEq for ConjugateModel<X, Fx, Pr>where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Auto Trait Implementations§
impl<X, Fx, Pr> RefUnwindSafe for ConjugateModel<X, Fx, Pr>where
Pr: RefUnwindSafe,
X: RefUnwindSafe,
<Fx as HasSuffStat<X>>::Stat: RefUnwindSafe,
impl<X, Fx, Pr> Send for ConjugateModel<X, Fx, Pr>where
Pr: Send + Sync,
X: Send,
<Fx as HasSuffStat<X>>::Stat: Send,
impl<X, Fx, Pr> Sync for ConjugateModel<X, Fx, Pr>where
Pr: Send + Sync,
X: Sync,
<Fx as HasSuffStat<X>>::Stat: Sync,
impl<X, Fx, Pr> Unpin for ConjugateModel<X, Fx, Pr>where
X: Unpin,
<Fx as HasSuffStat<X>>::Stat: Unpin,
impl<X, Fx, Pr> UnwindSafe for ConjugateModel<X, Fx, Pr>where
Pr: RefUnwindSafe,
X: UnwindSafe,
<Fx as HasSuffStat<X>>::Stat: UnwindSafe,
Blanket Implementations§
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.