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