- Timestamp:
- 08/08/09 13:43:16 (15 years ago)
- Location:
- library
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r488 r489 273 273 } 274 274 275 void mepdf::condition ( const vec &cond ) {276 }277 278 275 void mepdf::from_setting ( const Setting &set ) { 279 276 shared_ptr<epdf> e ( UI::build<epdf> ( set, "epdf", UI::compulsory ) ); 280 ipdf = e; 277 iepdf = e; 278 set_ep(iepdf.get()); 281 279 } 282 280 -
library/bdm/base/bdmbase.h
r488 r489 419 419 ep = &iepdf; 420 420 } 421 void set_ep (epdf *iepdfp) { 422 ep = iepdfp; 423 } 421 424 422 425 public: … … 436 439 437 440 //! Returns \param N samples from the density conditioned on \c cond, \f$x \sim epdf(rv|cond)\f$. \param cond is numeric value of \c rv 438 virtual mat samplecond_m (const vec &cond, int N) {it_error ("Not implemented");return mat();} 441 virtual mat samplecond_m (const vec &cond, int N) { 442 mat M(dimension(), N); 443 for(int i=0;i<N;i++){M.set_col(i, samplecond(cond));} 444 return M; 445 } 439 446 440 447 … … 443 450 444 451 //! Matrix version of evallogcond 445 virtual vec evallogcond_m (const mat &Dt, const vec &cond) {it_error ("Not implemented");return vec (0);} 452 virtual vec evallogcond_m (const mat &Dt, const vec &cond) { 453 vec v(Dt.cols()); 454 for(int i=0;i<Dt.cols();i++){v(i)= evallogcond(Dt.get_col(i),cond);} 455 return v; 456 } 446 457 447 458 //! Array<vec> version of evallogcond … … 718 729 { 719 730 720 shared_ptr<epdf> i pdf;731 shared_ptr<epdf> iepdf; 721 732 public: 722 733 //!Default constructor … … 724 735 725 736 mepdf (shared_ptr<epdf> em) { 726 i pdf = em;727 set_ep (*i pdf.get());737 iepdf = em; 738 set_ep (*iepdf.get()); 728 739 dimc = 0; 729 740 } 730 741 731 742 //! empty 732 void condition (const vec &cond); 743 vec samplecond(const vec &cond){return iepdf->sample();} 744 double evallogcond(const vec &val, const vec &cond){return iepdf->evallog(val);} 733 745 734 746 //! Load from structure with elements: -
library/tests/epdf_harness.cpp
r484 r489 175 175 } while ( ( tc < CurrentContext::max_trial_count ) && 176 176 !UnitTest::AreClose ( R, actual( tc - 1 ), tolerance ) ); 177 177 178 if ( ( tc == CurrentContext::max_trial_count ) && 178 179 ( !UnitTest::AreClose ( R, actual( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { -
library/tests/mepdf.cfg
r484 r489 18 18 mean = [ 1.1, -1.0 ]; 19 19 R = ( "matrix", 2, 2, [ 1.0, -0.5, -0.5, 2.0 ] ); 20 variance = [ 1.0, 2.0 ]; 20 21 tolerance = 0.1; 21 variance = [ 0.3, 0.3 ];22 22 } ); 23 23 -
library/tests/mgamma.cfg
r484 r489 20 20 mean = [ 1.5, 1.7 ]; 21 21 R = ( "matrix", 2, 2, [ 2.25, 0.0, 0.0, 2.89 ] ); 22 variance = [ 0.4, 0.4];22 variance = [ 2.25, 2.89]; 23 23 tolerance = 0.4; 24 24 } ); -
library/tests/mlnorm.cfg
r484 r489 10 10 cond = [ 1.5, 1.7 ]; 11 11 mean = [ 1.5, 1.7 ]; 12 R = ( "matrix", 2, 2, [ 1.26402, 0.378231, 0.378231, 5.15925 ] ); 12 R = ( "matrix", 2, 2, [ 1.2, 0.3, 0.3, 5.0 ] ); 13 variance = [ 1.2, 5.0 ]; 13 14 tolerance = 0.6; 14 variance = [ 0.2, 0.2 ]; 15 } ); 15 }, 16 { 17 class = "mpdf_harness"; 18 mpdf = { 19 class = "mlnorm<chmat>"; 20 A = ( "matrix", 2, 2, [ 1.0, 0.0, 0.0, 1.0 ] ); 21 const = [ 0, 0 ]; 22 R = ( "matrix", 2, 2, [ 1.2, 0.3, 0.3, 5.0 ] ); 23 }; 24 cond = [ 1.5, 1.7 ]; 25 mean = [ 1.5, 1.7 ]; 26 R = ( "matrix", 2, 2, [ 1.2, 0.3, 0.3, 5.0 ] ); 27 variance = [ 1.2, 5.0 ]; 28 tolerance = 0.6; 29 }); 16 30