Changeset 502
- Timestamp:
- 08/11/09 15:27:34 (15 years ago)
- Location:
- library
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r489 r502 140 140 } 141 141 142 vec epdf::evallog_m (const mat &Val) const { 143 vec x (Val.cols()); 144 for (int i = 0; i < Val.cols(); i++) { 145 x (i) = evallog ( Val.get_col (i) ); 146 } 147 148 return x; 149 } 150 151 vec epdf::evallog_m (const Array<vec> &Avec) const { 152 vec x (Avec.size()); 153 for (int i = 0; i < Avec.size(); i++) { 154 x (i) = evallog ( Avec (i) ); 155 } 156 157 return x; 158 } 142 159 143 160 void mpdf::from_setting ( const Setting &set ) { -
library/bdm/base/bdmbase.h
r489 r502 296 296 //! Returns a sample, \f$ x \f$ from density \f$ f_x()\f$ 297 297 virtual vec sample() const { 298 it_error ("not implem neted");298 it_error ("not implemented"); 299 299 return vec (0); 300 }; 300 } 301 301 302 //! Returns N samples, \f$ [x_1 , x_2 , \ldots \ \f$ from density \f$ f_x(rv)\f$ 302 303 virtual mat sample_m (int N) const; 304 303 305 //! Compute log-probability of argument \c val 304 306 //! In case the argument is out of suport return -Infinity 305 307 virtual double evallog (const vec &val) const { 306 it_error ("not implem neted");308 it_error ("not implemented"); 307 309 return 0.0; 308 }; 310 } 311 309 312 //! Compute log-probability of multiple values argument \c val 310 virtual vec evallog_m (const mat &Val) const { 311 vec x (Val.cols()); 312 for (int i = 0; i < Val.cols(); i++) { 313 x (i) = evallog (Val.get_col (i)) ; 314 } 315 return x; 316 } 313 virtual vec evallog_m (const mat &Val) const; 314 317 315 //! Compute log-probability of multiple values argument \c val 318 virtual vec evallog_m (const Array<vec> &Avec) const { 319 vec x (Avec.size()); 320 for (int i = 0; i < Avec.size(); i++) { 321 x (i) = evallog (Avec (i)) ; 322 } 323 return x; 324 } 316 virtual vec evallog_m (const Array<vec> &Avec) const; 317 325 318 //! Return conditional density on the given RV, the remaining rvs will be in conditioning 326 319 virtual mpdf* condition (const RV &rv) const { -
library/tests/epdf_harness.cpp
r493 r502 87 87 } 88 88 89 CHECK_CLOSE_EX ( hepdf->evallog ( zeron ), mEp.evallogcond ( zeron, zero ), tolerance ); 89 double lpz = hepdf->evallog ( zeron ); 90 CHECK_CLOSE_EX ( lpz, mEp.evallogcond ( zeron, zero ), tolerance ); 91 92 vec lpzv(1); 93 lpzv(0) = lpz; 94 95 mat zero1n ( hepdf->dimension(), 1 ); 96 for ( int i = 0; i < zero1n.rows(); ++i ) { 97 zero1n ( i, 0 ) = 0; 98 } 99 100 vec lpzv_act = hepdf->evallog_m ( zero1n ); 101 CHECK_CLOSE_EX ( lpzv, lpzv_act, tolerance ); 102 103 Array<vec> zeroa(3); 104 lpzv = vec( zeroa.size() ); 105 for ( int i = 0; i < zeroa.size(); ++i ) { 106 zeroa(i) = zeron; 107 lpzv(i) = lpz; 108 } 109 110 lpzv_act = hepdf->evallog_m ( zeroa ); 111 CHECK_CLOSE_EX ( lpzv, lpzv_act, tolerance ); 90 112 } 91 113 }