annotate toolboxes/FullBNT-1.0.7/bnt/general/mk_slice_and_half_dbn.m @ 0:cc4b1211e677 tip

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