Changeset 301 for mpdm/TR2244
- Timestamp:
- 03/19/09 15:39:00 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
mpdm/TR2244/merger_iter_cond.cpp
r299 r301 15 15 RV y ( "{y }","1" ); 16 16 RV u1 ( "{u1 }","1" ); 17 RV u2 ( "{u2 }","1" );17 // RV u2 ( "{u2 }","1" ); 18 18 19 19 RV all = y; 20 20 all.add ( u1 ); 21 all.add ( u2 );21 // all.add ( u2 ); 22 22 23 23 mlnorm<fsqmat> f1; f1.set_rv( y ); f1.set_rvc( u1 ); 24 mlnorm<fsqmat> f2; f2.set_rv( y );f2.set_rvc( u2 );24 enorm<fsqmat> f2; f2.set_rv( y );// f2.set_rvc( u2 ); 25 25 26 26 //Differneces in constant term are essential 27 27 f1.set_parameters ( "0.4","1",mat ( "0.04" ) ); 28 f2.set_parameters ( "0.2", "-1",mat ( "0.08" ) );28 f2.set_parameters ( "0.2", mat ( "0.08" ) ); 29 29 30 mepdf mf2(&f2); 31 30 32 Array<mpdf* > A ( 2 ); 31 33 A ( 0 ) =&f1; 32 A ( 1 ) =& f2;34 A ( 1 ) =&mf2; 33 35 34 36 merger M ( A ); 35 37 M.debug_file("iter_cond_debug.it"); 36 38 enorm<ldmat> g0; g0.set_rv ( all ); 37 mat Cov= 0.3*eye ( 3);38 Cov(1,2)=0.29;39 Cov(2,1)=0.29; 40 g0.set_parameters ( vec ( " 1 1 1" ),Cov);// +1*ones ( 3,3 ) );39 mat Cov=10*eye ( 2 ); 40 /* Cov(1,2)=0.29; 41 Cov(2,1)=0.29;*/ 42 g0.set_parameters ( vec ( "0 0" ),Cov);// +1*ones ( 3,3 ) ); 41 43 42 enorm<ldmat>* teste=g0.marginal(concat(u1,u2));43 mlnorm<ldmat>* testm=(mlnorm<ldmat>*)teste->condition(u2);44 // enorm<ldmat>* teste=g0.marginal(concat(u1,u2)); 45 // mlnorm<ldmat>* testm=(mlnorm<ldmat>*)teste->condition(u2); 44 46 45 M.set_parameters ( 1.2,1000,1 47 M.set_parameters ( 1.2,1000,1); 46 48 47 Array<vec> YUU( 3);49 Array<vec> YUU(2); 48 50 YUU(0)=linspace(-2.9,3.1,20); 49 51 YUU(1)=linspace(-5,5,20); 50 YUU(2)=linspace(-3,3,20);52 //YUU(2)=linspace(-3,3,20); 51 53 52 54 M.set_grid(YUU); … … 54 56 int Ntrials=1; 55 57 vec A1s ( Ntrials ); 56 vec A2s ( Ntrials );58 // vec A2s ( Ntrials ); 57 59 vec R1s ( Ntrials ); 58 60 vec R2s ( Ntrials ); … … 68 70 69 71 RV yu1 = y; yu1.add ( u1 ); 70 RV yu2 = y; yu2.add ( u2 );72 // RV yu2 = y; yu2.add ( u2 ); 71 73 enorm<ldmat>* P1m= ( enorm<ldmat>* ) MP->marginal ( yu1 ); 72 enorm<ldmat>* P2m= ( enorm<ldmat>* ) MP->marginal ( y u2);74 enorm<ldmat>* P2m= ( enorm<ldmat>* ) MP->marginal ( y ); 73 75 mlnorm<ldmat>* P1c= ( mlnorm<ldmat>* ) ( P1m->condition ( y ) ); 74 mlnorm<ldmat>* P2c= ( mlnorm<ldmat>* ) ( P2m->condition ( y ) );76 // mlnorm<ldmat>* P2c= ( mlnorm<ldmat>* ) ( P2m->condition ( y ) ); 75 77 76 78 A1s(it) = P1c->_A()(0,0); 77 A2s(it) = P2c->_A()(0,0);79 // A2s(it) = P2c->_A()(0,0); 78 80 R1s(it) = P1c->_R()(0,0); 79 R2s(it) = P2 c->_R()(0,0);81 R2s(it) = P2m->_R().to_mat()(0,0); 80 82 C1s(it) = P1c->_mu_const()(0); 81 C2s(it) = P2 c->_mu_const()(0);83 C2s(it) = P2m->_mu()(0); 82 84 83 85 cout << "mean: " << MM._Coms(0)->_e()->mean() <<endl; … … 89 91 cout << "C2s:" <<C2s<<endl; 90 92 double A1mean = sum(A1s)/Ntrials; 91 double A2mean = sum(A2s)/Ntrials;93 // double A2mean = sum(A2s)/Ntrials; 92 94 double C1mean = sum(C1s)/Ntrials; 93 95 double C2mean = sum(C2s)/Ntrials; … … 95 97 double R2mean = sum(R2s)/Ntrials; 96 98 cout << "A1: " << A1mean << " +- " << 2*sqrt(sum_sqr(A1s)/Ntrials-A1mean*A1mean) <<endl; 97 cout << "A2: " << A2mean << " +- " << 2*sqrt(sum_sqr(A2s)/Ntrials-A2mean*A2mean) <<endl;99 // cout << "A2: " << A2mean << " +- " << 2*sqrt(sum_sqr(A2s)/Ntrials-A2mean*A2mean) <<endl; 98 100 cout << "C1: " << C1mean << " +- " << 2*sqrt(sum_sqr(C1s)/Ntrials-C1mean*C1mean) <<endl; 99 101 cout << "C2: " << C2mean << " +- " << 2*sqrt(sum_sqr(C2s)/Ntrials-C2mean*C2mean) <<endl;