Changeset 462 for library/tests

Show
Ignore:
Timestamp:
07/31/09 15:17:20 (16 years ago)
Author:
vbarta
Message:

moved test of marginal & condition to epdf_harness

Location:
library/tests
Files:
1 removed
6 modified

Legend:

Unmodified
Added
Removed
  • library/tests/CMakeLists.txt

    r457 r462  
    3333 
    3434# using UnitTest++ 
    35 add_executable(testsuite datalink_test.cpp egiw_test.cpp epdf_test.cpp loggers_test.cpp mepdf_test.cpp mpdf_test.cpp rv_test.cpp square_mat_test.cpp testsuite.cpp test_user_info.cpp test_shared_ptr.cpp) 
     35add_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) 
    3636target_link_libraries(testsuite bdm itpp testutil unittest) 
    3737 
  • library/tests/enorm.cfg

    r458 r462  
    1818  marginal_rv =     { 
    1919      class = "RV"; 
    20       names = ( "x" ); 
     20      names = ( "y" ); 
    2121    }; 
    22   tolerance = 0.2; 
     22  tolerance = 0.3; 
    2323}, 
    2424{ 
     
    3939  R = ( "matrix", 2, 2, [ 5.0, -0.05, -0.05, 5.2 ] ); 
    4040  nbins = [ 200, 200 ]; 
    41   tolerance = 0.5; 
     41  tolerance = 0.8; 
    4242}, 
    4343{ 
  • library/tests/epdf_harness.cpp

    r461 r462  
    33#include "base/user_info.h" 
    44#include "stat/exp_family.h" 
     5#include "stat/emix.h" 
    56#include "mat_checks.h" 
    67#include "test_util.h" 
    78#include "UnitTest++.h" 
     9#include <memory> 
    810 
    911namespace bdm { 
     
    4749    } 
    4850 
     51    if (set.exists("marginal_rv")) { 
     52        mrv = shared_ptr<RV>(UI::build<RV>(set, "marginal_rv")); 
     53    } 
     54 
    4955    if (set.exists("tolerance")) { 
    5056        UI::get(tolerance, set, "tolerance"); 
     
    7379        } 
    7480 
    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); 
    7783    } 
    7884 
     
    8591        CHECK_CLOSE_EX(R, er, tolerance); 
    8692    } 
     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    } 
    87124} 
    88125 
  • library/tests/epdf_harness.h

    r458 r462  
    3535    int nsamples; 
    3636    mat R; 
     37    shared_ptr<RV> mrv; 
    3738    double tolerance; 
    3839 
  • library/tests/mlnorm.cfg

    r459 r462  
    1111  mean = [ 1.5, 1.7 ]; 
    1212  R = ( "matrix", 2, 2, [ 1.26402, 0.378231, 0.378231, 5.15925 ] ); 
    13   tolerance = 0.4; 
     13  tolerance = 0.6; 
    1414} ); 
    1515 
  • library/tests/mpdf_test.cpp

    r459 r462  
    1818    ParticularUI<mlnorm<ldmat> >("mlnorm<ldmat>")); 
    1919 
     20TEST(test_mepdf) { 
     21    mpdf_harness::test_config("mepdf.cfg"); 
     22} 
     23 
    2024TEST(test_mgamma) { 
    2125    mpdf_harness::test_config("mgamma.cfg");