Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/inference/dynamic/@bk_inf_engine/dbn_update_bel.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function [engine, loglik] = dbn_update_bel(engine, evidence) | |
2 % DBN_UPDATE_BEL Update the belief state (bk) | |
3 % [engine, loglik] = dbn_update_bel(engine, evidence) | |
4 % | |
5 % evidence{i,1} contains the evidence on node i in slice t-1 | |
6 % evidence{i,2} contains the evidence on node i in slice t | |
7 | |
8 oldbel = engine.bel; | |
9 | |
10 ss = size(evidence, 1); | |
11 bnet = bnet_from_engine(engine); | |
12 CPDpot = cell(1, ss); | |
13 for n=1:ss | |
14 fam = family(bnet.dag, n, 2); | |
15 e = bnet.equiv_class(n, 2); | |
16 CPDpot{n} = convert_to_pot(bnet.CPD{e}, engine.pot_type, fam(:), evidence); | |
17 end | |
18 | |
19 observed = ~isemptycell(evidence); | |
20 onodes2 = find(observed(:)); | |
21 clqs = [engine.clq_ass_to_cluster(:,1); engine.clq_ass_to_node(:,2)]; | |
22 pots = [oldbel(:); CPDpot(:)]; | |
23 | |
24 [clpot, loglik] = enter_soft_evidence(engine.sub_engine, clqs, pots, onodes2(:), engine.pot_type); | |
25 | |
26 C = length(engine.clusters); | |
27 newbel = cell(1,C); | |
28 for c=1:C | |
29 k = engine.clq_ass_to_cluster(c,2); | |
30 cl = engine.clusters{c}; | |
31 newbel{c} = marginalize_pot(clpot{k}, cl+ss); % extract slice 2 posterior | |
32 newbel{c} = set_domain_pot(newbel{c}, cl); % shift back to slice 1 for re-use as prior | |
33 end | |
34 | |
35 engine.bel = newbel; | |
36 engine.bel_clpot = clpot; | |
37 engine.slice1 = 0; |