To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / _FullBNT / BNT / general / shrink_obs_dims_in_table.m @ 8:b5b38998ef3b
History | View | Annotate | Download (703 Bytes)
| 1 |
function T2 = shrink_obs_dims_in_table(T1, dom, evidence) |
|---|---|
| 2 |
% SHRINK_OBS_DIMS_IN_TABLE Set observed dimensions to size 1 |
| 3 |
% T2 = shrink_obs_dims_in_table(T1, dom, evidence) |
| 4 |
% |
| 5 |
% If 'T1' contains observed nodes, it will have 0s in the positions that are |
| 6 |
% inconsistent with the evidence. We now remove these 0s and set the corresponding dimensions to |
| 7 |
% size 1, to be consistent with the way most inference engines handle evidence, which is to |
| 8 |
% shrink observed nodes before doing inference. |
| 9 |
|
| 10 |
% This is used by pearl and enumerative inf. engines. |
| 11 |
|
| 12 |
odom = dom(~isemptycell(evidence(dom))); |
| 13 |
vals = cat(1,evidence{odom});
|
| 14 |
ndx = mk_multi_index(length(dom), find_equiv_posns(odom, dom), vals(:)); |
| 15 |
T2 = T1(ndx{:});
|