- Main Page
- Related Pages
- Classes
- Files

# work/git/mixpp/bdm/estim/mixef.h

Go to the documentation of this file.

    00001
    00013 #ifndef MEF_H
    00014 #define MEF_H
    00015
    00016 #include <itpp/itbase.h>
    00017 #include "../stat/libFN.h"
    00018 #include "../stat/libEF.h"
    00019 #include "../stat/emix.h"
    00020
    00021 using namespace itpp;
    00022
    00039 class MixEF: public BM {
    00040 protected:
    00042         int n;
    00044         Array<BMEF*> Coms;
    00046         multiBM weights;
    00048         eprod* est;
    00050
    00052         void build_est() {
    00053                 Array<const epdf*> epdfs ( n+1 );
    00054                 for ( int i=0;i<Coms.length();i++ ) {
    00055 //                      it_assert_debug(!x,"MixEF::MixEF : Incompatible components");
    00056                         epdfs ( i ) =& ( Coms ( i )->_epdf() );
    00057                 }
    00058                 // last in the product is the weight
    00059                 epdfs ( n ) =& ( weights._epdf() );
    00060                 est = new eprod ( epdfs );
    00061         }
    00062
    00063 public:
    00065         MixEF ( const Array<BMEF*> &Coms0, const vec &alpha0 ) :
    00066                         BM ( RV() ), n ( Coms0.length() ), Coms ( n ),
    00067                         weights ( RV ( "{w }", vec_1 ( n ) ),alpha0 ) {
    00068         //      it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" );
    00069
    00070                 for ( int i=0;i<n;i++ ) {Coms ( i ) = ( BMEF* ) Coms0 ( i )->_copy_();}
    00071                 build_est();
    00072         };
    00073         MixEF () :
    00074                         BM ( RV() ), n ( 0 ), Coms ( 0 ),
    00075                         weights ( RV ( "{w }", vec_1 ( 0 ) ),vec ( 0 ) ) {build_est();}
    00080         void init ( BMEF* Com0, const mat &Data, int c=5 );
    00081         //Destructor
    00082         ~MixEF() {
    00083                 delete est;
    00084                 for ( int i=0;i<n;i++ ) {delete Coms ( i );}
    00085         }
    00087         void bayes ( const vec &dt );
    00089         void bayes ( const mat &dt );
    00090         void bayesB ( const mat &dt );
    00091         double logpred ( const vec &dt ) const;
    00092         const epdf& _epdf() const {return *est;}
    00093 };
    00094
    00095
    00096 #endif // MEF_H
    00097
    00098