|
Revision 811, 1.1 kB
(checked in by smidl, 16 years ago)
|
|
extensions and stuff for MPF
|
| Line | |
|---|
| 1 | x = RV('x',2); |
|---|
| 2 | y = RV('y',2); |
|---|
| 3 | |
|---|
| 4 | g.class = 'mexFnc'; |
|---|
| 5 | g.dim = 2; |
|---|
| 6 | g.dimc = 2; |
|---|
| 7 | g.function = 'test_function'; |
|---|
| 8 | |
|---|
| 9 | h.class = 'linfn'; |
|---|
| 10 | h.A = eye(2); |
|---|
| 11 | h.B = [1;0]; |
|---|
| 12 | |
|---|
| 13 | fx.class = 'mgnorm<chmat>'; |
|---|
| 14 | fx.R = [0.3 -0.2; -0.2 0.5]; |
|---|
| 15 | fx.g = g; |
|---|
| 16 | fx.rv = x; |
|---|
| 17 | fx.rvc = RVtimes(x,-1); |
|---|
| 18 | |
|---|
| 19 | fy.class = 'mgnorm<chmat>'; |
|---|
| 20 | fy.R = 0.1*eye(2); |
|---|
| 21 | fy.g = h; |
|---|
| 22 | fy.rv = y; |
|---|
| 23 | fy.rvc = x; |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | %%%%%% Data generator |
|---|
| 27 | DS.class = 'PdfDS'; |
|---|
| 28 | DS.pdf.class = 'mprod'; |
|---|
| 29 | DS.pdf.pdfs = {fy,fx}; |
|---|
| 30 | DS.init_rv = RVtimes(x,-1); |
|---|
| 31 | DS.init_values = [.2,.3]'; |
|---|
| 32 | |
|---|
| 33 | %%%%% Estimator |
|---|
| 34 | A.class = 'ARX'; |
|---|
| 35 | A.rv = y; |
|---|
| 36 | A.rgr = RV({}); |
|---|
| 37 | A.rv_param = RV('R',4); |
|---|
| 38 | A.dimx=2; |
|---|
| 39 | A.constant = 0; |
|---|
| 40 | A.frg=0.99; |
|---|
| 41 | |
|---|
| 42 | A2=A; |
|---|
| 43 | A2.rv_param = RV('Q',4); |
|---|
| 44 | A2.rv=x; |
|---|
| 45 | |
|---|
| 46 | E.class = 'MPF_ARXg'; |
|---|
| 47 | E.g = g; |
|---|
| 48 | E.h = h; |
|---|
| 49 | E.rvc = x; |
|---|
| 50 | E.arxo = A; |
|---|
| 51 | E.arxp = A2; |
|---|
| 52 | E.prior.class = 'enorm<ldmat>'; |
|---|
| 53 | E.prior.mu = [0.2;0.3]; |
|---|
| 54 | E.prior.R = 0.1*eye(2); |
|---|
| 55 | E.n = 100; |
|---|
| 56 | E.res_threshold = 1.0; |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | exper.ndat = 2000; |
|---|
| 60 | M = estimator(DS,{E},exper); |
|---|
| 61 | %%%%%% ARX estimator conditioned on frg |
|---|
| 62 | |
|---|
| 63 | % plot |
|---|
| 64 | |
|---|
| 65 | figure(1); |
|---|
| 66 | hold off |
|---|
| 67 | plot(M.Est0_Q_Q); |
|---|
| 68 | hold on |
|---|
| 69 | plot(ones(size(M.Est0_Q_Q,1),1)* DS.pdf.pdfs{2}.R(:)','--'); |
|---|
| 70 | |
|---|
| 71 | figure(2) |
|---|
| 72 | hold off |
|---|
| 73 | plot(M.Est0_apost_mean_); |
|---|
| 74 | hold on |
|---|
| 75 | plot(M.DS_x,'--'); |
|---|
| 76 | |
|---|