annotate toolboxes/FullBNT-1.0.7/bnt/inference/static/@jtree_inf_engine/marginal_nodes.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function marginal = marginal_nodes(engine, query, add_ev)
Daniel@0 2 % MARGINAL_NODES Compute the marginal on the specified query nodes (jtree)
Daniel@0 3 % marginal = marginal_nodes(engine, query, add_ev)
Daniel@0 4 %
Daniel@0 5 % 'query' must be a subset of some clique; an error will be raised if not.
Daniel@0 6 % add_ev is an optional argument; if 1, we will "inflate" the marginal of observed nodes
Daniel@0 7 % to their original size, adding 0s to the positions which contradict the evidence
Daniel@0 8
Daniel@0 9 if nargin < 3, add_ev = 0; end
Daniel@0 10
Daniel@0 11 c = clq_containing_nodes(engine, query);
Daniel@0 12 if c == -1
Daniel@0 13 error(['no clique contains ' num2str(query)]);
Daniel@0 14 end
Daniel@0 15 marginal = pot_to_marginal(marginalize_pot(engine.clpot{c}, query, engine.maximize));
Daniel@0 16
Daniel@0 17 if add_ev
Daniel@0 18 bnet = bnet_from_engine(engine);
Daniel@0 19 %marginal = add_ev_to_dmarginal(marginal, engine.evidence, bnet.node_sizes);
Daniel@0 20 marginal = add_evidence_to_gmarginal(marginal, engine.evidence, bnet.node_sizes, bnet.cnodes);
Daniel@0 21 end
Daniel@0 22