Changeset 725 for library/tests

Show
Ignore:
Timestamp:
11/17/09 00:53:54 (15 years ago)
Author:
smidl
Message:

Sampling from egiw

Location:
library/tests
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • library/tests/epdf_harness.cpp

    r722 r725  
    5959        } 
    6060 
    61         if ( R.rows() > 0 ) { 
     61        if ( variance.length() > 0 ) { 
    6262                check_sample_mean(); 
     63        } 
     64        if (R.rows()>0){ 
    6365                check_covariance(); 
    6466        } 
     
    114116        vec yb = support.get_row ( 1 ); 
    115117 
    116         int tc = 0; 
    117         Array<vec> actual ( CurrentContext::max_trial_count ); 
    118         do { 
    119                 vec emu = num_mean2 ( hepdf.get(), xb, yb, nbins ( 0 ), nbins ( 1 ) ); 
    120                 actual ( tc ) = emu; 
    121                 ++tc; 
    122         } while ( ( tc < CurrentContext::max_trial_count ) && 
    123                   !UnitTest::AreClose ( mean, actual ( tc - 1 ), tolerance ) ); 
    124         if ( ( tc == CurrentContext::max_trial_count ) && 
    125                 ( !UnitTest::AreClose ( mean, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { 
    126                 UnitTest::MemoryOutStream stream; 
    127                 stream << CurrentContext::format_context ( __LINE__ ) << "expected " << mean << " +/- " << tolerance << " but was " << actual; 
    128  
    129                 UnitTest::TestDetails details ( *UnitTest::CurrentTest::Details(), 0, false ); 
    130  
    131                 UnitTest::CurrentTest::Results()->OnTestFailure ( details, stream.GetText() ); 
    132         } 
     118        vec actual; 
     119        actual = num_mean2 ( hepdf.get(), xb, yb, nbins ( 0 ), nbins ( 1 ) ); 
     120 
     121        CHECK_CLOSE(mean, actual, tolerance); 
    133122} 
    134123 
     
    137126        vec yb = support.get_row ( 1 ); 
    138127 
    139         int tc = 0; 
    140         Array<double> actual ( CurrentContext::max_trial_count ); 
    141         do { 
    142                 double nc = normcoef ( hepdf.get(), xb, yb, nbins ( 0 ), nbins ( 1 ) ); 
    143                 actual ( tc ) = nc; 
    144                 ++tc; 
    145         } while ( ( tc < CurrentContext::max_trial_count ) && 
    146                   !UnitTest::AreClose ( 1.0, actual ( tc - 1 ), tolerance ) ); 
    147         if ( ( tc == CurrentContext::max_trial_count ) && 
    148                 ( !UnitTest::AreClose ( 1.0, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { 
    149                 UnitTest::MemoryOutStream stream; 
    150                 stream << CurrentContext::format_context ( __LINE__ ) << "expected " << mean << " +/- " << tolerance << " but was " << actual; 
    151  
    152                 UnitTest::TestDetails details ( *UnitTest::CurrentTest::Details(), 0, false ); 
    153  
    154                 UnitTest::CurrentTest::Results()->OnTestFailure ( details, stream.GetText() ); 
    155         } 
     128        double nc = normcoef ( hepdf.get(), xb, yb, nbins ( 0 ), nbins ( 1 ) ); 
     129        CHECK_CLOSE(1.0,nc,0.01); 
    156130} 
    157131 
     
    168142        } while ( ( tc < CurrentContext::max_trial_count ) && 
    169143                  !UnitTest::AreClose ( mean, actual ( tc - 1 ), delta ) ); 
     144                           
    170145        if ( ( tc == CurrentContext::max_trial_count ) && 
    171146                ( !UnitTest::AreClose ( mean, actual ( CurrentContext::max_trial_count - 1 ), delta ) ) ) { 
  • library/tests/testsuite/egiw.cfg

    r717 r725  
    1212    }; 
    1313  }; 
    14   mean = [ 1.1, 0.1 ]; 
    15   variance = [ 0.01, 8e-05 ]; 
     14  mean = [ 1.1, 0.2 ]; 
     15  variance = [ 0.02, 0.01333 ]; 
    1616  support = ( "matrix", 2, 2, [ -2.0, 4.0, 0.01, 2.0 ] ); 
    1717  nbins = [ 100, 200 ]; 
    18   tolerance = 0.2; 
     18  tolerance = 0.01; 
    1919}, 
    2020{ 
     
    3333  mean = [2.0, 1.14286]; 
    3434  variance = [0.0285714, 0.0395795]; 
     35  support = ( "matrix", 2, 2, [ 0.0, 4.0, 0.01, 3.0 ] ); 
     36  nbins = [ 100, 200 ]; 
     37  tolerance = 0.01; 
    3538} ); 
    3639 
  • library/tests/testsuite/epdf_test.cpp

    r723 r725  
    4343 
    4444TEST ( ewishart_test ) { 
    45         mat wM = "1.0 0.9; 0.9 1.0"; 
     45        mat wM = "10.0 0.9; 0.9 1.0"; 
    4646        eWishartCh eW; 
    4747        eW.set_parameters ( wM / 100, 100 ); 
     
    5353        } 
    5454 
    55         mat observed ( "0.978486 0.88637; 0.88637 0.992141" ); 
    5655        mat actual = mea / 100; 
    57         CHECK_CLOSE ( observed, actual, 0.1 ); 
     56        CHECK_CLOSE ( wM, actual, 0.1 ); 
    5857} 
    5958