comparison toolboxes/FullBNT-1.0.7/bnt/inference/static/@stab_cond_gauss_inf_engine/marginal_difclq_nodes.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 marginal = marginal_difclq_nodes(engine, query_nodes)
2 % MARGINAL_DIFCLQ_NODES get the marginal distribution of nodes which is not in a single clique
3 % marginal = marginal_difclq_nodes(engine, query_nodes)
4
5 keyboard
6 num_clique = length(engine.cliques);
7 B = engine.cliques_bitv;
8 clqs_containnodes = [];
9 for i=1:length(query_nodes)
10 node = query_nodes(i);
11 tnodes = find(all(B(:, node), 2));
12 clqs_containnodes = myunion(clqs_containnodes, tnodes);
13 end
14 % get all cliques contains query nodes
15
16 % get the minimal sub tree in junction which contains these cliques and the node closest to the root of jtree
17 [subtree, nroot_node] = min_subtree_conti_nodes(engine.jtree, engine.root, clqs_containnodes);
18 if ~mysubset(query_nodes, engine.cliques{nroot_node});
19 % if query nodes is not all memers of the clique closest to the root clique performe push operation
20 engine = push_tree(engine, subtree, query_nodes, nroot_node);
21 end
22
23 if ~(nroot_node == engine.root)
24 % if the clique closest to the root clique is not the root clique we must direct combine the
25 % potential with the potential stored in separator toward to root
26 p = parents(engine.jtree, nroot_node);
27 tpot = direct_combine_pots(engine.clpot{nroot_node}, engine.seppot{p, nroot_node});
28 else
29 tpot = engine.clpot{nroot_node};
30 end
31
32 pot = marginalize_pot(tpot, query_nodes);
33 marginal = pot_to_marginal(pot);
34 marginal.T = normalise(marginal.T);
35
36
37
38 function engine = push_tree(engine, tree, query_nodes, inode)
39 % PUSH_TREE recursive perform push opeartion on tree
40 % engine = push_tree(engine, tree, query_nodes, inode)
41
42 cs = children(tree, inode);
43 for i = 1:length(cs)
44 node = cs(i);
45 push_tree(engine, tree, query_nodes, node);
46 push_dom = myintersect(engine.cliques{node}, query_nodes);
47 [engine, clqtoroot] = push(engine, node, push_dom);
48 end
49
50
51
52
53
54
55