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

Sampling from egiw

Files:
1 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 ) ) ) {