Changeset 523 for library/tests

Show
Ignore:
Timestamp:
08/13/09 12:22:27 (15 years ago)
Author:
vbarta
Message:

moved Wishart tests from testSmp to epdf_test

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/tests/epdf_test.cpp

    r493 r523  
    11#include "base/user_info.h" 
    22#include "stat/exp_family.h" 
     3#include "itpp_ext.h" 
    34#include "epdf_harness.h" 
     5#include "mat_checks.h" 
    46#include "UnitTest++.h" 
    57 
     
    1315        epdf_harness::test_config ( "enorm.cfg" ); 
    1416} 
     17 
     18TEST ( 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 
     34TEST ( 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}