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, π(θ)

Methods

impl<X, Fx, Pr> ConjugateModel<X, Fx, Pr> where
    Fx: Rv<X> + HasSuffStat<X>,
    Pr: ConjugatePrior<X, Fx>, 
[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);

Log marginal likelihood, f(obs)

Log posterior predictive, f(y|obs)

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 { alpha: 3.0, beta: 5.0 });

Trait Implementations

impl<X, Fx, Pr> SuffStat<X> for ConjugateModel<X, Fx, Pr> where
    Fx: Rv<X> + HasSuffStat<X>,
    Pr: ConjugatePrior<X, Fx>, 
[src]

Assimilate the datum x into the statistic

Remove the datum x from the statistic

Assimilate several observations

Forget several observations

impl<X, Fx, Pr> Rv<X> for ConjugateModel<X, Fx, Pr> where
    Fx: Rv<X> + HasSuffStat<X>,
    Pr: ConjugatePrior<X, Fx>, 
[src]

Un-normalized probability function Read more

The log of the constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more

Single draw from the Rv Read more

Multiple draws of the Rv Read more

Un-normalized probability function Read more

The constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more

Auto Trait Implementations

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