[−][src]Struct rv::ConjugateModel
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]
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
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]
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: Clone,
fn clone(&self) -> ConjugateModel<X, Fx, Pr>
[src]
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]
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: Debug,
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]
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: PartialEq,
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]
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
Fx::Stat: PartialOrd,
fn partial_cmp(&self, other: &ConjugateModel<X, Fx, Pr>) -> Option<Ordering>
[src]
fn lt(&self, other: &ConjugateModel<X, Fx, Pr>) -> bool
[src]
fn le(&self, other: &ConjugateModel<X, Fx, Pr>) -> bool
[src]
fn gt(&self, other: &ConjugateModel<X, Fx, Pr>) -> bool
[src]
fn ge(&self, other: &ConjugateModel<X, Fx, Pr>) -> bool
[src]
impl<X, Fx, Pr> Rv<X> for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
[src]
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
fn ln_f(&self, x: &X) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> X
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
fn f(&self, x: &X) -> f64
[src]
fn sample_stream<'r, R: Rng>(
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
[src]
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
impl<X, Fx, Pr> StructuralPartialEq for ConjugateModel<X, Fx, Pr> where
Fx: Rv<X> + HasSuffStat<X>,
Pr: ConjugatePrior<X, Fx>,
[src]
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>,
[src]
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,
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,
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,
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,
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,
Pr: RefUnwindSafe,
X: UnwindSafe,
<Fx as HasSuffStat<X>>::Stat: UnwindSafe,
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<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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,
fn sample_stream<'r, R: Rng>(
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
[src]
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<S, X> SuffStat<X> for S where
S: DerefMut,
<S as Deref>::Target: SuffStat<X>,
[src]
S: DerefMut,
<S as Deref>::Target: SuffStat<X>,
fn n(&Self) -> usize
[src]
fn observe(&mut Self, &X)
[src]
fn forget(&mut Self, &X)
[src]
fn observe_many(&mut Self, &[X])
[src]
fn forget_many(&mut Self, &[X])
[src]
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<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, 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>,