Changeset 950
- Timestamp:
- 05/18/10 21:19:38 (15 years ago)
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/bdmtoolbox/tutorial/userguide/frg_estim.m
r934 r950 32 32 E.class = 'PF'; 33 33 E.particle = p; % ARX is the analytical part 34 E.res_threshold = 1.0; % resampling parameter34 E.res_threshold = 0.90; % resampling parameter 35 35 E.n = 100; % number of particles 36 36 E.prior.class = 'eDirich'; % prior on non-linear part 37 37 E.prior.beta = [2 1]; % 38 E.log_level = 'logbounds ';38 E.log_level = 'logbounds,logweights,logmeans'; 39 39 E.name = 'MPF'; 40 40 … … 59 59 title('Forgetting factor') 60 60 61 62 for i=1:E.n 63 -
library/bdm/base/bdmbase.cpp
r949 r950 442 442 }; 443 443 444 if ( log_level[logfull] ) { 445 // log full data 446 L.add_setting ( log_level, logfull, prefix ); 447 } else { 448 // log only 449 450 if ( log_level[logmean] ) 451 L.add_vector ( log_level, logmean, r, prefix ); 452 if ( log_level[loglbound] ) 453 L.add_vector ( log_level, loglbound, r, prefix ); 454 if ( log_level[logubound] ) 455 L.add_vector ( log_level, logubound, r, prefix ); 456 } 444 // log only 445 446 if ( log_level[logmean] ) 447 L.add_vector ( log_level, logmean, r, prefix ); 448 if ( log_level[loglbound] ) 449 L.add_vector ( log_level, loglbound, r, prefix ); 450 if ( log_level[logubound] ) 451 L.add_vector ( log_level, logubound, r, prefix ); 457 452 } 458 453 459 454 void epdf::log_write() const { 460 if ( log_level[logfull] ) { 461 log_level.store( logfull, this ); 462 } else { 463 if ( log_level[logmean] ) { 464 log_level.store( logmean, mean() ); 465 } 466 if ( log_level[loglbound] || log_level[logubound] ) { 467 vec lb; 468 vec ub; 469 qbounds ( lb, ub ); 470 if (log_level[loglbound]) 471 log_level.store( loglbound, lb ); 472 if (log_level[logubound]) 473 log_level.store( logubound, ub ); 474 } 475 } 476 } 455 if ( log_level[logmean] ) { 456 log_level.store( logmean, mean() ); 457 } 458 if ( log_level[loglbound] || log_level[logubound] ) { 459 vec lb; 460 vec ub; 461 qbounds ( lb, ub ); 462 if (log_level[loglbound]) 463 log_level.store( loglbound, lb ); 464 if (log_level[logubound]) 465 log_level.store( logubound, ub ); 466 } 467 } 468 477 469 478 470 … … 558 550 root::log_register ( L, prefix ); 559 551 552 if ( log_level[logfull] ) { 553 // log full data 554 L.add_setting ( log_level, logfull, prefix + L.separator + "posterior" ); 555 } 556 560 557 if ( log_level[logevidence] ) 561 558 L.add_vector ( log_level, logevidence, RV ( 1 ), prefix ); … … 565 562 prior().log_level[epdf::logubound]=true; 566 563 } 567 if (log_level[logfull]){568 prior().log_level[epdf::logfull]=true;569 }570 564 const_cast<epdf&> ( posterior() ).log_register ( L, prefix + L.separator + "apost" ); 571 565 } … … 573 567 void BM::log_write ( ) const { 574 568 posterior().log_write(); 575 569 if ( log_level[logfull] ) { 570 log_level.store( logfull, &posterior() ); 571 } 572 576 573 if( log_level[logevidence] ) 577 574 log_level.store( logevidence, ll ); -
library/bdm/base/bdmbase.h
r946 r950 670 670 //! \var log_level_enums logfull 671 671 //! log full record of the density in the form of setting 672 LOG_LEVEL(epdf,logmean,loglbound,logubound ,logfull);672 LOG_LEVEL(epdf,logmean,loglbound,logubound); 673 673 674 674 public: … … 1335 1335 void validate() 1336 1336 { 1337 if ( log_level[log full] ) {1338 const_cast<epdf&> ( posterior() ).log_level[epdf::log full] = true;1337 if ( log_level[logbounds] ) { 1338 const_cast<epdf&> ( posterior() ).log_level[epdf::loglbound] = true; 1339 1339 } else { 1340 if ( log_level[logbounds] ) { 1341 const_cast<epdf&> ( posterior() ).log_level[epdf::loglbound] = true; 1342 } else { 1343 const_cast<epdf&> ( posterior() ).log_level[epdf::logmean] = true;; 1344 } 1345 if ( log_level[logevidence] ) { 1346 } 1340 const_cast<epdf&> ( posterior() ).log_level[epdf::logmean] = true;; 1347 1341 } 1348 1342 } -
library/bdm/bdmroot.h
r945 r950 223 223 // add number to name only in the case there are more registered vectors with the same log_level_enum 224 224 if( ids(log_level_enum).length() > 1 ) 225 stream << " *" << enum_subindex;225 stream << "_" << enum_subindex; 226 226 227 227 return stream.str(); -
library/bdm/estim/particles.h
r907 r950 98 98 bm = UI::build<BM> ( set, "bm", UI::compulsory ); 99 99 } 100 101 void to_setting(const Setting &set){ 102 if (BM::log_level[logfull]){ 103 } 104 } 100 105 void validate(){ 101 106 est_emp.set_point(zeros(par->dimension())); … … 202 207 //! all weightes will be logged 203 208 204 //! \var log_level_enums samples205 //! all samples will be logged206 LOG_LEVEL(PF, weights,samples);209 //! \var log_level_enums menas 210 //! means of particles will be logged 211 LOG_LEVEL(PF,logweights,logmeans,logvars); 207 212 208 213 class pf_mix: public emix_base{ … … 300 305 void from_setting ( const Setting &set ) { 301 306 BM::from_setting ( set ); 307 UI::get ( log_level, set, "log_level", UI::optional ); 302 308 303 309 shared_ptr<BM> bm0 = UI::build<BM>(set, "particle",UI::compulsory); … … 320 326 BM::set_rv(bm0->_rv()); 321 327 yrv=bm0->_yrv(); 328 } 329 330 void log_register ( bdm::logger& L, const string& prefix ){ 331 BM::log_register(L,prefix); 332 if (log_level[logweights]){ 333 L.add_vector( log_level, logweights, RV ( particles.length()), prefix); 334 } 335 if (log_level[logmeans]){ 336 for (int i=0; i<particles.length(); i++){ 337 L.add_vector( log_level, logmeans, RV ( particles(i)->dimension() ), prefix , i); 338 } 339 } 340 }; 341 void log_write ( ) const { 342 BM::log_write(); 343 if (log_level[logweights]){ 344 log_level.store( logweights, w); 345 } 346 if (log_level[logmeans]){ 347 for (int i=0; i<particles.length(); i++){ 348 log_level.store( logmeans, particles(i)->posterior().mean(), i); 349 } 350 } 351 322 352 } 323 353