9 | | M=mixef_init(Data,com); |
| 9 | [Mix0,P0]=mixef_init(Data,com); |
| 10 | |
| 11 | % show predictor |
| 12 | |
| 13 | Pred = bm_epredictor(Mix0); |
| 14 | epdf_2dplot(Pred); |
| 15 | |
| 16 | % Do Quasi Bayes |
| 17 | |
| 18 | tic |
| 19 | %use same or new data |
| 20 | MixQB = Mix0; |
| 21 | n = length(MixQB.Coms); |
| 22 | for 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 |
| 37 | end |
| 38 | toc |
| 39 | |
| 40 | tic |
| 41 | % should be the same as: |
| 42 | % MixQBc = bm_bayes_batch(MixQB,Data); |
| 43 | toc |
| 44 | |
| 45 | %% display results |
| 46 | |
| 47 | figure(2); |
| 48 | PredQB = bm_epredictor(MixQB); |
| 49 | epdf_2dplot(Pred); |
| 50 | |
| 51 | %% relations between components |
| 52 | Batta_dist=zeros(n); |
| 53 | for i=1:n |
| 54 | for j=i:n |
| 55 | Batta_dist(i,j) = enorm_bhattacharyya(PredQB.pdfs{i}, PredQB.pdfs{j}); |
| 56 | end |
| 57 | end |
| 58 | imagesc(Batta_dist); |