Changeset 170 for bdm/stat/libBM.h
- Timestamp:
- 09/24/08 13:07:50 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/stat/libBM.h
r168 r170 103 103 //!access function 104 104 std::string name ( int at ) {return names ( at );}; 105 //!Assign unused ids to this rv 106 void newids(); 105 107 }; 106 108 … … 144 146 epdf ( const RV &rv0 ) :rv ( rv0 ) {}; 145 147 146 //! Returns the required moment of the epdf148 // //! Returns the required moment of the epdf 147 149 // virtual vec moment ( const int order = 1 ); 150 148 151 //! Returns a sample, \f$x\f$ from density \f$epdf(rv)\f$ 149 152 virtual vec sample () const =0; … … 156 159 virtual double evalpdflog ( const vec &val ) const =0; 157 160 161 //! Compute log-probability of multiple values argument \c val 162 virtual vec evalpdflog ( const mat &Val ) const { 163 vec x ( Val.cols() ); 164 for ( int i=0;i<Val.cols();i++ ) {x ( i ) =evalpdflog( Val.get_col(i) ) ;} 165 return x; 166 } 167 158 168 //! return expected value 159 169 virtual vec mean() const =0; … … 162 172 virtual ~epdf() {}; 163 173 //! access function, possibly dangerous! 164 RV& _rv() {return rv;} 174 const RV& _rv() const {return rv;} 175 //! modifier function - useful when copying epdfs 176 void _renewrv(const RV &in_rv){rv=in_rv;} 165 177 }; 166 178 … … 270 282 271 283 //!Default constructor 272 BM ( const RV &rv0 ) :rv ( rv0 ), ll ( 0 ),evalll ( true) {//Fixme: test rv284 BM ( const RV &rv0, double ll0=0,bool evalll0=true ) :rv ( rv0 ), ll ( ll0 ),evalll ( evalll0) {//Fixme: test rv 273 285 }; 286 //!Copy constructor 287 BM (const BM &B) : rv(B.rv), ll(B.ll), evalll(B.evalll) {} 274 288 275 289 /*! \brief Incremental Bayes rule … … 278 292 virtual void bayes ( const vec &dt ) = 0; 279 293 //! Batch Bayes rule (columns of Dt are observations) 280 v oid bayes ( matDt );294 virtual void bayesB (const mat &Dt ); 281 295 //! Returns a pointer to the epdf representing posterior density on parameters. Use with care! 282 virtual epdf& _epdf() =0; 283 296 virtual const epdf& _epdf() const =0; 297 298 //! Evaluates predictive log-likelihood of the given data record 299 //! I.e. marginal likelihood of the data with the posterior integrated out. 300 virtual double logpred(const vec &dt)const{it_error("Not implemented");return 0.0;} 301 284 302 //! Destructor for future use; 285 303 virtual ~BM() {}; … … 290 308 //!access function 291 309 void set_evalll(bool evl0){evalll=evl0;} 310 311 //! Copy function required in vectors, Arrays of BM etc. Have to be DELETED manually! 312 //! Prototype: BM* _copy_(){BM Tmp*=new Tmp(this*); return Tmp; } 313 virtual BM* _copy_(bool changerv=false){it_error("function _copy_ not implemented for this BM"); return NULL;}; 292 314 }; 293 315