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