annotate toolboxes/FullBNT-1.0.7/bnt/general/determine_elim_constraints.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 partial_order = determine_elim_constraints(bnet, onodes)
wolffd@0 2 % DETERMINE_ELIM_CONSTRAINTS Determine what the constraints are (if any) on the elimination ordering.
wolffd@0 3 % partial_order = determine_elim_constraints(bnet, onodes)
wolffd@0 4 %
wolffd@0 5 % A graph with different kinds of nodes (e.g., discrete and cts, or decision and rnd) is called marked.
wolffd@0 6 % A strong root is guaranteed to exist if the marked graph is triangulated and does not have any paths of
wolffd@0 7 % the form discrete -> cts -> discrete. In general we need to add extra edges to
wolffd@0 8 % the moral graph to ensure this (see example in Lauritzen (1992) fig 3b).
wolffd@0 9 % However, a simpler sufficient condition is to eliminate all the cts nodes before the discrete ones,
wolffd@0 10 % because then, as we move from the leaves to the root, the cts nodes get marginalized away
wolffd@0 11 % and we are left with purely discrete cliques.
wolffd@0 12 %
wolffd@0 13 % partial_order(i,j)=1 if we must marginalize j *before* i
wolffd@0 14 % (so i will be nearer the strong root).
wolffd@0 15 % If the hidden nodes are either all discrete or all cts, we set partial_order = [].
wolffd@0 16 %
wolffd@0 17 % For details, see
wolffd@0 18 % - Jensen, Jensen and Dittmer, "From influence diagrams to junction trees", UAI 94.
wolffd@0 19 % - Lauritzen, "Propgation of probabilities, means, and variances in mixed graphical
wolffd@0 20 % association models", JASA 87(420):1098--1108, 1992.
wolffd@0 21 % - K. Olesen, "Causal probabilistic networks with both discrete and continuous variables",
wolffd@0 22 % IEEE Pami 15(3), 1993
wolffd@0 23
wolffd@0 24
wolffd@0 25 n = length(bnet.dag);
wolffd@0 26 pot_type = determine_pot_type(bnet, onodes);
wolffd@0 27 if (pot_type == 'd') | (pot_type == 'g')
wolffd@0 28 partial_order = [];
wolffd@0 29 return;
wolffd@0 30 end
wolffd@0 31
wolffd@0 32
wolffd@0 33 partial_order = sparse(n,n);
wolffd@0 34 partial_order(bnet.dnodes, bnet.cnodes) = 1;
wolffd@0 35
wolffd@0 36 % Integrate out cts nodes before their discrete parents - see Olesen (1993) p9
wolffd@0 37 % This method gives the wrong results on cg1.m!
wolffd@0 38 if 0
wolffd@0 39 for i=bnet.cnodes(:)'
wolffd@0 40 dps = myintersect(parents(bnet.dag, i), bnet.dnodes);
wolffd@0 41 partial_order(dps, i)=1;
wolffd@0 42 end
wolffd@0 43 end