use nalgebra::*;
use super::*;
use super::categorical::*;
use super::multinormal::*;
use super::dirichlet::*;
struct NormalMixture {
normals : Vec<MultiNormal>,
cat : Categorical,
realiz : DMatrix<f64>,
realiz_trans : DMatrix<f64>
}
impl NormalMixture {
pub fn new(normals) -> Self {
unimplemented!()
}
}
impl ConditionalDistribution<Dirichlet> for NormalMixture {
fn condition(mut self, mut d : Dirichlet) -> Bernoulli {
self.cat.factor = Factor::Conjugate(Box::new(d));
self
}
fn take_factor(self) -> Option<Dirichlet> {
match self.cat.factor {
Factor::Conjugate(d) => {
Some(*d)
},
_ => None
}
}
fn share_factor(&mut self, d : NormalMixture) {
unimplemented!()
}
}
impl Distribution for NormalMixture
where Self : Debug
{
fn mean<'a>(&'a self) -> &'a DVector<f64> {
unimplemented!()
}
fn set_parameter(&mut self, p : &[f64]) {
unimplemented!()
}
fn mode(&self) -> DVector<f64> {
unimplemented!()
}
fn var(&self) -> DVector<f64> {
unimplemented!()
}
fn factors<'a>(&'a self) -> Factors {
unimplemented!()
}
fn factors_mut<'a>(&'a mut self) -> FactorsMut {
unimplemented!()
}
fn shared_factors<'a>(&'a self) -> Factors {
unimplemented!()
}
fn marginalize(&self) -> Option<Histogram> {
None
}
fn log_prob(&self, y : DMatrixSlice<f64>) -> f64 {
let n = y.ncols();
let p = self.normals.len();
let means : Vec<_> = self.normals.map(|n| n.mean()).collect();
let mean_mat = DMatrix::from_columns(means);
let mix_avgs = self.realizations * mean_mat;
let mut lp = 0.0;
for i in 0..n {
lp += self.normals[i].log_prob(mix_avgs.column(i)) +
self.cat.log_prob(self.realiz_trans.column(i));
}
lp
}
fn sample(&self) -> DMatrix<f64> {
unimplemented!()
}
}