wolffd@0: function marginal = marginal_family(engine, i, t, add_ev) wolffd@0: % MARGINAL_FAMILY Compute the marginal on the specified family (hmm) wolffd@0: % marginal = marginal_family(engine, i, t, add_ev) wolffd@0: wolffd@0: if nargin < 3, t = 1; end wolffd@0: if nargin < 4, add_ev = 0; end wolffd@0: wolffd@0: ns = engine.eff_node_sizes(:); wolffd@0: ss = engine.slice_size; wolffd@0: wolffd@0: if t==1 | ~engine.persist_bitv(i) wolffd@0: bigT = engine.one_slice_marginal(:,t); wolffd@0: ps = engine.parents{i}; wolffd@0: dom = [ps i] + (t-1)*ss; wolffd@0: bigdom = 1:ss; wolffd@0: bigsz = ns(bigdom); wolffd@0: bigdom = bigdom + (t-1)*ss; wolffd@0: else % some parents are in previous slice wolffd@0: bigT = engine.two_slice_marginal(:,t-1); % t-1 and t wolffd@0: ps = engine.parents{i+ss}; wolffd@0: dom = [ps i+ss] + (t-2)*ss; wolffd@0: bigdom = 1:(2*ss); % domain of xi(:,:,t) wolffd@0: bigsz = ns(bigdom); wolffd@0: bigdom = bigdom + (t-2)*ss; wolffd@0: end wolffd@0: marginal.domain = dom; wolffd@0: wolffd@0: marginal.T = marg_table(bigT, bigdom, bigsz, dom, engine.maximize); wolffd@0: marginal.mu = []; wolffd@0: marginal.Sigma = []; wolffd@0: wolffd@0: if add_ev wolffd@0: marginal = add_ev_to_dmarginal(marginal, engine.evidence, engine.node_sizes); wolffd@0: end wolffd@0: