Changeset 524
- Timestamp:
- 08/13/09 12:23:30 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/tests/mpdf_test.cpp
r516 r524 9 9 using namespace bdm; 10 10 11 static void check_mean(m mix &mMix, const vec &mu0, int nsamples, const vec &mean, double tolerance);11 static void check_mean(mpdf &distrib_obj, const vec &mu0, int nsamples, const vec &mean, double tolerance); 12 12 13 static void check_covariance(mmix & mMix, const vec &mu0, int nsamples, const mat &R, double tolerance);13 static void check_covariance(mmix &distrib_obj, const vec &mu0, int nsamples, const mat &R, double tolerance); 14 14 15 15 TEST ( test_mepdf ) { … … 68 68 } 69 69 70 static void check_mean(mmix &mMix, const vec &mu0, int nsamples, const vec &mean, double tolerance) { 70 // not using mpdf_harness because emix isn't configurable (yet?) 71 TEST ( test_mepdf_emix ) { 72 int N = 10000; //number of samples 73 vec mu0 ( "1.5 1.7" ); 74 mat V0 ( "1.2 0.3; 0.3 5" ); 75 ldmat R = ldmat ( V0 ); 76 77 shared_ptr<enorm<ldmat> > eN = new enorm<ldmat>(); 78 eN->set_parameters ( mu0, R ); 79 80 vec a = "100000,10000"; 81 vec b = a / 10.0; 82 shared_ptr<egamma> eG = new egamma(); 83 eG->set_parameters ( a, b ); 84 85 shared_ptr<emix> eMix = new emix(); 86 Array<shared_ptr<epdf> > Coms ( 2 ); 87 Coms ( 0 ) = eG; 88 Coms ( 1 ) = eN; 89 90 eMix->set_parameters ( vec_2 ( 0.5, 0.5 ), Coms ); 91 mepdf meMix ( eMix ); 92 check_mean ( meMix, mu0, N, eMix->mean(), 0.1 ); 93 } 94 95 static void check_mean(mpdf &distrib_obj, const vec &mu0, int nsamples, const vec &mean, double tolerance) { 71 96 int tc = 0; 72 97 Array<vec> actual(CurrentContext::max_trial_count); 73 98 do { 74 mat smp = mMix.samplecond_m ( mu0, nsamples );99 mat smp = distrib_obj.samplecond_m ( mu0, nsamples ); 75 100 vec emu = smp * ones ( nsamples ) / nsamples ; 76 101 actual( tc ) = emu; … … 88 113 } 89 114 90 static void check_covariance(mmix & mMix, const vec &mu0, int nsamples, const mat &R, double tolerance) {115 static void check_covariance(mmix &distrib_obj, const vec &mu0, int nsamples, const mat &R, double tolerance) { 91 116 int tc = 0; 92 117 Array<mat> actual(CurrentContext::max_trial_count); 93 118 do { 94 mat smp = mMix.samplecond_m ( mu0, nsamples );119 mat smp = distrib_obj.samplecond_m ( mu0, nsamples ); 95 120 vec emu = smp * ones ( nsamples ) / nsamples ; 96 121 mat er = ( smp * smp.T() ) / nsamples - outer_product ( emu, emu );