Mercurial > hg > camir-ismir2012
view toolboxes/FullBNT-1.0.7/bnt/inference/static/@pearl_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 |
line wrap: on
line source
function marginal = marginal_nodes(engine, query, add_ev) % MARGINAL_NODES Compute the marginal on the specified query nodes (loopy) % marginal = marginal_nodes(engine, query, add_ev) % % 'query' must be a single node. % add_ev is an optional argument; if 1, observed nodes will be set to their original size, % otherwise they will be treated like points. if nargin < 3, add_ev = 0; end if length(query) > 1 error('can only compute marginal on single nodes or families') end bnet = bnet_from_engine(engine); ns = bnet.node_sizes(:); switch engine.msg_type case 'd', T = engine.marginal{query}; if ~add_ev marginal.T = shrink_obs_dims_in_table(T, query, engine.evidence); else marginal.T = T; end marginal.domain = query; case 'g', if engine.disconnected_nodes_bitv(query) marginal.T = 1; marginal.domain = query; if add_ev marginal = add_ev_to_dmarginal(marginal, engine.evidence, ns) end return; end marginal = engine.marginal{query}; marginal.domain = query; if ~add_ev marginal = shrink_obs_dims_in_gaussian(marginal, query, engine.evidence, ns); end end