[934] | 1 | clear all |
---|
[744] | 2 | % name random variables |
---|
| 3 | y = RV({'y'},1); |
---|
| 4 | u1 = RV({'u1'},1); |
---|
| 5 | u2 = RV({'u2'},1); |
---|
| 6 | |
---|
| 7 | % create f(y_t| y_{t-3}, u_{t-1}) |
---|
| 8 | fy.class = 'mlnorm<ldmat>'; |
---|
| 9 | fy.rv = y; |
---|
| 10 | fy.rvc = RVtimes([y,u1,u2], [-3, 0, 0]); |
---|
| 11 | fy.A = [0.5, -0.9, 0.9]; |
---|
| 12 | fy.const = 0; |
---|
| 13 | fy.R = 1e-2; |
---|
| 14 | |
---|
| 15 | DS.class = 'PdfDS'; |
---|
| 16 | DS.pdf = fy; |
---|
| 17 | |
---|
| 18 | % create ARX estimator |
---|
| 19 | A1.class = 'ARX'; |
---|
[968] | 20 | A1.rv = RV({'theta','r'},[3,1]); |
---|
| 21 | A1.yrv = y; |
---|
[744] | 22 | A1.rgr = RVtimes([y,u1],[-3,0]) ; % correct structure is {y,y} |
---|
[968] | 23 | A1.log_level ='logbounds,logevidence,logmean'; |
---|
[744] | 24 | A1.frg = 0.95; |
---|
| 25 | |
---|
| 26 | A2=A1; |
---|
| 27 | A2.rgr = RVtimes([y,u2],[-3,0]) ; % correct structure is {y,y} |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | C1.class = 'LQG_ARX'; |
---|
| 31 | C1.ARX = A1; |
---|
| 32 | C1.Qu = 0.1*eye(1); |
---|
| 33 | C1.Qy = 1*eye(1); |
---|
| 34 | C1.yreq = 1; |
---|
| 35 | C1.horizon = 100; |
---|
| 36 | |
---|
| 37 | C2=C1; |
---|
| 38 | C2.ARX = A2; |
---|
| 39 | |
---|
[764] | 40 | exper.Ndat=100; |
---|
| 41 | exper.burnin=3; |
---|
| 42 | exper.burn_pdf.class='enorm<chmat>'; |
---|
| 43 | exper.burn_pdf.mu=[0,0]; |
---|
| 44 | exper.burn_pdf.R=0.1*eye(2); |
---|
[744] | 45 | |
---|
| 46 | |
---|
[764] | 47 | M= controlloop(DS,{C1,C2},exper); |
---|
| 48 | |
---|
| 49 | |
---|
[744] | 50 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 51 | % PLOTS |
---|
| 52 | |
---|
| 53 | figure(1); |
---|
| 54 | hold off |
---|
| 55 | subplot(1,2,1); |
---|
[968] | 56 | plot(M.DS_dt_y); |
---|
[744] | 57 | subplot(1,2,2); |
---|
[968] | 58 | plot(M.DS_dt_u1); hold on; |
---|
| 59 | plot(M.DS_dt_u2); |
---|
[744] | 60 | |
---|
| 61 | figure(2); |
---|
| 62 | hold off |
---|
| 63 | plot(M.Ctrl0_apost_mean_theta); |
---|
| 64 | hold on |
---|
| 65 | plot(M.Ctrl0_apost_ub_theta,':'); |
---|
| 66 | plot(M.Ctrl0_apost_lb_theta,':'); |
---|
| 67 | set(gca,'YLim',[-4,2]); |
---|
| 68 | |
---|
| 69 | figure(3); |
---|
| 70 | hold off |
---|
| 71 | plot(M.Ctrl1_apost_mean_theta); |
---|
| 72 | hold on |
---|
| 73 | plot(M.Ctrl1_apost_ub_theta,':'); |
---|
| 74 | plot(M.Ctrl1_apost_lb_theta,':'); |
---|
| 75 | set(gca,'YLim',[-2,3]); |
---|