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