- Timestamp:
- 11/13/08 20:00:53 (16 years ago)
- Location:
- mpdm
- Files:
-
- 2 modified
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
mpdm/merg_2a.cpp
r205 r211 13 13 // Setup model 14 14 RV y ( "{y }" ); 15 RV u1 ( "{u1 }" ); 16 RV u2 ( "{u2 }" ); 17 RV uu=u1; uu.add ( u2 ); 18 19 double a1t = 1.5; 20 double a2t = 0.8; 21 double sqr=0.10; 15 RV u ( "{u }" ); 16 RV um = u; um.t(-1); 17 RV z ( "{z }" ); 18 RV a ("{a }"); 19 RV b ("{b }"); 20 RV c ("{c }"); 21 RV r ("{r }"); 22 23 double at = 1.5; 24 double bt = 0.8; 25 double ct = 0.50; 26 double sig = 0.10; 22 27 // Full system 23 vec thg =vec_2 ( a1t,a2t ); //Simulated system - zero for constant term 24 vec Th = concat ( thg, sqr ); //Full parameter 25 26 // Estimated systems ARX(2) 27 RV a1 ( "{a1 }" ); 28 RV a2 ( "{a2 }" ); 29 RV r ( "{r }" ); 30 RV all =a1; all.add ( a2 ); all.add ( r ); 31 RV allj =a1; allj.add ( r ); allj.add ( a2 ); 32 vec Thj=vec_3 ( a1t,sqr,a2t ); 33 // Setup values 28 vec thy =vec_2 ( at,bt ); //Simulated system - zero for constant term 29 vec thu =vec_2 ( at,ct ); //Simulated system - zero for constant term 30 vec Thy = concat ( thy, vec_1(sig) ); //Full parameter 31 vec Thu = concat ( thu, vec_1(sig) ); //Full parameter 34 32 35 33 //ARX constructor 36 mat V0 = 0.001*eye ( 2 ); V0 ( 0,0 ) = 1; // 37 mat V0g = 0.001*eye ( 3 ); V0g ( 0,0 ) = 1; // 34 mat V0 = 0.001*eye ( 3 ); V0 ( 0,0 ) = 1; // 38 35 39 ARX P1 ( concat ( a1,r ), V0, -1 ); 40 ARX P2 ( concat ( a2,r ), V0, -1 ); 41 ARX PG ( all, V0g, -1 ); //or -1? 42 // ARX PGk ( all, V0g, -1 ); 36 ARX P1 ( concat ( a, concat(b,r) ), V0, -1 ); 37 ARX P2 ( concat ( a, concat(c,r) ), V0, -1 ); 43 38 44 39 //Test estimation … … 47 42 48 43 // Logging 49 dirfilelog L ( "exp/merg_ giw",ndat );44 dirfilelog L ( "exp/merg_2a",ndat ); 50 45 int Li_Data = L.add ( RV ( "{Y U1 U2 }" ), "" ); 51 46 int Li_LL = L.add ( RV ( "{G M }" ), "LL" ); 52 int Li_P1m = L.add ( RV ( "{a1 r }" ), "P1" ); 53 int Li_P2m = L.add ( RV ( "{a2 r }" ), "P2" ); 54 int Li_Gm = L.add ( RV ( "{a1 a2 r }" ), "G" ); 55 int Li_Mm = L.add ( RV ( "{a1 r a2 }" ), "M" ); 47 int Li_P1m = L.add ( RV ( "{a b r }" ), "P1" ); 48 int Li_P2m = L.add ( RV ( "{a c r }" ), "P2" ); 56 49 L.init(); 57 50 58 51 vec Yt ( ndat ); 59 52 vec yt ( 1 ); 60 61 vec LLs ( 2 );62 vec rgrg ( 2 );63 53 64 54 //Proposal … … 96 86 Array<mpdf*> A ( 2 ); A ( 0 ) =&eG1;A ( 1 ) =&eG2; 97 87 merger M ( A ); 98 M.set_parameters ( 1 .5, 100,3 ); //M._Mix().set_method(QB);88 M.set_parameters ( 10, 100,3 ); //M._Mix().set_method(QB); 99 89 //M2.set_parameters ( 100.0, 1000,3 ); //M2._Mix().set_method(QB); 100 90 M.merge ( &G0 ); -
mpdm/merg_giw.cpp
r205 r211 104 104 yt ( 0 ) = Yt ( t ); 105 105 106 // LLs ( 0 ) = P1._e()->eval pdflog ( get_vec(Th, "1 2") );107 // LLs ( 1 ) = P2._e()->eval pdflog ( get_vec(Th, "3 2") );108 LLs ( 0 ) = PG._e()->eval pdflog ( Th );106 // LLs ( 0 ) = P1._e()->evallog ( get_vec(Th, "1 2") ); 107 // LLs ( 1 ) = P2._e()->evallog ( get_vec(Th, "3 2") ); 108 LLs ( 0 ) = PG._e()->evallog ( Th ); 109 109 LLs ( 1 ) = M._Mix().logpred ( concat ( Thj, vec_1 ( 1.0 ) ) ); 110 110 // LLs ( 3 ) = M2._Mix().logpred ( concat(Thj, vec_1(1.0)) ); -
mpdm/merg_pred.cpp
r204 r211 94 94 95 95 yt(0) = Yt(t); 96 double P1pl = P1p->eval cond(yt,rgr1);97 double P2pl = P2p->eval cond(yt,rgr2);98 double PGpl = Pgp->eval cond(yt,rgrg);96 double P1pl = P1p->evallogcond(yt,rgr1); 97 double P2pl = P2p->evallogcond(yt,rgr2); 98 double PGpl = Pgp->evallogcond(yt,rgrg); 99 99 { 100 100 cout << "yt: " << yt << endl; … … 113 113 mlnorm<ldmat>* cP2p = (mlnorm<ldmat>*)mP2p->condition(y); 114 114 115 cP1pl = cP1p->eval cond(yt,rgr1);116 cP2pl = cP2p->eval cond(yt,rgr2);115 cP1pl = cP1p->evallogcond(yt,rgr1); 116 cP2pl = cP2p->evallogcond(yt,rgr2); 117 117 118 118 cout << "ytm1: " << cP1p->_epdf().mean() << endl;