Revision 888, 1.2 kB
(checked in by smidl, 15 years ago)
|
m files in bdmtoolbox
|
Line | |
---|
1 | % name random variables |
---|
2 | x = RV({'x'},1); |
---|
3 | y = RV({'y'},1); |
---|
4 | u = RV({'u'},1); |
---|
5 | |
---|
6 | % create f(x_t| x_{t-1}, u_{t}) |
---|
7 | fx.class = 'mlnorm<ldmat>'; |
---|
8 | fx.rv = x; |
---|
9 | fx.rvc = RVtimes([x,u], [-1, 0]); |
---|
10 | fx.A = [0.5 -0.9]; |
---|
11 | fx.const = 0; |
---|
12 | fx.R = 0.01; |
---|
13 | |
---|
14 | % create f(y_t| y_{t-1}, u_{t-1}) |
---|
15 | fy.class = 'mlnorm<ldmat>'; |
---|
16 | fy.rv = y; |
---|
17 | fy.rvc = RVjoin([x,u]); |
---|
18 | fy.A = [1, 0.1]; |
---|
19 | fy.const = 0; |
---|
20 | fy.R = 1e-3; |
---|
21 | |
---|
22 | % create f(u_t| ) |
---|
23 | fu.class = 'egauss'; |
---|
24 | fu.rv = u; |
---|
25 | fu.mu = 0; |
---|
26 | fu.R = 1e-1; |
---|
27 | |
---|
28 | % create DS |
---|
29 | DS.class = 'PdfDS'; |
---|
30 | DS.pdf.class = 'mprod'; |
---|
31 | DS.pdf.pdfs = { fy, fx, fu}; |
---|
32 | DS.init_rv = RVtimes([x], [-1]); |
---|
33 | DS.init_values = [0.1]; |
---|
34 | |
---|
35 | % debug DS % MMM=simulator(DS); |
---|
36 | |
---|
37 | %%%%%% PF estimator |
---|
38 | |
---|
39 | PF.class = 'PF'; |
---|
40 | PF.particle.class = 'BootstrapParticle'; |
---|
41 | PF.particle.parameter_pdf = fx; |
---|
42 | PF.particle.observation_pdf = fy; |
---|
43 | PF.log_level ={'bounds','likelihood,'}; |
---|
44 | PF.prior.class = 'egauss'; |
---|
45 | PF.prior.mu = 0; |
---|
46 | PF.prior.R = 0.2; |
---|
47 | PF.res_threshold = 1; |
---|
48 | PF.n = 1000; |
---|
49 | |
---|
50 | exper.ndat =100; |
---|
51 | |
---|
52 | M=estimator(DS,{PF},exper); |
---|
53 | |
---|
54 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
55 | % plot results |
---|
56 | ndat = size(M.DS_u,1); |
---|
57 | |
---|
58 | plotestimates(M.DS_x, ... |
---|
59 | M.Est0_apost_mean_x, ... |
---|
60 | M.Est0_apost_lb_x, ... |
---|
61 | M.Est0_apost_ub_x); |
---|
62 | set(gca,'YLim',[-1.5,1]); |
---|
63 | |
---|
64 | title('Variance parameters r') |
---|