Changeset 441

Show
Ignore:
Timestamp:
07/29/09 08:29:35 (15 years ago)
Author:
vbarta
Message:

added configurable tests for egamma

Location:
library/tests
Files:
2 added
4 modified

Legend:

Unmodified
Added
Removed
  • library/tests/CMakeLists.txt

    r439 r441  
    3838 
    3939# using UnitTest++ 
    40 add_executable(testsuite datalink_test.cpp egiw_test.cpp enorm_test.cpp loggers_test.cpp rv_test.cpp square_mat_test.cpp testsuite.cpp test_user_info.cpp test_shared_ptr.cpp) 
     40add_executable(testsuite datalink_test.cpp egamma_test.cpp egiw_test.cpp enorm_test.cpp loggers_test.cpp rv_test.cpp square_mat_test.cpp testsuite.cpp test_user_info.cpp test_shared_ptr.cpp) 
    4141target_link_libraries(testsuite bdm itpp testutil unittest) 
    4242 
  • library/tests/egiw.cfg

    r440 r441  
    1818  nsamples = 200; 
    1919  integral = 1.0; 
     20}, 
     21{ 
     22  class = "egiw_harness"; 
     23  epdf = { 
     24    class = "egiw"; 
     25    V = ( "matrix", 2, 2, [ 20.0, 8.0, 8.0, 4.0 ] ); 
     26    nu = 4.0; 
     27    dimx = 1.0; 
     28    rv :  
     29    { 
     30      class = "RV"; 
     31      names = ( "a", "b" ); 
     32    }; 
     33  }; 
     34  mean = [ 2, -4 ]; 
     35  lognc = 0.451583; 
     36  variance = [ -1, -16 ]; 
    2037} ); 
    2138 
  • library/tests/epdf_harness.cpp

    r439 r441  
    4444    UI::get(mean, set, "mean"); 
    4545    UI::get(variance, set, "variance"); 
    46     UI::get(support, set, "support"); 
     46 
     47    if (set.exists("support")) { 
     48        UI::get(support, set, "support"); 
     49    } 
    4750 
    4851    if (set.exists("nsamples")) { 
     
    5053    } 
    5154 
    52     UI::get(integral, set, "integral"); 
     55    if (set.exists("integral")) { 
     56        UI::get(integral, set, "integral"); 
     57    } 
     58 
     59    if (set.exists("R")) { 
     60        UI::get(R, set, "R"); 
     61    } 
    5362} 
    5463 
     
    5867    CHECK_CLOSE(variance, hepdf->variance(), epsilon); 
    5968 
    60     vec xb = support.get_row(0); 
    61     vec yb = support.get_row(1); 
    62     CHECK_CLOSE(mean, num_mean2(hepdf.get(), xb, yb, nsamples, nsamples), 0.1); 
    63     CHECK_CLOSE(integral, normcoef(hepdf.get(), xb, yb, nsamples, nsamples), 0.1); 
     69    if (support.rows() == 2) { 
     70        vec xb = support.get_row(0); 
     71        vec yb = support.get_row(1); 
     72        CHECK_CLOSE(mean, num_mean2(hepdf.get(), xb, yb, nsamples, nsamples), 0.1); 
     73        CHECK_CLOSE(integral, normcoef(hepdf.get(), xb, yb, nsamples, nsamples), 0.1); 
     74    } 
     75 
     76    if (R.rows() > 0) { 
     77        mat Smp = hepdf->sample_m(10000); 
     78        int N = Smp.cols(); 
     79        vec Emu = Smp*ones(N) /N ; 
     80        mat Er = (Smp*Smp.transpose())/N - outer_product(Emu,Emu); 
     81        CHECK_CLOSE(mean, Emu, 0.1); 
     82        CHECK_CLOSE(R, Er, 0.1); 
     83    } 
    6484} 
    6585 
  • library/tests/epdf_harness.h

    r439 r441  
    3434    int nsamples; 
    3535    double integral; 
     36    mat R; 
    3637 
    3738public: