|
Revision 523, 1.1 kB
(checked in by vbarta, 16 years ago)
|
|
moved Wishart tests from testSmp to epdf_test
|
| Line | |
|---|
| 1 | #include "base/user_info.h" |
|---|
| 2 | #include "stat/exp_family.h" |
|---|
| 3 | #include "itpp_ext.h" |
|---|
| 4 | #include "epdf_harness.h" |
|---|
| 5 | #include "mat_checks.h" |
|---|
| 6 | #include "UnitTest++.h" |
|---|
| 7 | |
|---|
| 8 | using namespace bdm; |
|---|
| 9 | |
|---|
| 10 | TEST ( test_egamma ) { |
|---|
| 11 | epdf_harness::test_config ( "egamma.cfg" ); |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | TEST ( test_enorm ) { |
|---|
| 15 | epdf_harness::test_config ( "enorm.cfg" ); |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | TEST ( test_ewishart ) { |
|---|
| 19 | mat wM = "1.0 0.9; 0.9 1.0"; |
|---|
| 20 | eWishartCh eW; |
|---|
| 21 | eW.set_parameters ( wM / 100, 100 ); |
|---|
| 22 | mat mea = zeros ( 2, 2 ); |
|---|
| 23 | mat Ch; |
|---|
| 24 | for ( int i = 0; i < 100; i++ ) { |
|---|
| 25 | Ch = eW.sample_mat(); |
|---|
| 26 | mea += Ch.T() * Ch; |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | mat observed ( "0.978486 0.88637; 0.88637 0.992141" ); |
|---|
| 30 | mat actual = mea / 100; |
|---|
| 31 | CHECK_CLOSE ( observed, actual, 0.1 ); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | TEST ( test_rwiwishart ) { |
|---|
| 35 | mat wM = "1.0 0.9; 0.9 1.0"; |
|---|
| 36 | rwiWishartCh rwW; |
|---|
| 37 | rwW.set_parameters ( 2, 0.1, "1 1", 0.9 ); |
|---|
| 38 | mat mea = zeros ( 2, 2 ); |
|---|
| 39 | mat wMch = chol ( wM ); |
|---|
| 40 | mat Ch ( 2, 2 ); |
|---|
| 41 | for ( int i = 0; i < 100; i++ ) { |
|---|
| 42 | vec tmp = rwW.samplecond ( vec ( wMch._data(), 4 ) ); |
|---|
| 43 | copy_vector ( 4, tmp._data(), Ch._data() ); |
|---|
| 44 | mea += Ch.T() * Ch; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | mat observed ( "0.99464 0.885458; 0.885458 1.01853" ); |
|---|
| 48 | mat actual = mea / 100; |
|---|
| 49 | CHECK_CLOSE ( observed, actual, 0.1 ); |
|---|
| 50 | } |
|---|