comparison toolboxes/FullBNT-1.0.7/bnt/inference/static/@cond_gauss_inf_engine/marginal_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_nodes(engine, query, add_ev)
2 % MARGINAL_NODES Compute the marginal on the specified query nodes (cond_gauss)
3 % marginal = marginal_nodes(engine, query, add_ev)
4 %
5 % 'query' must be a singleton set
6 % add_ev is an optional argument; if 1, we will "inflate" the marginal of observed nodes
7 % to their original size, adding 0s to the positions which contradict the evidence
8
9 if nargin < 3, add_ev = 0; end
10
11 if length(query) ~= 1
12 error('cond_gauss_inf_engine can only handle marginal queries on single nodes')
13 end
14 j = query;
15 bnet = bnet_from_engine(engine);
16
17 if myismember(j, bnet.cnodes)
18 if ~myismember(j, engine.onodes)
19 [m, C] = collapse_mog(engine.mu{j}, engine.Sigma{j}, engine.T);
20 marginal.mu = m;
21 marginal.Sigma = C;
22 marginal.T = 1.0; % single mixture component
23 else
24 marginal.mu = engine.evidence{j};
25 k = bnet.node_sizes(j);
26 marginal.Sigma = zeros(k,k);
27 marginal.T = 1.0; % since P(E|E)=1
28 end
29 else
30 marginal = pot_to_marginal(marginalize_pot(engine.joint_dmarginal, j));
31 if add_ev
32 marginal = add_ev_to_dmarginal(marginal, engine.evidence, bnet.node_sizes);
33 end
34 end
35
36 marginal.domain = query;