/*! \file \brief Probability distributions for Exponential Family models. \author Vaclav Smidl. ----------------------------------- BDM++ - C++ library for Bayesian Decision Making under Uncertainty Using IT++ for numerical operations ----------------------------------- */ #ifndef EF_H #define EF_H #include #include "libDC.h" #include "libBM.h" //#include using namespace itpp; /*! * \brief General conjugate exponential family posterior density. * More?... */ class eEF : public epdf { public: virtual void tupdate( double phi, mat &vbar, double nubar ) {}; virtual void dupdate( mat &v,double nu=1.0 ) {}; }; class mEF : public mpdf { public: }; /*! * \brief General exponential family density * More?... */ template class enorm : public eEF { int dim; vec mu; sq_T R; public: enorm( RV &rv, vec &mu, sq_T &R ); enorm(); void tupdate( double phi, mat &vbar, double nubar ); void dupdate( mat &v,double nu=1.0 ); vec sample(); mat sample(int N); double eval( const vec &val ); Normal_RNG RNG; }; /*! \brief */ template class mlnorm : public mEF { enorm epdf; mat A; public: //! Constructor mlnorm( RV &rv,RV &rvc, mat &A, sq_T &R ); //!Generate one sample of the posterior vec samplecond( vec &cond, double &lik ); mat samplecond( vec &cond, vec &lik, int n ); void condition( vec &cond ); }; //////////////////////// template enorm::enorm( RV &rv, vec &mu0, sq_T &R0 ) { dim = rv.count(); mu = mu0; R = R0; }; template void enorm::dupdate( mat &v, double nu ) { // }; template void enorm::tupdate( double phi, mat &vbar, double nubar ) { // }; template vec enorm::sample() { vec x( dim ); RNG.sample_vector( dim,x ); vec smp = R.sqrt_mult( x ); smp += mu; return smp; }; template mat enorm::sample( int N ) { mat X( dim,N ); vec x( dim ); vec pom; int i; for ( i=0;i double enorm::eval( const vec &val ) { // }; template enorm::enorm() {}; template mlnorm::mlnorm( RV &rv,RV &rvc, mat &A, sq_T &R ) { int dim = rv.count(); vec mu( dim ); epdf = enorm( rv,mu,R ); } template vec mlnorm::samplecond( vec &cond, double &lik ) { this->condition( cond ); vec smp = epdf.sample(); lik = epdf.eval( smp ); return smp; } template mat mlnorm::samplecond( vec &cond, vec &lik, int n ) { int i; int dim = rv.count(); mat Smp( dim,n ); vec smp( dim ); this->condition( cond ); for ( i=0; i void mlnorm::condition( vec &cond ) { epdf.mu = A*cond; //R is already assigned; } #endif //EF_H