44 | | // test if ARX and emix with one ARX are the same |
45 | | epdf_ptr Mm = M1.marginal ( y ); |
46 | | epdf_ptr Am = E1->marginal ( y ); |
47 | | pdf_ptr Mc = M1.condition ( y ); |
48 | | pdf_ptr Ac = E1->condition ( y ); |
| 44 | // test if ARX and emix with one ARX are the same |
| 45 | epdf_ptr Mm = M1.marginal ( y ); |
| 46 | epdf_ptr Am = E1->marginal ( y ); |
| 47 | pdf_ptr Mc = M1.condition ( y ); |
| 48 | pdf_ptr Ac = E1->condition ( y ); |
50 | | mlnorm<ldmat> *wacnd = dynamic_cast<mlnorm<ldmat> *> ( Ac.get() ); |
51 | | CHECK ( wacnd ); |
52 | | if ( wacnd ) { |
53 | | CHECK_CLOSE ( mat ( "-0.349953" ), wacnd->_A(), epsilon ); |
54 | | CHECK_CLOSE ( vec ( "1.39564" ), wacnd->_mu_const(), epsilon ); |
55 | | CHECK_CLOSE ( mat ( "0.939557" ), wacnd->_R(), epsilon ); |
56 | | } |
| 50 | mlnorm<ldmat> *wacnd = dynamic_cast<mlnorm<ldmat> *> ( Ac.get() ); |
| 51 | CHECK ( wacnd ); |
| 52 | if ( wacnd ) { |
| 53 | CHECK_CLOSE ( mat ( "-0.349953" ), wacnd->_A(), epsilon ); |
| 54 | CHECK_CLOSE ( vec ( "1.39564" ), wacnd->_mu_const(), epsilon ); |
| 55 | CHECK_CLOSE ( mat ( "0.939557" ), wacnd->_R(), epsilon ); |
| 56 | } |
58 | | double same = -1.46433; |
59 | | CHECK_CLOSE ( same, Mm->evallog ( vec_1 ( 0.0 ) ), epsilon ); |
60 | | CHECK_CLOSE ( same, Am->evallog ( vec_1 ( 0.0 ) ), epsilon ); |
61 | | CHECK_CLOSE ( 0.145974, Mc->evallogcond ( vec_1 ( 0.0 ), vec_1 ( 0.0 ) ), epsilon ); |
62 | | CHECK_CLOSE ( -1.92433, Ac->evallogcond ( vec_1 ( 0.0 ), vec_1 ( 0.0 ) ), epsilon ); |
| 58 | double same = -1.46433; |
| 59 | CHECK_CLOSE ( same, Mm->evallog ( vec_1 ( 0.0 ) ), epsilon ); |
| 60 | CHECK_CLOSE ( same, Am->evallog ( vec_1 ( 0.0 ) ), epsilon ); |
| 61 | CHECK_CLOSE ( 0.145974, Mc->evallogcond ( vec_1 ( 0.0 ), vec_1 ( 0.0 ) ), epsilon ); |
| 62 | CHECK_CLOSE ( -1.92433, Ac->evallogcond ( vec_1 ( 0.0 ), vec_1 ( 0.0 ) ), epsilon ); |
101 | | int tc = 0; |
102 | | Array<vec> actual ( CurrentContext::max_trial_count ); |
103 | | do { |
104 | | mat smp = distrib_obj.sample_mat ( nsamples ); |
105 | | vec emu = sum ( smp, 2 ) / nsamples; |
106 | | actual ( tc ) = emu; |
107 | | ++tc; |
108 | | } while ( ( tc < CurrentContext::max_trial_count ) && |
109 | | !UnitTest::AreClose ( mean, actual ( tc - 1 ), tolerance ) ); |
110 | | if ( ( tc == CurrentContext::max_trial_count ) && |
111 | | ( !UnitTest::AreClose ( mean, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { |
112 | | UnitTest::MemoryOutStream stream; |
113 | | UnitTest::TestDetails details ( *UnitTest::CurrentTest::Details(), __LINE__ ); |
114 | | stream << "Expected " << mean << " +/- " << tolerance << " but was " << actual; |
| 101 | int tc = 0; |
| 102 | Array<vec> actual ( CurrentContext::max_trial_count ); |
| 103 | do { |
| 104 | mat smp = distrib_obj.sample_mat ( nsamples ); |
| 105 | vec emu = sum ( smp, 2 ) / nsamples; |
| 106 | actual ( tc ) = emu; |
| 107 | ++tc; |
| 108 | } while ( ( tc < CurrentContext::max_trial_count ) && |
| 109 | !UnitTest::AreClose ( mean, actual ( tc - 1 ), tolerance ) ); |
| 110 | if ( ( tc == CurrentContext::max_trial_count ) && |
| 111 | ( !UnitTest::AreClose ( mean, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { |
| 112 | UnitTest::MemoryOutStream stream; |
| 113 | UnitTest::TestDetails details ( *UnitTest::CurrentTest::Details(), __LINE__ ); |
| 114 | stream << "Expected " << mean << " +/- " << tolerance << " but was " << actual; |
121 | | int tc = 0; |
122 | | Array<mat> actual ( CurrentContext::max_trial_count ); |
123 | | do { |
124 | | mat smp = distrib_obj.sample_mat ( nsamples ); |
125 | | vec emu = sum ( smp, 2 ) / nsamples; |
126 | | mat er = ( smp * smp.T() ) / nsamples - outer_product ( emu, emu ); |
127 | | actual ( tc ) = er; |
128 | | ++tc; |
129 | | } while ( ( tc < CurrentContext::max_trial_count ) && |
130 | | !UnitTest::AreClose ( R, actual ( tc - 1 ), tolerance ) ); |
131 | | if ( ( tc == CurrentContext::max_trial_count ) && |
132 | | ( !UnitTest::AreClose ( R, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { |
133 | | UnitTest::MemoryOutStream stream; |
134 | | UnitTest::TestDetails details ( *UnitTest::CurrentTest::Details(), __LINE__ ); |
135 | | stream << "Expected " << R << " +/- " << tolerance << " but was " << actual; |
| 121 | int tc = 0; |
| 122 | Array<mat> actual ( CurrentContext::max_trial_count ); |
| 123 | do { |
| 124 | mat smp = distrib_obj.sample_mat ( nsamples ); |
| 125 | vec emu = sum ( smp, 2 ) / nsamples; |
| 126 | mat er = ( smp * smp.T() ) / nsamples - outer_product ( emu, emu ); |
| 127 | actual ( tc ) = er; |
| 128 | ++tc; |
| 129 | } while ( ( tc < CurrentContext::max_trial_count ) && |
| 130 | !UnitTest::AreClose ( R, actual ( tc - 1 ), tolerance ) ); |
| 131 | if ( ( tc == CurrentContext::max_trial_count ) && |
| 132 | ( !UnitTest::AreClose ( R, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { |
| 133 | UnitTest::MemoryOutStream stream; |
| 134 | UnitTest::TestDetails details ( *UnitTest::CurrentTest::Details(), __LINE__ ); |
| 135 | stream << "Expected " << R << " +/- " << tolerance << " but was " << actual; |