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]

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: 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: 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, 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> 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> 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<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,