14 | | UIFile in ( config_file_name ); |
15 | | Array<shared_ptr<pdf_harness> > input; |
16 | | UI::get ( input, in, "data", UI::compulsory ); |
17 | | int sz = input.size(); |
18 | | CHECK ( sz > 0 ); |
19 | | for ( int i = 0; i < sz; ++i ) { |
20 | | input ( i )->test ( config_file_name, i ); |
21 | | } |
| 14 | UIFile in ( config_file_name ); |
| 15 | Array<shared_ptr<pdf_harness> > input; |
| 16 | UI::get ( input, in, "data", UI::compulsory ); |
| 17 | int sz = input.size(); |
| 18 | CHECK ( sz > 0 ); |
| 19 | for ( int i = 0; i < sz; ++i ) { |
| 20 | input ( i )->test ( config_file_name, i ); |
| 21 | } |
25 | | hpdf = UI::build<pdf> ( set, "pdf", UI::compulsory ); |
26 | | UI::get ( mean, set, "mean", UI::compulsory ); |
27 | | UI::get ( variance, set, "variance", UI::compulsory ); |
| 25 | hpdf = UI::build<pdf> ( set, "pdf", UI::compulsory ); |
| 26 | UI::get ( mean, set, "mean", UI::compulsory ); |
| 27 | UI::get ( variance, set, "variance", UI::compulsory ); |
33 | | UI::get ( nsamples, set, "nsamples", UI::optional ); |
34 | | UI::get ( R, set, "R", UI::optional ); |
35 | | UI::get ( tolerance, set, "tolerance", UI::optional ); |
| 33 | UI::get ( nsamples, set, "nsamples", UI::optional ); |
| 34 | UI::get ( R, set, "R", UI::optional ); |
| 35 | UI::get ( tolerance, set, "tolerance", UI::optional ); |
49 | | int tc = 0; |
50 | | Array<vec> actual ( CurrentContext::max_trial_count ); |
51 | | do { |
52 | | mat smp = hpdf->samplecond_mat ( cond, nsamples ); |
53 | | vec emu = smp * ones ( nsamples ) / nsamples; |
54 | | actual ( tc ) = emu; |
55 | | ++tc; |
56 | | } while ( ( tc < CurrentContext::max_trial_count ) && |
57 | | !UnitTest::AreClose ( mean, actual ( tc - 1 ), delta ) ); |
58 | | if ( ( tc == CurrentContext::max_trial_count ) && |
59 | | ( !UnitTest::AreClose ( mean, actual ( CurrentContext::max_trial_count - 1 ), delta ) ) ) { |
60 | | UnitTest::MemoryOutStream stream; |
61 | | stream << CurrentContext::format_context ( __LINE__ ) << "expected " << mean << " +/- " << delta << " but was " << actual; |
| 49 | int tc = 0; |
| 50 | Array<vec> actual ( CurrentContext::max_trial_count ); |
| 51 | do { |
| 52 | mat smp = hpdf->samplecond_mat ( cond, nsamples ); |
| 53 | vec emu = smp * ones ( nsamples ) / nsamples; |
| 54 | actual ( tc ) = emu; |
| 55 | ++tc; |
| 56 | } while ( ( tc < CurrentContext::max_trial_count ) && |
| 57 | !UnitTest::AreClose ( mean, actual ( tc - 1 ), delta ) ); |
| 58 | if ( ( tc == CurrentContext::max_trial_count ) && |
| 59 | ( !UnitTest::AreClose ( mean, actual ( CurrentContext::max_trial_count - 1 ), delta ) ) ) { |
| 60 | UnitTest::MemoryOutStream stream; |
| 61 | stream << CurrentContext::format_context ( __LINE__ ) << "expected " << mean << " +/- " << delta << " but was " << actual; |
70 | | int tc = 0; |
71 | | Array<mat> actual ( CurrentContext::max_trial_count ); |
72 | | do { |
73 | | mat smp = hpdf->samplecond_mat ( cond, nsamples ); |
74 | | vec emu = smp * ones ( nsamples ) / nsamples; |
75 | | mat er = ( smp * smp.T() ) / nsamples - outer_product ( emu, emu ); |
76 | | actual ( tc ) = er; |
77 | | ++tc; |
78 | | } while ( ( tc < CurrentContext::max_trial_count ) && |
79 | | !UnitTest::AreClose ( R, actual ( tc - 1 ), tolerance ) ); |
80 | | if ( ( tc == CurrentContext::max_trial_count ) && |
81 | | ( !UnitTest::AreClose ( R, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { |
82 | | UnitTest::MemoryOutStream stream; |
83 | | stream << CurrentContext::format_context ( __LINE__ ) << "expected " << R << " +/- " << tolerance << " but was " << actual; |
| 70 | int tc = 0; |
| 71 | Array<mat> actual ( CurrentContext::max_trial_count ); |
| 72 | do { |
| 73 | mat smp = hpdf->samplecond_mat ( cond, nsamples ); |
| 74 | vec emu = smp * ones ( nsamples ) / nsamples; |
| 75 | mat er = ( smp * smp.T() ) / nsamples - outer_product ( emu, emu ); |
| 76 | actual ( tc ) = er; |
| 77 | ++tc; |
| 78 | } while ( ( tc < CurrentContext::max_trial_count ) && |
| 79 | !UnitTest::AreClose ( R, actual ( tc - 1 ), tolerance ) ); |
| 80 | if ( ( tc == CurrentContext::max_trial_count ) && |
| 81 | ( !UnitTest::AreClose ( R, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { |
| 82 | UnitTest::MemoryOutStream stream; |
| 83 | stream << CurrentContext::format_context ( __LINE__ ) << "expected " << R << " +/- " << tolerance << " but was " << actual; |