Changeset 286 for bdm/estim/mixef.h
- Timestamp:
- 03/05/09 14:03:35 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/estim/mixef.h
r278 r286 19 19 #include "../stat/emix.h" 20 20 21 namespace bdm {21 namespace bdm { 22 22 23 23 enum MixEF_METHOD { EM = 0, QB = 1}; … … 50 50 eprod* est; 51 51 ////!Indeces of component rvc in common rvc 52 52 53 53 //! Flag for a method that is used in the inference 54 54 MixEF_METHOD method; 55 55 56 56 //! Auxiliary function for use in constructors 57 57 void build_est() { 58 Array<const epdf*> epdfs ( n+1 ); 59 for ( int i=0;i<Coms.length();i++ ) { 58 est = new eprod; 59 if ( n>0 ) { 60 Array<const epdf*> epdfs ( n+1 ); 61 for ( int i=0;i<Coms.length();i++ ) { 60 62 // it_assert_debug(!x,"MixEF::MixEF : Incompatible components"); 61 epdfs ( i ) =& ( Coms ( i )->posterior() ); 63 epdfs ( i ) =& ( Coms ( i )->posterior() ); 64 } 65 // last in the product is the weight 66 epdfs ( n ) =& ( weights.posterior() ); 67 est->set_parameters ( epdfs, false ); 62 68 } 63 // last in the product is the weight64 epdfs ( n ) =& ( weights.posterior() );65 est = new eprod ( epdfs );66 69 } 67 70 … … 69 72 //! Full constructor 70 73 MixEF ( const Array<BMEF*> &Coms0, const vec &alpha0 ) : 71 BMEF ( 72 weights (), method (QB) {73 // it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" );74 BMEF ( ), n ( Coms0.length() ), Coms ( n ), 75 weights (), method ( QB ) { 76 // it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" ); 74 77 75 78 for ( int i=0;i<n;i++ ) {Coms ( i ) = ( BMEF* ) Coms0 ( i )->_copy_();} … … 79 82 MixEF () : 80 83 BMEF ( ), n ( 0 ), Coms ( 0 ), 81 weights (),method (QB) {build_est();}84 weights (),method ( QB ) {build_est();} 82 85 //! Copy constructor 83 MixEF (const MixEF &M2): BMEF ( ), n ( M2.n ), Coms ( n ),84 weights ( M2.weights ), method(M2.method) {85 // it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" );86 MixEF ( const MixEF &M2 ) : BMEF ( ), n ( M2.n ), Coms ( n ), 87 weights ( M2.weights ), method ( M2.method ) { 88 // it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" ); 86 89 87 88 89 90 for ( int i=0;i<n;i++ ) {Coms ( i ) = M2.Coms ( i )->_copy_();} 91 build_est(); 92 } 90 93 //! Initializing the mixture by a random pick of centroids from data 91 94 //! \param Com0 Initial component - necessary to determine its type. … … 108 111 emix* epredictor() const; 109 112 //! Flatten the density as if it was not estimated from the data 110 void flatten (const BMEF* M2);113 void flatten ( const BMEF* M2 ); 111 114 //! Access function 112 BMEF* _Coms (int i){return Coms(i);}113 115 BMEF* _Coms ( int i ) {return Coms ( i );} 116 114 117 //!Set which method is to be used 115 void set_method (MixEF_METHOD M){method=M;}118 void set_method ( MixEF_METHOD M ) {method=M;} 116 119 }; 117 120