Changeset 60 for bdm/estim/libPF.h
- Timestamp:
- 03/31/08 13:53:36 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/estim/libPF.h
r33 r60 19 19 20 20 using namespace itpp; 21 22 //UGLY HACK 23 extern double PF_SSAT;//used for StrSim:06 test... if length>0 the value is written. 21 24 22 25 /*! … … 60 63 61 64 class MPF : public PF { 62 BM_T* Bms[1000 ];65 BM_T* Bms[10000]; 63 66 64 67 //! internal class for MPDF providing composition of eEmp with external components … … 105 108 // 106 109 107 if ( n>1000 ) it_error ( "increase 1000 here!" );110 if ( n>10000 ) it_error ( "increase 10000 here!" ); 108 111 109 112 for ( int i=0;i<n;i++ ) { … … 126 129 for ( int i=0;i<n;i++ ) {Bms[i]->condition ( _samples ( i ) );} 127 130 } 131 132 //SimStr: 133 double SSAT; 128 134 }; 129 135 … … 132 138 int i; 133 139 vec lls ( n ); 140 vec llsP ( n ); 134 141 ivec ind; 135 142 double mlls=-std::numeric_limits<double>::infinity(); 136 143 144 // StrSim:06 145 double sumLWL=0.0; 146 double sumL2WL=0.0; 147 double WL = 0.0; 148 137 149 for ( i=0;i<n;i++ ) { 138 150 //generate new samples from paramater evolution model; 139 _samples ( i ) = par.samplecond ( _samples ( i ), lls ( i ) );151 _samples ( i ) = par.samplecond ( _samples ( i ), llsP ( i ) ); 140 152 Bms[i]->condition ( _samples ( i ) ); 141 153 Bms[i]->bayes ( dt ); … … 144 156 if ( lls ( i ) >mlls ) mlls=lls ( i ); //find maximum likelihood (for numerical stability) 145 157 } 158 159 if ( true ) { 160 for ( i=0;i<n;i++ ) { 161 WL = _w ( i ) *exp ( llsP ( i ) ); //using old weights! 162 sumLWL += exp ( lls ( i ) ) *WL; 163 sumL2WL += exp ( 2*lls ( i ) ) *WL; 164 } 165 SSAT = sumL2WL/(sumLWL*sumLWL); 166 } 146 167 147 168 // compute weights … … 150 171 } 151 172 152 _w /=sum(_w); //? 153 154 double eff = 1.0/( _w*_w ); 173 _w /=sum ( _w ); //? 174 175 176 177 double eff = 1.0/ ( _w*_w ); 155 178 if ( eff < ( 0.1*n ) ) { 156 179 ind = est.resample(); … … 161 184 //fixme this would require new assignment operator 162 185 // *Bms[i] = *Bms[ind ( i ) ]; 163 186 164 187 // poor-man's solution: replicate constructor here 165 188 // copied from MPF::MPF … … 170 193 } 171 194 }; 172 cout << '.'; 195 cout << '.'; 173 196 } 174 197 }