root/applications/bdmtoolbox/tutorial/userguide/particle_ARX.m @ 888

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

m files in bdmtoolbox

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