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

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

use clear all + new mex

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