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