wolffd@0: function T2 = shrink_obs_dims_in_table(T1, dom, evidence) wolffd@0: % SHRINK_OBS_DIMS_IN_TABLE Set observed dimensions to size 1 wolffd@0: % T2 = shrink_obs_dims_in_table(T1, dom, evidence) wolffd@0: % wolffd@0: % If 'T1' contains observed nodes, it will have 0s in the positions that are wolffd@0: % inconsistent with the evidence. We now remove these 0s and set the corresponding dimensions to wolffd@0: % size 1, to be consistent with the way most inference engines handle evidence, which is to wolffd@0: % shrink observed nodes before doing inference. wolffd@0: wolffd@0: % This is used by pearl and enumerative inf. engines. wolffd@0: wolffd@0: odom = dom(~isemptycell(evidence(dom))); wolffd@0: vals = cat(1,evidence{odom}); wolffd@0: ndx = mk_multi_index(length(dom), find_equiv_posns(odom, dom), vals(:)); wolffd@0: T2 = T1(ndx{:});