- Timestamp:
- 07/31/09 15:17:20 (15 years ago)
- Location:
- library
- Files:
-
- 1 removed
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r461 r462 318 318 } 319 319 320 void mepdf::condition(const vec &cond) { 321 } 322 323 void mepdf::from_setting(const Setting &set) { 324 shared_ptr<epdf> e(UI::build<epdf>(set, "epdf")); 325 set_ep(e); 326 } 327 320 328 RV compositepdf::getrv ( bool checkoverlap ) { 321 329 RV rv; //empty rv -
library/bdm/base/bdmbase.h
r461 r462 611 611 class mepdf : public mpdf { 612 612 public: 613 //!Default constructor 614 mepdf() { } 615 616 mepdf(shared_ptr<epdf> em) :mpdf ( ) { set_ep(em); dimc=0; } 617 618 void condition ( const vec &cond ) {} 619 620 //! Load from structure with elements: 621 //! \code 622 //! { class = "mepdf", 623 //! epdfs = {class="epdfs",...} 624 //! } 625 //! \endcode 626 //!@} 627 void from_setting(const Setting &set){ 628 epdf *e = UI::build<epdf>(set, "epdf"); 629 set_ep(e); 630 } 613 //!Default constructor 614 mepdf() { } 615 616 mepdf(shared_ptr<epdf> em) { 617 set_ep(em); 618 dimc = 0; 619 } 620 621 //! empty 622 void condition(const vec &cond); 623 624 //! Load from structure with elements: 625 //! \code 626 //! { class = "mepdf", 627 //! epdfs = {class="epdfs",...} 628 //! } 629 //! \endcode 630 //!@} 631 void from_setting(const Setting &set); 631 632 }; 632 633 UIREGISTER(mepdf); -
library/tests/CMakeLists.txt
r457 r462 33 33 34 34 # using UnitTest++ 35 add_executable(testsuite datalink_test.cpp egiw_test.cpp epdf_test.cpp loggers_test.cpp m epdf_test.cpp mpdf_test.cpp rv_test.cpp square_mat_test.cpp testsuite.cpp test_user_info.cpp test_shared_ptr.cpp)35 add_executable(testsuite datalink_test.cpp egiw_test.cpp epdf_test.cpp loggers_test.cpp mpdf_test.cpp rv_test.cpp square_mat_test.cpp testsuite.cpp test_user_info.cpp test_shared_ptr.cpp) 36 36 target_link_libraries(testsuite bdm itpp testutil unittest) 37 37 -
library/tests/enorm.cfg
r458 r462 18 18 marginal_rv = { 19 19 class = "RV"; 20 names = ( " x" );20 names = ( "y" ); 21 21 }; 22 tolerance = 0. 2;22 tolerance = 0.3; 23 23 }, 24 24 { … … 39 39 R = ( "matrix", 2, 2, [ 5.0, -0.05, -0.05, 5.2 ] ); 40 40 nbins = [ 200, 200 ]; 41 tolerance = 0. 5;41 tolerance = 0.8; 42 42 }, 43 43 { -
library/tests/epdf_harness.cpp
r461 r462 3 3 #include "base/user_info.h" 4 4 #include "stat/exp_family.h" 5 #include "stat/emix.h" 5 6 #include "mat_checks.h" 6 7 #include "test_util.h" 7 8 #include "UnitTest++.h" 9 #include <memory> 8 10 9 11 namespace bdm { … … 47 49 } 48 50 51 if (set.exists("marginal_rv")) { 52 mrv = shared_ptr<RV>(UI::build<RV>(set, "marginal_rv")); 53 } 54 49 55 if (set.exists("tolerance")) { 50 56 UI::get(tolerance, set, "tolerance"); … … 73 79 } 74 80 75 CHECK_CLOSE_EX(mean, num_mean2(hepdf.get(), xb, yb, nbins(0), nbins(1)), 0.1);76 CHECK_CLOSE_EX(1.0, normcoef(hepdf.get(), xb, yb, nbins(0), nbins(1)), 0.1);81 CHECK_CLOSE_EX(mean, num_mean2(hepdf.get(), xb, yb, nbins(0), nbins(1)), tolerance); 82 CHECK_CLOSE_EX(1.0, normcoef(hepdf.get(), xb, yb, nbins(0), nbins(1)), tolerance); 77 83 } 78 84 … … 85 91 CHECK_CLOSE_EX(R, er, tolerance); 86 92 } 93 94 if (mrv.get()) { 95 RV crv = hepdf->_rv().subt(*mrv); 96 shared_ptr<epdf> m = hepdf->marginal(*mrv); 97 shared_ptr<mpdf> c = hepdf->condition(crv); 98 mepdf mm(m); 99 100 Array<mpdf *> aa(2); 101 aa(0) = c.get(); 102 aa(1) = &mm; 103 mprod mEp(aa); 104 105 int n = nsamples; 106 mat smp = mEp.samplecond(vec(0), n); 107 vec emu = sum(smp, 2) / n; 108 CHECK_CLOSE_EX(mean, emu, tolerance); 109 110 if (R.rows() > 0) { 111 mat er = (smp * smp.T()) / n - outer_product(emu, emu); 112 CHECK_CLOSE_EX(R, er, tolerance); 113 } 114 115 // test of pdflog at zero 116 vec zero(0); 117 vec zeron(hepdf->dimension()); 118 for (int i = 0; i < zeron.size(); ++i) { 119 zeron(i) = 0; 120 } 121 122 CHECK_CLOSE_EX(hepdf->evallog(zeron), mEp.evallogcond(zeron, zero), tolerance); 123 } 87 124 } 88 125 -
library/tests/epdf_harness.h
r458 r462 35 35 int nsamples; 36 36 mat R; 37 shared_ptr<RV> mrv; 37 38 double tolerance; 38 39 -
library/tests/mlnorm.cfg
r459 r462 11 11 mean = [ 1.5, 1.7 ]; 12 12 R = ( "matrix", 2, 2, [ 1.26402, 0.378231, 0.378231, 5.15925 ] ); 13 tolerance = 0. 4;13 tolerance = 0.6; 14 14 } ); 15 15 -
library/tests/mpdf_test.cpp
r459 r462 18 18 ParticularUI<mlnorm<ldmat> >("mlnorm<ldmat>")); 19 19 20 TEST(test_mepdf) { 21 mpdf_harness::test_config("mepdf.cfg"); 22 } 23 20 24 TEST(test_mgamma) { 21 25 mpdf_harness::test_config("mgamma.cfg");