Changeset 1009 for library/bdm/base
- Timestamp:
- 05/27/10 23:07:16 (14 years ago)
- Location:
- library/bdm/base
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r979 r1009 575 575 } 576 576 577 void BM::bayes_batch ( const mat &Data, const vec &cond ) { 577 double BM::bayes_batch ( const mat &Data, const vec &cond ) { 578 double levid=0.0; 578 579 for ( int t = 0; t < Data.cols(); t++ ) { 579 580 bayes ( Data.get_col ( t ), cond ); 580 } 581 } 582 583 void BM::bayes_batch ( const mat &Data, const mat &Cond ) { 581 levid+=ll; 582 } 583 return levid; 584 } 585 586 double BM::bayes_batch ( const mat &Data, const mat &Cond ) { 587 double levid=0.0; 584 588 for ( int t = 0; t < Data.cols(); t++ ) { 585 589 bayes ( Data.get_col ( t ), Cond.get_col ( t ) ); 586 590 } 587 } 588 589 } 591 return levid; 592 } 593 594 } -
library/bdm/base/bdmbase.h
r989 r1009 1293 1293 @param dt vector of input data 1294 1294 */ 1295 virtual void bayes ( const vec &yt, const vec &cond = empty_vec ) = 1295 virtual void bayes ( const vec &yt, const vec &cond = empty_vec ) =0; 1296 1296 //! Batch Bayes rule (columns of Dt are observations) 1297 virtual voidbayes_batch ( const mat &Dt, const vec &cond = empty_vec );1297 virtual double bayes_batch ( const mat &Dt, const vec &cond = empty_vec ); 1298 1298 //! Batch Bayes rule (columns of Dt are observations, columns of Cond are conditions) 1299 virtual voidbayes_batch ( const mat &Dt, const mat &Cond );1299 virtual double bayes_batch ( const mat &Dt, const mat &Cond ); 1300 1300 //! Evaluates predictive log-likelihood of the given data record 1301 1301 //! I.e. marginal likelihood of the data with the posterior integrated out. 1302 1302 //! This function evaluates only \f$ y_t \f$, condition is assumed to be the last used in bayes(). 1303 1303 //! See bdm::BM::predictor for conditional version. 1304 virtual double logpred ( const vec &yt ) const NOT_IMPLEMENTED(0.0);1304 virtual double logpred ( const vec &yt, const vec &cond ) const NOT_IMPLEMENTED(0.0); 1305 1305 1306 1306 //! Matrix version of logpred 1307 vec logpred_mat ( const mat &Yt ) const {1307 vec logpred_mat ( const mat &Yt, const mat &Cond ) const { 1308 1308 vec tmp ( Yt.cols() ); 1309 1309 for ( int i = 0; i < Yt.cols(); i++ ) { 1310 tmp ( i ) = logpred ( Yt.get_col ( i ) );1310 tmp ( i ) = logpred ( Yt.get_col ( i ), Cond.get_col(i) ); 1311 1311 } 1312 1312 return tmp;