/*! \file \brief Bayesian Filtering for mixtures of exponential family (EF) members \author Vaclav Smidl. ----------------------------------- BDM++ - C++ library for Bayesian Decision Making under Uncertainty Using IT++ for numerical operations ----------------------------------- */ #ifndef MEF_H #define MEF_H #include #include "../stat/libFN.h" #include "../stat/libEF.h" #include "../stat/emix.h" using namespace itpp; enum MixEF_METHOD { EM = 0, QB = 1}; /*! * \brief Mixture of Exponential Family Densities An approximate estimation method for models with latent discrete variable, such as mixture models of the following kind: \f[ f(y_t|\psi_t, \Theta) = \sum_{i=1}^{n} w_i f(y_t|\psi_t, \theta_i) \f] where \f$\psi\f$ is a known function of past outputs, \f$w=[w_1,\ldots,w_n]\f$ are component weights, and component parameters \f$\theta_i\f$ are assumed to be mutually independent. \f$\Theta\f$ is an aggregation af all component parameters and weights, i.e. \f$\Theta = [\theta_1,\ldots,\theta_n,w]\f$. The characteristic feature of this model is that if the exact values of the latent variable were known, estimation of the parameters can be handled by a single model. For example, for the case of mixture models, posterior density for each component parameters would be a BayesianModel from Exponential Family. This class uses EM-style type algorithms for estimation of its parameters. Under this simplification, the posterior density is a product of exponential family members, hence under EM-style approximate estimation this class itself belongs to the exponential family. TODO: Extend BM to use rvc. */ class MixEF: public BM { protected: //!Number of components int n; //! Models for Components of \f$\theta_i\f$ Array Coms; //! Statistics for weights multiBM weights; //!Posterior on component parameters eprod* est; ////!Indeces of component rvc in common rvc //! Flag for a method that is used in the inference MixEF_METHOD method; //! Auxiliary function for use in constructors void build_est() { Array epdfs ( n+1 ); for ( int i=0;i_epdf() ); } // last in the product is the weight epdfs ( n ) =& ( weights._epdf() ); est = new eprod ( epdfs ); } public: //! Full constructor MixEF ( const Array &Coms0, const vec &alpha0 ) : BM ( RV() ), n ( Coms0.length() ), Coms ( n ), weights ( RV ( "{w }", vec_1 ( n ) ),alpha0 ), method(QB) { // it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" ); for ( int i=0;i_copy_();} build_est(); }; MixEF () : BM ( RV() ), n ( 0 ), Coms ( 0 ), weights ( RV ( "{w }", vec_1 ( 0 ) ),vec ( 0 ) ),method(QB) {build_est();} //! Initializing the mixture by a random pick of centroids from data //! \param Com0 Initial component - necessary to determine its type. //! \param Data Data on which the initialization will be done //! \param c Initial number of components, default=5 void init ( BMEF* Com0, const mat &Data, int c=5 ); //Destructor ~MixEF() { delete est; for ( int i=0;i