annotate toolboxes/FullBNT-1.0.7/bnt/general/add_ev_to_dmarginal.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 fmarginal = add_ev_to_dmarginal(fmarginal, evidence, ns)
wolffd@0 2 % ADD_EV_TO_DMARGINAL 'pump up' observed nodes back to their original size.
wolffd@0 3 % fmarginal = add_ev_to_dmarginal(fmarginal, evidence, ns)
wolffd@0 4 %
wolffd@0 5 % We introduce 0s into the array in positions which are incompatible with the evidence.
wolffd@0 6
wolffd@0 7 dom = fmarginal.domain;
wolffd@0 8 odom = dom(~isemptycell(evidence(dom)));
wolffd@0 9 vals = cat(1, evidence{odom});
wolffd@0 10 index = mk_multi_index(length(dom), find_equiv_posns(odom, dom), vals);
wolffd@0 11 T = 0*myones(ns(dom));
wolffd@0 12 ens = ns(:)';
wolffd@0 13 ens(odom) = 1;
wolffd@0 14 T(index{:}) = myreshape(fmarginal.T, ens(dom));
wolffd@0 15 fmarginal.T = T;