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 / mk_slice_and_half_dbn.m @ 8:b5b38998ef3b
History | View | Annotate | Download (1.06 KB)
| 1 |
function bnet15 = mk_slice_and_half_dbn(bnet, int) |
|---|---|
| 2 |
% function bnet = mk_slice_and_half_dbn(bnet, int) |
| 3 |
% function bnet = mk_slice_and_half_dbn(bnet, int) |
| 4 |
% |
| 5 |
% Create a "1.5 slice" jtree, containing the interface nodes of slice 1 |
| 6 |
% and all the nodes of slice 2 |
| 7 |
% To keep the node numbering the same, we simply disconnect the non-interface nodes |
| 8 |
% from slice 1, and set their size to 1. |
| 9 |
% We do this to speed things up, and so that the likelihood is computed correctly. |
| 10 |
% We do not need to do |
| 11 |
% this if we just want to compute marginals (i.e., we can include nodes whose potentials will |
| 12 |
% be left as all 1s). |
| 13 |
|
| 14 |
intra15 = bnet.intra; |
| 15 |
ss = length(bnet.intra); |
| 16 |
nonint = mysetdiff(1:ss, int); |
| 17 |
for i=nonint(:)' |
| 18 |
intra15(:,i) = 0; |
| 19 |
intra15(i,:) = 0; |
| 20 |
%assert(~any(bnet.inter(i,:))) |
| 21 |
end |
| 22 |
dag15 = [intra15 bnet.inter; |
| 23 |
zeros(ss) bnet.intra]; |
| 24 |
ns = bnet.node_sizes(:); |
| 25 |
ns(nonint) = 1; % disconnected nodes get size 1 |
| 26 |
obs_nodes = [bnet.observed(:) bnet.observed(:)+ss]; |
| 27 |
bnet15 = mk_bnet(dag15, ns, 'discrete', bnet.dnodes, 'equiv_class', bnet.equiv_class(:), ... |
| 28 |
'observed', obs_nodes(:)); |