annotate toolboxes/FullBNT-1.0.7/bnt/general/shrink_obs_dims_in_table.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 T2 = shrink_obs_dims_in_table(T1, dom, evidence)
Daniel@0 2 % SHRINK_OBS_DIMS_IN_TABLE Set observed dimensions to size 1
Daniel@0 3 % T2 = shrink_obs_dims_in_table(T1, dom, evidence)
Daniel@0 4 %
Daniel@0 5 % If 'T1' contains observed nodes, it will have 0s in the positions that are
Daniel@0 6 % inconsistent with the evidence. We now remove these 0s and set the corresponding dimensions to
Daniel@0 7 % size 1, to be consistent with the way most inference engines handle evidence, which is to
Daniel@0 8 % shrink observed nodes before doing inference.
Daniel@0 9
Daniel@0 10 % This is used by pearl and enumerative inf. engines.
Daniel@0 11
Daniel@0 12 odom = dom(~isemptycell(evidence(dom)));
Daniel@0 13 vals = cat(1,evidence{odom});
Daniel@0 14 ndx = mk_multi_index(length(dom), find_equiv_posns(odom, dom), vals(:));
Daniel@0 15 T2 = T1(ndx{:});