Mercurial > hg > camir-aes2014
annotate toolboxes/FullBNT-1.0.7/bnt/inference/static/@jtree_sparse_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 |
rev | line source |
---|---|
wolffd@0 | 1 function marginal = marginal_nodes(engine, query, add_ev) |
wolffd@0 | 2 % MARGINAL_NODES Compute the marginal on the specified query nodes (jtree) |
wolffd@0 | 3 % marginal = marginal_nodes(engine, query, add_ev) |
wolffd@0 | 4 % |
wolffd@0 | 5 % 'query' must be a subset of some clique; an error will be raised if not. |
wolffd@0 | 6 % add_ev is an optional argument; if 1, we will "inflate" the marginal of observed nodes |
wolffd@0 | 7 % to their original size, adding 0s to the positions which contradict the evidence |
wolffd@0 | 8 |
wolffd@0 | 9 if nargin < 3, add_ev = 0; end |
wolffd@0 | 10 |
wolffd@0 | 11 c = clq_containing_nodes(engine, query); |
wolffd@0 | 12 if c == -1 |
wolffd@0 | 13 error(['no clique contains ' num2str(query)]); |
wolffd@0 | 14 end |
wolffd@0 | 15 marginal = pot_to_marginal(marginalize_pot(engine.clpot{c}, query, engine.maximize)); |
wolffd@0 | 16 |
wolffd@0 | 17 if add_ev |
wolffd@0 | 18 bnet = bnet_from_engine(engine); |
wolffd@0 | 19 %marginal = add_ev_to_dmarginal(marginal, engine.evidence, bnet.node_sizes); |
wolffd@0 | 20 marginal = add_evidence_to_gmarginal(marginal, engine.evidence, bnet.node_sizes, bnet.cnodes); |
wolffd@0 | 21 end |
wolffd@0 | 22 |