annotate toolboxes/FullBNT-1.0.7/bnt/inference/dynamic/@hmm_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 marginal = marginal_family(engine, i, t, add_ev)
wolffd@0 2 % MARGINAL_FAMILY Compute the marginal on the specified family (hmm)
wolffd@0 3 % marginal = marginal_family(engine, i, t, add_ev)
wolffd@0 4
wolffd@0 5 if nargin < 3, t = 1; end
wolffd@0 6 if nargin < 4, add_ev = 0; end
wolffd@0 7
wolffd@0 8 ns = engine.eff_node_sizes(:);
wolffd@0 9 ss = engine.slice_size;
wolffd@0 10
wolffd@0 11 if t==1 | ~engine.persist_bitv(i)
wolffd@0 12 bigT = engine.one_slice_marginal(:,t);
wolffd@0 13 ps = engine.parents{i};
wolffd@0 14 dom = [ps i] + (t-1)*ss;
wolffd@0 15 bigdom = 1:ss;
wolffd@0 16 bigsz = ns(bigdom);
wolffd@0 17 bigdom = bigdom + (t-1)*ss;
wolffd@0 18 else % some parents are in previous slice
wolffd@0 19 bigT = engine.two_slice_marginal(:,t-1); % t-1 and t
wolffd@0 20 ps = engine.parents{i+ss};
wolffd@0 21 dom = [ps i+ss] + (t-2)*ss;
wolffd@0 22 bigdom = 1:(2*ss); % domain of xi(:,:,t)
wolffd@0 23 bigsz = ns(bigdom);
wolffd@0 24 bigdom = bigdom + (t-2)*ss;
wolffd@0 25 end
wolffd@0 26 marginal.domain = dom;
wolffd@0 27
wolffd@0 28 marginal.T = marg_table(bigT, bigdom, bigsz, dom, engine.maximize);
wolffd@0 29 marginal.mu = [];
wolffd@0 30 marginal.Sigma = [];
wolffd@0 31
wolffd@0 32 if add_ev
wolffd@0 33 marginal = add_ev_to_dmarginal(marginal, engine.evidence, engine.node_sizes);
wolffd@0 34 end
wolffd@0 35