annotate toolboxes/FullBNT-1.0.7/bnt/inference/@inf_engine/marginal_family.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 m = marginal_family(engine, i, t)
wolffd@0 2 % MARGINAL_FAMILY Compute the marginal on i's family (inf_engine)
wolffd@0 3 % m = marginal_family(engine, i, t)
wolffd@0 4 %
wolffd@0 5 % t defaults to 1.
wolffd@0 6
wolffd@0 7 if nargin < 3, t = 1; end
wolffd@0 8
wolffd@0 9 bnet = bnet_from_engine(engine);
wolffd@0 10 if t==1
wolffd@0 11 m = marginal_nodes(engine, family(bnet.dag, i));
wolffd@0 12 else
wolffd@0 13 ss = length(bnet.intra);
wolffd@0 14 fam = family(bnet.dag, i+ss);
wolffd@0 15 if any(fam<=ss)
wolffd@0 16 % i has a parent in the preceeding slice
wolffd@0 17 % Hence the lowest numbered slice containing the family is t-1
wolffd@0 18 m = marginal_nodes(engine, fam, t-1);
wolffd@0 19 else
wolffd@0 20 % The family all fits inside slice t
wolffd@0 21 % Hence shift the indexes back to slice 1
wolffd@0 22 m = marginal_nodes(engine, fam-ss, t);
wolffd@0 23 end
wolffd@0 24 end