merg_pred.cpp estim/arx.h stat/libEF.h stat/loggers.h stat/merger.h int int main () main #include<estim/arx.h> #include<stat/libEF.h> #include<stat/loggers.h> #include<stat/merger.h> usingnamespaceitpp; //Theselinesareneededforuseofcoutandendl usingstd::cout; usingstd::endl; intmain(){ //Setupmodel RVy("{y}"); RVu1("{u1}"); RVu2("{u2}"); //Fullsystem vecthg("0.711");//Simulatedsystem //y=ay_t-1+u1+u2 doublesqr=0.1; intord=1; //EstimatedsystemsARX(2) RVthri("{thr_i}",vec_1(2+1)); RVthrg("{thr_g}",vec_1(3+1)); //Setupvalues //ARXconstructor matV0=0.001*eye(thri.count());V0(0,0)*=10;// matV0g=0.001*eye(thrg.count());V0g(0,0)*=10;// doublenu0=ord+1; doublefrg=0.99; ARXP1(thri,V0,nu0,frg); ARXP2(thri,V0,nu0,frg); ARXPG(thrg,V0g,nu0,frg); //Testestimation intndat=10000; intt; //Logging dirfilelogL("exp/merg",ndat); intEth1_log=L.add(thri,"P1"); intEth2_log=L.add(thri,"P2"); intEthg_log=L.add(thrg,"PG"); intData_log=L.add(RV("{YU1U2}"),""); intLL_log=L.add(RV("{12G}"),"LL"); L.init(); vecYt(ndat); Yt.set_subvector(0,randn(ord));//initialvalues vecrgrg(thg.length()); vecrgri(thri.count()); for(t=0;t<ndat;t++){ //Truesystem if(t>0){ rgrg(0)=Yt(t-1); rgrg(1)=pow(sin((t/40.0)*pi),3); rgrg(2)=pow(cos((t/40.0)*pi),3); Yt(t)=thg*rgrg+sqr*NorRNG(); //1st rgri(0)=Yt(t); rgri(1)=Yt(t-1); rgri(2)=rgrg(1); P1.bayes(rgri); //2nd rgri(2)=rgrg(2); P2.bayes(rgri); //Global PG.bayes(concat(Yt(t),rgrg)); //Merger } L.logit(Eth1_log,P1._epdf().mean()); L.logit(Eth2_log,P2._epdf().mean()); L.logit(Ethg_log,PG._epdf().mean()); L.logit(Data_log,vec_3(Yt(t),rgrg(1),rgrg(2))); L.logit(LL_log,vec_3(P1._ll(),P2._ll(),PG._ll())); L.step(); } L.finalize(); L.itsave("merg.it"); }