Changeset 189 for bdm/estim/mixef.h

Show
Ignore:
Timestamp:
10/22/08 10:46:36 (16 years ago)
Author:
smidl
Message:

extend MixEF to allow for EM algorithm and alow estimation of weighted empirical density

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/estim/mixef.h

    r180 r189  
    2020 
    2121using namespace itpp; 
     22 
     23enum MixEF_METHOD { EM = 0, QB = 1}; 
    2224 
    2325/*! 
     
    4951        ////!Indeces of component rvc in common rvc 
    5052         
     53        //! Flag for a method that is used in the inference 
     54        MixEF_METHOD method; 
     55         
    5156        //! Auxiliary function for use in constructors 
    5257        void build_est() { 
     
    6570        MixEF ( const Array<BMEF*> &Coms0, const vec &alpha0 ) : 
    6671                        BM ( RV() ), n ( Coms0.length() ), Coms ( n ), 
    67                         weights ( RV ( "{w }", vec_1 ( n ) ),alpha0 ) { 
     72                        weights ( RV ( "{w }", vec_1 ( n ) ),alpha0 ), method(QB) { 
    6873        //      it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" ); 
    6974 
     
    7378        MixEF () : 
    7479                        BM ( RV() ), n ( 0 ), Coms ( 0 ), 
    75                         weights ( RV ( "{w }", vec_1 ( 0 ) ),vec ( 0 ) ) {build_est();} 
     80                        weights ( RV ( "{w }", vec_1 ( 0 ) ),vec ( 0 ) ),method(QB) {build_est();} 
    7681        //! Initializing the mixture by a random pick of centroids from data 
    7782        //! \param Com0 Initial component - necessary to determine its type. 
     
    8893        //! EM algorithm 
    8994        void bayes ( const mat &dt ); 
    90         void bayesB ( const mat &dt ); 
     95        void bayesB ( const mat &dt, const vec &wData ); 
    9196        double logpred ( const vec &dt ) const; 
    9297        const epdf& _epdf() const {return *est;} 
     
    9499        //! Flatten the density as if it was not estimated from the data 
    95100        void flatten(double sumw=1.0); 
     101         
     102        //!Set which method is to be used 
     103        void set_method(MixEF_METHOD M){method=M;} 
    96104}; 
    97105