comparison toolboxes/FullBNT-1.0.7/bnt/general/mk_slice_and_half_dbn.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
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(:));