Changeset 1005

Show
Ignore:
Timestamp:
05/27/10 13:08:50 (14 years ago)
Author:
smidl
Message:

MixEf? example

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/tutorial/userguide/mixef_basic.m

    r934 r1005  
    22 
    33com.class='ARX'; 
    4 com.rv = RV({'d'},[2],[0]); 
     4com.yrv = RV({'d'},[2],[0]); 
    55com.rgr = RV({},[],[]); 
    66 
    77Data = randn(2,20); 
    88 
    9 M=mixef_init(Data,com); 
     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);