Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/inference/static/@jtree_inf_engine/Old/collect_evidence.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 = collect_evidence(engine, root) | |
2 | |
3 if isempty(engine.postorder{root}) | |
4 % this is the first time we have collected to this root | |
5 % memoize the order | |
6 [jtree, preorder, postorder] = mk_rooted_tree(engine.jtree, root); | |
7 postorder_parents = cell(1,length(postorder)); | |
8 for n=postorder(1:end-1) | |
9 postorder_parents{n} = parents(jtree, n); | |
10 end | |
11 engine.postorder{root} = postorder; | |
12 engine.postorder_parents{root} = postorder_parents; | |
13 else | |
14 postorder = engine.postorder{root}; | |
15 postorder_parents = engine.postorder_parents{root}; | |
16 end | |
17 | |
18 C = length(engine.clpot); | |
19 seppot = cell(C, C); | |
20 % separators are implicitely initialized to 1s | |
21 | |
22 % collect to root (node to parents) | |
23 for n=postorder(1:end-1) | |
24 for p=postorder_parents{n} | |
25 %clpot{p} = divide_by_pot(clpot{n}, seppot{p,n}); % dividing by 1 is redundant | |
26 engine.seppot{p,n} = marginalize_pot(engine.clpot{n}, engine.separator{p,n}, engine.maximize); | |
27 engine.clpot{p} = multiply_by_pot(engine.clpot{p}, engine.seppot{p,n}); | |
28 end | |
29 end |