Struct rv::ConjugateModel [−][src]
pub struct ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>, { /* fields omitted */ }
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
impl<X, Fx, Pr> ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
[src]
impl<X, Fx, Pr> ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
[src]pub fn new(fx: &Fx, pr: Arc<Pr>) -> Self
[src]
Create a new conjugate model
Arguments
fx:
Example
use std::sync::Arc; use rv::prelude::*; use rv::ConjugateModel; let pr = Arc::new(Beta::jeffreys()); let fx = Bernoulli::uniform(); let model = ConjugateModel::<bool, Bernoulli, Beta>::new(&fx, pr);
pub fn ln_m(&self) -> f64
[src]
Log marginal likelihood, f(obs)
pub fn ln_pp(&self, y: &X) -> f64
[src]
Log posterior predictive, f(y|obs)
pub fn posterior(&self) -> Pr::Posterior
[src]
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
impl<X: Clone, Fx: Clone, Pr: Clone> Clone for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: Clone,
[src]
impl<X: Clone, Fx: Clone, Pr: Clone> Clone for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: Clone,
[src]fn clone(&self) -> ConjugateModel<X, Fx, Pr>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<X: Debug, Fx: Debug, Pr: Debug> Debug for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: Debug,
[src]
impl<X: Debug, Fx: Debug, Pr: Debug> Debug for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: Debug,
[src]impl<X: PartialEq, Fx: PartialEq, Pr: PartialEq> PartialEq<ConjugateModel<X, Fx, Pr>> for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: PartialEq,
[src]
impl<X: PartialEq, Fx: PartialEq, Pr: PartialEq> PartialEq<ConjugateModel<X, Fx, Pr>> for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: PartialEq,
[src]fn eq(&self, other: &ConjugateModel<X, Fx, Pr>) -> bool
[src]
fn ne(&self, other: &ConjugateModel<X, Fx, Pr>) -> bool
[src]
impl<X: PartialOrd, Fx: PartialOrd, Pr: PartialOrd> PartialOrd<ConjugateModel<X, Fx, Pr>> for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: PartialOrd,
[src]
impl<X: PartialOrd, Fx: PartialOrd, Pr: PartialOrd> PartialOrd<ConjugateModel<X, Fx, Pr>> for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: PartialOrd,
[src]fn partial_cmp(&self, other: &ConjugateModel<X, Fx, Pr>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
pub fn lt(&self, other: &Rhs) -> bool#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
pub fn le(&self, other: &Rhs) -> bool#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
pub fn gt(&self, other: &Rhs) -> bool#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
pub fn ge(&self, other: &Rhs) -> boolimpl<X, Fx, Pr> Rv<X> for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
[src]
impl<X, Fx, Pr> Rv<X> for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
[src]impl<X, Fx, Pr> StructuralPartialEq for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
[src]
impl<X, Fx, Pr> StructuralPartialEq for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
[src]impl<X, Fx, Pr> SuffStat<X> for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
[src]
impl<X, Fx, Pr> SuffStat<X> for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
[src]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> 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> 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> 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> 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,
impl<X, Fx, Pr> UnwindSafe for ConjugateModel<X, Fx, Pr> where
Pr: RefUnwindSafe,
X: UnwindSafe,
<Fx as HasSuffStat<X>>::Stat: UnwindSafe,
Blanket Implementations
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,