| 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 | } |