Changeset 529 for library/tests
- Timestamp:
- 08/14/09 09:03:02 (15 years ago)
- Location:
- library/tests
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
library/tests/emix_test.cpp
r522 r529 1 #include "shared_ptr.h"2 1 #include "stat/exp_family.h" 3 2 #include "stat/emix.h" … … 20 19 vec mu0 ( "1.00054 1.0455" ); 21 20 22 shared_ptr<enorm<ldmat> > E1 = new enorm<ldmat>();21 enorm_ldmat_ptr E1; 23 22 E1->set_rv ( xy ); 24 23 E1->set_parameters ( mu0 , mat ( "0.740142 -0.259015; -0.259015 1.0302" ) ); 25 24 26 shared_ptr<enorm<ldmat> > E2 = new enorm<ldmat>();25 enorm_ldmat_ptr E2; 27 26 E2->set_rv ( xy ); 28 27 E2->set_parameters ( "-1.2 -0.1" , mat ( "1 0.4; 0.4 0.5" ) ); 29 28 30 Array<shared_ptr<epdf> >A1 ( 1 );29 epdf_array A1 ( 1 ); 31 30 A1 ( 0 ) = E1; 32 31 … … 36 35 37 36 // test if ARX and emix with one ARX are the same 38 shared_ptr<epdf>Mm = M1.marginal ( y );39 shared_ptr<epdf>Am = E1->marginal ( y );40 shared_ptr<mpdf>Mc = M1.condition ( y );41 shared_ptr<mpdf>Ac = E1->condition ( y );37 epdf_ptr Mm = M1.marginal ( y ); 38 epdf_ptr Am = E1->marginal ( y ); 39 mpdf_ptr Mc = M1.condition ( y ); 40 mpdf_ptr Ac = E1->condition ( y ); 42 41 43 42 mlnorm<ldmat> *wacnd = dynamic_cast<mlnorm<ldmat> *>( Ac.get() ); … … 56 55 57 56 // mixture with two components 58 Array<shared_ptr<epdf> >A2 ( 2 );57 epdf_array A2 ( 2 ); 59 58 A2 ( 0 ) = E1; 60 59 A2 ( 1 ) = E2; … … 80 79 check_covariance ( M2, N, observedR, 2.0); 81 80 82 shared_ptr<epdf>Mg = M2.marginal ( y );81 epdf_ptr Mg = M2.marginal ( y ); 83 82 CHECK ( Mg.get() ); 84 shared_ptr<mpdf>Cn = M2.condition ( x );83 mpdf_ptr Cn = M2.condition ( x ); 85 84 CHECK ( Cn.get() ); 86 85 … … 90 89 91 90 TEST ( test_emix_2 ) { 92 int N = 10000; // number of samples91 int N = 10000; // number of samples 93 92 vec mu0 ( "1.5 1.7" ); 94 93 mat V0 ( "1.2 0.3; 0.3 5" ); 95 94 ldmat R = ldmat ( V0 ); 96 95 97 shared_ptr<enorm<ldmat> > eN = new enorm<ldmat>();96 enorm_ldmat_ptr eN; 98 97 eN->set_parameters ( mu0, R ); 99 98 100 99 vec a = "100000,10000"; 101 100 vec b = a / 10.0; 102 shared_ptr<egamma> eG = new egamma();101 egamma_ptr eG; 103 102 eG->set_parameters ( a, b ); 104 103 105 104 emix eMix; 106 Array<shared_ptr<epdf> >Coms ( 2 );105 epdf_array Coms ( 2 ); 107 106 Coms ( 0 ) = eG; 108 107 Coms ( 1 ) = eN; -
library/tests/epdf_harness.cpp
r527 r529 64 64 } 65 65 66 if ( mrv .get()) {66 if ( mrv ) { 67 67 RV crv = hepdf->_rv().subt ( *mrv ); 68 shared_ptr<epdf>m = hepdf->marginal ( *mrv );69 shared_ptr<mpdf>c = hepdf->condition ( crv );70 71 Array<shared_ptr<mpdf> >aa ( 2 );68 epdf_ptr m = hepdf->marginal ( *mrv ); 69 mpdf_ptr c = hepdf->condition ( crv ); 70 71 mpdf_array aa ( 2 ); 72 72 aa ( 0 ) = c; 73 73 aa ( 1 ) = new mepdf ( m ); -
library/tests/merger_2d_test.cpp
r507 r529 21 21 xy.add ( y ); 22 22 23 shared_ptr<enorm<fsqmat> > f1 = new enorm<fsqmat>();23 enorm_fsqmat_ptr f1; 24 24 f1->set_rv ( xy ); 25 shared_ptr<enorm<fsqmat> > f2 = new enorm<fsqmat>();25 enorm_fsqmat_ptr f2; 26 26 f2->set_rv ( xy ); 27 27 … … 31 31 f2->set_parameters ( "1 1", mat ( "0.5 0; 0 0.1" ) ); 32 32 33 Array<shared_ptr<mpdf> >A ( 2 );34 shared_ptr<mepdf>A1 = new mepdf ( f1 );35 shared_ptr<mepdf>A2 = new mepdf ( f2 );33 mpdf_array A ( 2 ); 34 mepdf_ptr A1 = new mepdf ( f1 ); 35 mepdf_ptr A2 = new mepdf ( f2 ); 36 36 A ( 0 ) = A1; 37 37 A ( 1 ) = A2; -
library/tests/merger_iter_test.cpp
r507 r529 21 21 xy.add ( y ); 22 22 23 shared_ptr<enorm<fsqmat> > f1 = new enorm<fsqmat>();23 enorm_fsqmat_ptr f1; 24 24 f1->set_rv ( xy ); 25 shared_ptr<enorm<fsqmat> > f2 = new enorm<fsqmat>();25 enorm_fsqmat_ptr f2; 26 26 f2->set_rv ( xy ); 27 shared_ptr<enorm<fsqmat> > f3 = new enorm<fsqmat>();27 enorm_fsqmat_ptr f3; 28 28 f3->set_rv ( y ); 29 29 … … 32 32 f3->set_parameters ( "2", mat ( "0.4" ) ); 33 33 34 Array<shared_ptr<mpdf> >A ( 3 );34 mpdf_array A ( 3 ); 35 35 A ( 0 ) = new mepdf ( f1 ); 36 36 A ( 1 ) = new mepdf ( f2 ); -
library/tests/merger_test.cpp
r518 r529 13 13 RV z ( x ); 14 14 15 shared_ptr<enorm<fsqmat> > f1 = new enorm<fsqmat>();15 enorm_fsqmat_ptr f1; 16 16 f1->set_rv ( x ); 17 shared_ptr<enorm<fsqmat> > f2 = new enorm<fsqmat>();17 enorm_fsqmat_ptr f2; 18 18 f2->set_rv ( x ); 19 19 … … 21 21 f2->set_parameters ( "5", mat ( "10" ) ); 22 22 23 Array<shared_ptr<mpdf> >A ( 2 );23 mpdf_array A ( 2 ); 24 24 A ( 0 ) = new mepdf ( f1 ); 25 25 A ( 1 ) = new mepdf ( f2 ); -
library/tests/mixtures_test.cpp
r504 r529 53 53 fsqmat V2 ( mat ( "2 -0.1; -0.1 2" ) ); 54 54 55 shared_ptr<enorm<fsqmat> > C1 = new enorm<fsqmat>();55 enorm_fsqmat_ptr C1; 56 56 C1->set_rv ( x ); 57 57 C1->set_parameters ( m1, V1 ); 58 shared_ptr<enorm<fsqmat> > C2 = new enorm<fsqmat>();58 enorm_fsqmat_ptr C2; 59 59 C2->set_rv ( x ); 60 60 C2->set_parameters ( m2, V2 ); 61 61 62 Array<shared_ptr<epdf> >Sim ( 2 );62 epdf_array Sim ( 2 ); 63 63 Sim ( 0 ) = C1; 64 64 Sim ( 1 ) = C2; -
library/tests/mpdf_test.cpp
r524 r529 38 38 ldmat R = ldmat ( V0 ); 39 39 40 shared_ptr<enorm<ldmat> > eN = new enorm<ldmat>();40 enorm_ldmat_ptr eN; 41 41 eN->set_parameters ( mu0, R ); 42 42 43 shared_ptr<mgamma> mG = new mgamma();43 mgamma_ptr mG; 44 44 double k = 10.0; 45 45 mG->set_parameters ( k, mu0 ); 46 46 47 47 mmix mMix; 48 Array<shared_ptr<mpdf> >mComs ( 2 );48 mpdf_array mComs ( 2 ); 49 49 50 50 // mmix::set_parameters requires the first mpdf to be named … … 54 54 55 55 eN->set_mu ( vec_2 ( 0.0, 0.0 ) ); 56 shared_ptr<mepdf>mEnorm = new mepdf ( eN );56 mepdf_ptr mEnorm = new mepdf ( eN ); 57 57 mComs ( 1 ) = mEnorm; 58 58 59 59 mMix.set_parameters ( vec_2 ( 0.5, 0.5 ), mComs ); 60 60 61 double tolerance = 0.1;62 63 61 vec tmu = 0.5 * eN->mean() + 0.5 * mu0; 64 check_mean ( mMix, mu0, N, tmu, tolerance);62 check_mean ( mMix, mu0, N, tmu, 0.1 ); 65 63 66 64 mat observedR ( "1.27572 0.778247; 0.778247 3.33129" ); 67 check_covariance( mMix, mu0, N, observedR, tolerance);65 check_covariance( mMix, mu0, N, observedR, 0.2 ); 68 66 } 69 67 … … 75 73 ldmat R = ldmat ( V0 ); 76 74 77 shared_ptr<enorm<ldmat> > eN = new enorm<ldmat>();75 enorm_ldmat_ptr eN; 78 76 eN->set_parameters ( mu0, R ); 79 77 80 78 vec a = "100000,10000"; 81 79 vec b = a / 10.0; 82 shared_ptr<egamma> eG = new egamma();80 egamma_ptr eG; 83 81 eG->set_parameters ( a, b ); 84 82 85 shared_ptr<emix> eMix = new emix();86 Array<shared_ptr<epdf> >Coms ( 2 );83 emix_ptr eMix; 84 epdf_array Coms ( 2 ); 87 85 Coms ( 0 ) = eG; 88 86 Coms ( 1 ) = eN; -
library/tests/mprod.cfg
r519 r529 38 38 R = ( "matrix", 2, 2, [ 2.0, 0.5, 0.5, 0.5 ] ); 39 39 variance = [ 1.2, 5.0 ]; 40 tolerance = 0. 2;40 tolerance = 0.3; 41 41 }, 42 42 {