wolffd@0: function bnet15 = mk_slice_and_half_dbn(bnet, int) wolffd@0: % function bnet = mk_slice_and_half_dbn(bnet, int) wolffd@0: % function bnet = mk_slice_and_half_dbn(bnet, int) wolffd@0: % wolffd@0: % Create a "1.5 slice" jtree, containing the interface nodes of slice 1 wolffd@0: % and all the nodes of slice 2 wolffd@0: % To keep the node numbering the same, we simply disconnect the non-interface nodes wolffd@0: % from slice 1, and set their size to 1. wolffd@0: % We do this to speed things up, and so that the likelihood is computed correctly. wolffd@0: % We do not need to do wolffd@0: % this if we just want to compute marginals (i.e., we can include nodes whose potentials will wolffd@0: % be left as all 1s). wolffd@0: wolffd@0: intra15 = bnet.intra; wolffd@0: ss = length(bnet.intra); wolffd@0: nonint = mysetdiff(1:ss, int); wolffd@0: for i=nonint(:)' wolffd@0: intra15(:,i) = 0; wolffd@0: intra15(i,:) = 0; wolffd@0: %assert(~any(bnet.inter(i,:))) wolffd@0: end wolffd@0: dag15 = [intra15 bnet.inter; wolffd@0: zeros(ss) bnet.intra]; wolffd@0: ns = bnet.node_sizes(:); wolffd@0: ns(nonint) = 1; % disconnected nodes get size 1 wolffd@0: obs_nodes = [bnet.observed(:) bnet.observed(:)+ss]; wolffd@0: bnet15 = mk_bnet(dag15, ns, 'discrete', bnet.dnodes, 'equiv_class', bnet.equiv_class(:), ... wolffd@0: 'observed', obs_nodes(:));