root/applications/bdmtoolbox/tutorial/userguide/partfrg_estim.m @ 1034

Revision 1034, 1.9 kB (checked in by smidl, 14 years ago)

examples: partial forgetting + prodbm

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 = 'ARXpartialforg';
12A1.yrv = y;
13A1.rv = RV({'theta','r'},[2,1]);
14A1.rgr = RVtimes([y,u],[-3,-1]) ;
15A1.log_level = 'logbounds';
16A1.constant = 0;
17A1.name = 'A1';
18
19% we have 2 parameters - i.e. 4 hypotheses
20
21%%%%%% Random walk on frg - Dirichlet
22walk.class = 'mBeta';         % random walk on coefficient phi
23walk.rv    = RV({'phi'},4);       % 2D random walk - frg is the first element
24walk.k     = 0.001*ones(1,4);              % width of the random walk
25walk.betac = 0.1*ones(1,4);         % stabilizing elememnt of random walk
26
27%%%%%% Particle
28p.class = 'MarginalizedParticle';
29p.parameter_pdf = walk;         % Random walk is the parameter evolution model
30p.bm    = A1;
31
32% prior on ARX
33%%%%%% Combining estimators in Marginalized particle filter
34E.class = 'PF';
35E.particle = p;                    % ARX is the analytical part
36E.res_threshold = 0.7;             % resampling parameter
37E.n = 100;                           % number of particles
38E.prior.class = 'eBeta';         % prior on non-linear part
39E.prior.alpha = 5*ones(1,4); %
40E.prior.beta  = ones(1,4); %
41E.log_level = 'logbounds,logweights,logmeans,logvars';
42E.name = 'MPF';
43
44[M,Str]=estimator(DS,{E});
45
46%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47% plot results
48ndat = size(M.DS_dt_u,1);
49
50figure(1);
51subplot(2,2,1);
52plotestimates(true_theta, M.MPF_apost_mean_theta, M.MPF_apost_lbound_theta, M.MPF_apost_ubound_theta);
53title(' Regression parameters \theta')
54set(gca,'YLim',[-1.5,1]);
55
56subplot(2,2,2);
57plotestimates(true_R, M.MPF_apost_mean_r,M.MPF_apost_lbound_r,M.MPF_apost_ubound_r);
58title('Variance parameters r')
59
60subplot(2,2,3);
61plotestimates(1, M.MPF_apost_mean_phi(:,1),M.MPF_apost_lbound_phi(:,1),M.MPF_apost_ubound_phi(:,1));
62title('Forgetting factor')
63
64
Note: See TracBrowser for help on using the browser.