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