Mercurial > hg > camir-aes2014
annotate toolboxes/FullBNT-1.0.7/bnt/inference/static/@jtree_inf_engine/find_max_config.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 [mpe, clpot, seppot] = find_max_config(engine, clpot, seppot, evidence) |
wolffd@0 | 2 % FIND_MAX_CONFIG Backwards pass of Viterbi fro jtree |
wolffd@0 | 3 % function [mpe, clpot, seppot] = find_max_config(engine, clpot, seppot, evidence) |
wolffd@0 | 4 % See Cowell99 p98 |
wolffd@0 | 5 |
wolffd@0 | 6 bnet = bnet_from_engine(engine); |
wolffd@0 | 7 nnodes = length(bnet.dag); |
wolffd@0 | 8 mpe = cell(1, nnodes); |
wolffd@0 | 9 maximize = 1; |
wolffd@0 | 10 |
wolffd@0 | 11 c = engine.root_clq; |
wolffd@0 | 12 pot = struct(clpot{c}); % violate object privacy |
wolffd@0 | 13 dom = pot.domain; |
wolffd@0 | 14 [indices, clpot{c}] = find_most_prob_entry(clpot{c}); |
wolffd@0 | 15 mpe(dom) = num2cell(indices); |
wolffd@0 | 16 |
wolffd@0 | 17 for n=engine.preorder |
wolffd@0 | 18 for c=engine.preorder_children{n} |
wolffd@0 | 19 clpot{c} = divide_by_pot(clpot{c}, seppot{n,c}); |
wolffd@0 | 20 seppot{n,c} = marginalize_pot(clpot{n}, engine.separator{n,c}, maximize); |
wolffd@0 | 21 clpot{c} = multiply_by_pot(clpot{c}, seppot{n,c}); |
wolffd@0 | 22 |
wolffd@0 | 23 pot = struct(clpot{c}); % violate object privacy |
wolffd@0 | 24 dom = pot.domain; |
wolffd@0 | 25 [indices, clpot{c}] = find_most_prob_entry(clpot{c}); |
wolffd@0 | 26 mpe(dom) = num2cell(indices); |
wolffd@0 | 27 end |
wolffd@0 | 28 end |
wolffd@0 | 29 |
wolffd@0 | 30 obs_nodes = find(~isemptycell(evidence)); |
wolffd@0 | 31 % indices for observed nodes will be 1 - need to overwrite these |
wolffd@0 | 32 mpe(obs_nodes) = evidence(obs_nodes); |
wolffd@0 | 33 |
wolffd@0 | 34 |
wolffd@0 | 35 |