root/applications/bdmtoolbox/tutorial/userguide/frg_estim.m @ 964

Revision 964, 1.8 kB (checked in by smidl, 14 years ago)

Corrections in ARX and PF

  • Property svn:eol-style set to native
Line 
1clear all
2% load data created by the MpdfDS_example
3load pdfds_results
4
5DS.class   = 'MemDS';
6DS.Data    = Data;
7DS.drv     = drv;
8
9%%%%%% ARX estimator conditioned on frg
10
11A1.class = 'ARXfrg';
12A1.yrv = y;
13A1.rv = RV({'theta','r'},[3,1]);
14A1.rgr = RVtimes([y,u],[-3,-1]) ;
15A1.log_level = 'logbounds';
16A1.frg = 0.98;
17A1.name = 'A1';
18
19
20%%%%%% Random walk on frg - Dirichlet
21phi_pdf.class = 'mDirich';         % random walk on coefficient phi
22phi_pdf.rv    = RV({'phi','1_phi'});       % 2D random walk - frg is the first element
23phi_pdf.k     = 0.001;              % width of the random walk
24phi_pdf.betac = [0.1 0.1];         % stabilizing elememnt of random walk
25
26%%%%%% Particle
27p.class = 'MarginalizedParticle';
28p.parameter_pdf = phi_pdf;         % Random walk is the parameter evolution model
29p.bm    = A1;
30
31% prior on ARX
32%%%%%% Combining estimators in Marginalized particle filter
33E.class = 'PF';
34E.particle = p;                    % ARX is the analytical part
35E.res_threshold = 0.0;             % resampling parameter
36E.n = 10;                          % number of particles
37E.prior.class = 'eDirich';         % prior on non-linear part
38E.prior.beta  = [2 1]; %
39E.log_level = 'logbounds,logweights,logmeans,logvars';
40E.name = 'MPF';
41
42A2=A1;
43A2.class='ARX';
44A2.frg=1.0;
45A2.name = 'MPFx';
46
47[M,Str]=estimator(DS,{E,A2});
48
49%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50% plot results
51ndat = size(M.DS_dt_u,1);
52
53figure(1);
54subplot(2,2,1);
55plotestimates(true_theta, M.MPF_apost_mean_theta, M.MPF_apost_lbound_theta, M.MPF_apost_ubound_theta);
56title(' Regression parameters \theta')
57set(gca,'YLim',[-1.5,1]);
58
59subplot(2,2,2);
60plotestimates(true_R, M.MPF_apost_mean_r,M.MPF_apost_lbound_r,M.MPF_apost_ubound_r);
61title('Variance parameters r')
62
63subplot(2,2,3);
64plotestimates(1, M.MPF_apost_mean_phi(:,1),M.MPF_apost_lbound_phi(:,1),M.MPF_apost_ubound_phi(:,1));
65title('Forgetting factor')
66
67
Note: See TracBrowser for help on using the browser.