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