root/applications/bdmtoolbox/tutorial/mpdm/dist_ctrl_example.m @ 765

Revision 765, 1.5 kB (checked in by smidl, 14 years ago)

New mex for mpdm: arena

Line 
1% name random variables
2y = RV({'y'},1);
3u1 = RV({'u1'},1);
4u2 = RV({'u2'},1);
5
6% create f(y_t| y_{t-3}, u_{t-1})
7fy.class = 'mlnorm<ldmat>';
8fy.rv    = y;
9fy.rvc   = RVtimes([y,u1,u2], [-3, 0, 0]);
10fy.A     = [0.5, -0.9, 0.9];
11fy.const = 0;
12fy.R     = 1e-2;
13
14DS.class = 'PdfDS';
15DS.pdf = fy;
16
17% create ARX estimator
18A1.class = 'ARX';
19A1.rv = y;
20A1.rgr = RVtimes([y,u1],[-3,0]) ; % correct structure is {y,y}
21A1.options ='logbounds,logll';
22A1.frg = 0.95;
23
24A2=A1;
25A2.rgr = RVtimes([y,u2],[-3,0]) ; % correct structure is {y,y}
26
27
28C1.class = 'LQG_ARX';
29C1.ARX = A1;
30C1.Qu = 0.1*eye(1);
31C1.Qy = 1*eye(1);
32C1.yreq = 1;
33C1.horizon = 100;
34
35C2=C1;
36C2.ARX = A2;
37
38P1.class = 'ARXAgent';
39P1.name = 'P1';
40P1.lqg_arx = C1;
41P1.lqg_arx.class = 'LQG_ARX';
42P1.merger.class = 'merger_mix';
43P1.merger.method = 'geometric';
44P1.neighbours = {'P2'};
45
46P2=P1;
47P2.name = 'P2';
48P2.lqg_arx = C2;
49P2.neighbours = {};
50
51exper.ndat = 100;
52exper.burnin = 10;
53exper.burn_pdf.class = 'enorm<ldmat>';
54exper.burn_pdf.mu = [0;0];
55exper.burn_pdf.R  = 0.01*eye(2);
56
57
58M= arena(DS,{P1,P2},exper);
59
60
61%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62%       PLOTS
63
64figure(1);
65hold off
66subplot(1,2,1);
67plot(M.DS_y);
68subplot(1,2,2);
69plot(M.DS_u1); hold on;
70plot(M.DS_u2);
71
72figure(2);
73hold off
74plot(M.Ctrl0_apost_mean_theta);
75hold on
76plot(M.Ctrl0_apost_ub_theta,':');
77plot(M.Ctrl0_apost_lb_theta,':');
78set(gca,'YLim',[-4,2]);
79
80figure(3);
81hold off
82plot(M.Ctrl1_apost_mean_theta);
83hold on
84plot(M.Ctrl1_apost_ub_theta,':');
85plot(M.Ctrl1_apost_lb_theta,':');
86set(gca,'YLim',[-2,3]);
Note: See TracBrowser for help on using the browser.