1 | x = RV('x',2); |
---|
2 | fx.class = 'mlnorm<ldmat>'; |
---|
3 | fx.A = [1 -0.9; 1 -0.3]; |
---|
4 | fx.const = [0;0]; |
---|
5 | fx.R = [0.1 0.05; 0.05 0.1]; |
---|
6 | fx.rv = x; |
---|
7 | fx.rvc = RVtimes(x,-1); |
---|
8 | |
---|
9 | y = RV('y',2); |
---|
10 | fy.class = 'mlnorm<ldmat>'; |
---|
11 | fy.A = [1 0.5; -0.3 0]; |
---|
12 | fy.const = [0;0]; |
---|
13 | fy.R = 0.1*eye(2); |
---|
14 | fy.rv = y; |
---|
15 | fy.rvc = x; |
---|
16 | |
---|
17 | |
---|
18 | %%%%%% Data generator |
---|
19 | DS.class = 'PdfDS'; |
---|
20 | DS.pdf.class = 'mprod'; |
---|
21 | DS.pdf.pdfs = {fy,fx}; |
---|
22 | |
---|
23 | Dt = simulator(DS); |
---|
24 | %%%%%% ARX estimator conditioned on frg |
---|
25 | |
---|
26 | A1.class = 'ARX'; |
---|
27 | A1.rv = y; |
---|
28 | A1.rgr = x ; |
---|
29 | A1.constant = 0; |
---|
30 | A1.log_level ='logbounds,logevidence'; |
---|
31 | A1.frg = 0.98; |
---|
32 | A1.name = 'A1'; |
---|
33 | |
---|
34 | %%%%%% Combining estimators in Marginalized particle filter |
---|
35 | E.class = 'MPF'; |
---|
36 | E.BM = A1; % ARX is the analytical part |
---|
37 | E.parameter_pdf = fx; % Random walk is the parameter evolution model |
---|
38 | E.res_threshold = 1.0; % resampling parameter |
---|
39 | E.n = 1000; % number of particles |
---|
40 | E.prior.class = 'enorm<ldmat>'; % prior on non-linear part |
---|
41 | E.prior.mu = [0 0]; % |
---|
42 | E.prior.R = 10*eye(2); % |
---|
43 | E.log_level ='logbounds,logevidence'; |
---|
44 | E.name = 'MPF'; |
---|
45 | |
---|
46 | exp.ndat = 1000; |
---|
47 | |
---|
48 | M=estimator(DS,{E},exp); |
---|
49 | |
---|
50 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
51 | % plot results |
---|
52 | ndat = size(M.DS_x,1); |
---|
53 | |
---|
54 | |
---|
55 | figure(1); |
---|
56 | subplot(4,1,1); |
---|
57 | plotestimates(fy.A(1,1)*ones(ndat,1), M.MPF_apost_mean_theta(:,1), M.MPF_apost_lb_theta(:,1), M.MPF_apost_ub_theta(:,1)); |
---|
58 | title(' Parameters C(1,1)') |
---|
59 | subplot(4,1,2); |
---|
60 | plotestimates(fy.A(1,2)*ones(ndat,1), M.MPF_apost_mean_theta(:,2), M.MPF_apost_lb_theta(:,2), M.MPF_apost_ub_theta(:,2)); |
---|
61 | title(' Parameters C(1,2)') |
---|
62 | subplot(4,1,3); |
---|
63 | plotestimates(fy.A(2,1)*ones(ndat,1), M.MPF_apost_mean_theta(:,3), M.MPF_apost_lb_theta(:,3), M.MPF_apost_ub_theta(:,3)); |
---|
64 | title(' Parameters C(2,1)') |
---|
65 | subplot(4,1,4); |
---|
66 | plotestimates(fy.A(2,2)*ones(ndat,1), M.MPF_apost_mean_theta(:,4), M.MPF_apost_lb_theta(:,4), M.MPF_apost_ub_theta(:,4)); |
---|
67 | title(' Parameters C(2,2)') |
---|
68 | |
---|
69 | |
---|