root/applications/bdmtoolbox/tutorial/userguide/mixef_basic.m @ 1005

Revision 1005, 1.0 kB (checked in by smidl, 14 years ago)

MixEf? example

Line 
1clear all
2
3com.class='ARX';
4com.yrv = RV({'d'},[2],[0]);
5com.rgr = RV({},[],[]);
6
7Data = randn(2,20);
8
9[Mix0,P0]=mixef_init(Data,com);
10
11% show predictor
12
13Pred = bm_epredictor(Mix0);
14epdf_2dplot(Pred);
15
16% Do Quasi Bayes
17
18tic
19%use same or new data
20MixQB = Mix0;
21n = length(MixQB.Coms);
22for t=1:size(Data,2)
23    log_w_nn = zeros(1,n);
24    % get predictions
25    for c=1:n
26        yt = Data(:,t);
27        [dummy, log_w_nn(c)]=bm_bayes(MixQB.Coms{c}, yt);
28    end
29    % normalize weights
30    w = exp(log_w_nn-max(log_w_nn));
31    w = w/sum(w);
32   
33    for c=1:n
34        yt = Data(:,t);
35        [MixQB.Coms{c}]=bm_bayes(MixQB.Coms{c}, yt);
36    end
37end
38toc
39
40tic
41% should be the same as:
42% MixQBc = bm_bayes_batch(MixQB,Data);
43toc
44
45%% display results
46
47figure(2);
48PredQB = bm_epredictor(MixQB);
49epdf_2dplot(Pred);
50
51%% relations between components
52Batta_dist=zeros(n);
53for i=1:n
54    for j=i:n
55        Batta_dist(i,j) = enorm_bhattacharyya(PredQB.pdfs{i}, PredQB.pdfs{j});
56    end
57end
58imagesc(Batta_dist);
Note: See TracBrowser for help on using the browser.