root/applications/bdmtoolbox/sandbox/mpf_arx_3.m @ 971

Revision 971, 1.2 kB (checked in by smidl, 14 years ago)

New MPF

Line 
1clear all;
2x = RV('x',2);
3y = RV('y',2);
4
5g.class = 'mexFnc';
6g.dim = 2;
7g.dimc = 2;
8g.function = 'test_function';
9
10g.class = 'linfn';
11g.A     = eye(2);
12g.B     = [1;0];
13
14h.class = 'linfn';
15h.A     = eye(2);
16h.B     = [1;0];
17
18fx.class = 'mgnorm<chmat>';
19fx.R = [0.3 -0.2; -0.2 0.5];
20fx.g = g;
21fx.rv = x;
22fx.rvc = RVtimes(x,-1);
23
24fy.class = 'mgnorm<chmat>';
25fy.R = 0.1*eye(2);
26fy.g = h;
27fy.rv = y;
28fy.rvc = x;
29
30
31%%%%%% Data generator
32DS.class   = 'PdfDS';
33DS.pdf.class     = 'mprod';
34DS.pdf.pdfs      = {fy,fx};
35DS.init_rv = RVtimes(x,-1);
36DS.init_values = [.2,.3]';
37
38%%%%% Estimator
39A.class = 'ARX';
40A.yrv = RV('vw',4);
41A.rgr = RV({});
42A.dimx=4;
43A.constant = 0;
44A.frg=0.99;
45
46M.class = 'NoiseParticle';
47M.g = g;
48M.h = h;
49M.rvx = x;
50M.rvxc = RVtimes(x,-1);
51M.rvyc = x;
52M.bm = A;
53
54PF.class='PF';
55PF.particle = M;
56PF.n = 100;
57PF.res_threshold = 1.0;
58PF.prior.class = 'enorm<ldmat>';
59PF.prior.mu = [0.2;0.3];
60PF.prior.R = 0.1*eye(2);
61
62
63exper.ndat = 2000;
64O = estimator(DS,{PF},exper);
65%%%%%% ARX estimator conditioned on frg
66
67% plot
68
69figure(1);
70hold off
71plot(M.Est0_Q_Q);
72hold on
73plot(ones(size(M.Est0_Q_Q,1),1)* DS.pdf.pdfs{2}.R(:)','--');
74
75figure(2)
76hold off
77plot(M.Est0_apost_mean_);
78hold on
79plot(M.DS_x,'--');
80
Note: See TracBrowser for help on using the browser.