Solutions to Darwiche’s Modeling and Reasoning with Bayesian Networks
Solutions to every exercise in Adnan Darwiche’s Modeling and Reasoning with Bayesian Networks (Cambridge, 2009) — 342 exercises across chapters 2–18, from propositional logic and probability calculus through exact and approximate inference to parameter and structure learning. The book is the COMP9418 reference text and is filed at Modeling and Reasoning with Bayesian Networks.
Propositional Logic
Exercises 2.1–2.7
Show that the following sentences are consistent by identifying a world that satisfies each sentence:
- (a)
- \((A \Rightarrow B) \wedge (A \Rightarrow \neg B)\).
- (b)
- \((A \vee B) \Rightarrow (\neg A \wedge \neg B)\).
Both sentences are satisfied by the world \(\omega\) with \(\omega(A) = \mathsf{false}\) and \(\omega(B) = \mathsf{false}\).
(a) Since \(\omega \models \neg A\), both \(\neg A \vee B\) and \(\neg A \vee \neg B\) hold at \(\omega\), hence so does their conjunction; here \(\alpha \Rightarrow \beta\) abbreviates \(\neg\alpha \vee \beta\) (Table 2.2). Distributing and using that \(B \wedge \neg B\) is inconsistent (Table 2.2),
\begin{equation*} \begin{aligned} (A \Rightarrow B) \wedge (A \Rightarrow \neg B) &\;=\; \neg A \vee (B \wedge \neg B) \;=\; \neg A , \end{aligned} \end{equation*}
the form Exercise 2.3(b) reuses; its models are the two worlds with \(A\) false.
(b) At \(\omega\) the antecedent \(A \vee B\) is false, so the implication holds. Writing \(\gamma = A \vee B\), de Morgan turns the sentence into \(\gamma \Rightarrow \neg\gamma = \neg\gamma \vee \neg\gamma = \neg A \wedge \neg B\), whose unique model is \(\omega\).
The truth table confirms both columns; a sentence is satisfied at the worlds carrying “true” in its column.
| \(A\) | \(B\) | (a) \((A \Rightarrow B) \wedge (A \Rightarrow \neg B)\) | (b) \((A \vee B) \Rightarrow (\neg A \wedge \neg B)\) |
|---|---|---|---|
| true | true | false | false |
| true | false | false | false |
| false | true | true | false |
| false | false | true | true |
Which of the following sentences are valid? If a sentence is not valid, identify a world that does not satisfy the sentence.
- (a)
- \((A \wedge (A \Rightarrow B)) \Rightarrow B\).
- (b)
- \((A \wedge B) \vee (A \wedge \neg B)\).
- (c)
- \((A \Rightarrow B) \Rightarrow (\neg B \Rightarrow \neg A)\).
(a) Valid; (b) not valid, falsified at \(\omega(A) = \mathsf{false}\), \(\omega(B) = \mathsf{false}\); (c) valid. Throughout \(\alpha \Rightarrow \beta\) is \(\neg\alpha \vee \beta\), and validity means \(\mathrm{Mods}(\alpha) = \Omega\) (Section 2.3.2).
(a) is modus ponens: if some \(\omega\) falsified it then \(\omega \models A\) and \(\omega \models \neg A \vee B\) while \(\omega \not\models B\), so both disjuncts of \(\neg A \vee B\) fail at \(\omega\) — impossible.
(b) By distribution and the validity of \(B \vee \neg B\) (Table 2.2),
\begin{equation*} (A \wedge B) \vee (A \wedge \neg B) \;=\; A \wedge (B \vee \neg B) \;=\; A , \end{equation*}
so the sentence fails at exactly the worlds setting \(A\) to false, the exhibited world among them.
(c) Table 2.2 lists the contrapositive \(\neg\beta \Rightarrow \neg\alpha\) as equivalent to \(\alpha \Rightarrow \beta\), so antecedent and consequent have the same truth value at every world and the implication is never false.
The truth table records all three verdicts:
| \(A\) | \(B\) | (a) | (b) | (c) |
|---|---|---|---|---|
| true | true | true | true | true |
| true | false | true | true | true |
| false | true | true | false | true |
| false | false | true | false | true |
Which of the following pairs of sentences are equivalent? If a pair of sentences is not equivalent, identify a world at which they disagree (one of them holds but the other does not).
- (a)
- \(A \Rightarrow B\) and \(B \Rightarrow A\).
- (b)
- \((A \Rightarrow B) \wedge (A \Rightarrow \neg B)\) and \(\neg A\).
- (c)
- \(\neg A \Rightarrow \neg B\) and \((A \vee \neg B \vee C) \wedge (A \vee \neg B \vee \neg C)\).
(a) Not equivalent — they disagree at \(\omega(A) = \mathsf{false}\), \(\omega(B) = \mathsf{true}\); (b) and (c) are equivalent. Equivalence means equality of model sets (Section 2.3.3).
(a) At that world \(A \Rightarrow B = \neg A \vee B\) holds via \(\neg A\), while \(B \Rightarrow A = \neg B \vee A\) has both disjuncts false.
(b) By Exercise 2.1(a), \((A \Rightarrow B) \wedge (A \Rightarrow \neg B) = \neg A\), and equivalence-preserving rewriting leaves the model set unchanged.
(c) Both sides reduce to \(A \vee \neg B\). On the left, \(\neg A \Rightarrow \neg B = \neg\neg A \vee \neg B = A \vee \neg B\); on the right, distribution (Table 2.2) with \(\alpha = A \vee \neg B\), \(\beta = C\), \(\gamma = \neg C\) gives
\begin{equation*} \begin{aligned} (A \vee \neg B \vee C) \wedge (A \vee \neg B \vee \neg C) &\;=\; (A \vee \neg B) \vee (C \wedge \neg C) \\ &\;=\; A \vee \neg B . \end{aligned} \end{equation*}
The right sentence therefore does not depend on \(\omega( C)\), which is what makes the comparison over the eight worlds below legitimate.
| \(A\) | \(B\) | \(C\) | \(\neg A \Rightarrow \neg B\) | \((A \vee \neg B \vee C) \wedge (A \vee \neg B \vee \neg C)\) |
|---|---|---|---|---|
| true | true | true | true | true |
| true | true | false | true | true |
| true | false | true | true | true |
| true | false | false | true | true |
| false | true | true | false | false |
| false | true | false | false | false |
| false | false | true | true | true |
| false | false | false | true | true |
For each of the following pairs of sentences, decide whether the first sentence implies the second. If the implication does not hold, identify a world at which the first sentence is true but the second is not.
- (a)
- \((A \Rightarrow B) \wedge \neg B\) and \(A\).
- (b)
- \((A \vee \neg B) \wedge B\) and \(A\).
- (c)
- \((A \vee B) \wedge (A \vee \neg B)\) and \(A\).
(a) The implication fails, at \(\omega(A) = \mathsf{false}\), \(\omega(B) = \mathsf{false}\); (b) and (c) hold. Here \(\alpha \models \beta\) means \(\mathrm{Mods}(\alpha) \subseteq \mathrm{Mods}(\beta)\) (Section 2.3.3), and \(\beta\) is the atomic sentence \(A\) in all three parts.
(a) At the exhibited world \(\neg A \vee B\) holds via \(\neg A\) and \(\neg B\) holds, yet \(\omega \not\models A\). Distribution and the inconsistency of \(B \wedge \neg B\) (Table 2.2) give
\begin{equation*} (A \Rightarrow B) \wedge \neg B \;=\; (\neg A \wedge \neg B) \vee (B \wedge \neg B) \;=\; \neg A \wedge \neg B , \end{equation*}
so the first sentence entails \(\neg A\) instead — modus tollens.
(b) \((A \vee \neg B) \wedge B = (A \wedge B) \vee (\neg B \wedge B) = A \wedge B\), and \(\mathrm{Mods}(A \wedge B) = \mathrm{Mods}(A) \cap \mathrm{Mods}(B) \subseteq \mathrm{Mods}(A)\).
(c) \((A \vee B) \wedge (A \vee \neg B) = A \vee (B \wedge \neg B) = A\), so the implication holds, in both directions.
Over the four worlds:
| \(A\) | \(B\) | (a) \((A \Rightarrow B) \wedge \neg B\) | (b) \((A \vee \neg B) \wedge B\) | (c) \((A \vee B) \wedge (A \vee \neg B)\) | \(A\) |
|---|---|---|---|---|---|
| true | true | false | true | true | true |
| true | false | false | false | true | true |
| false | true | false | false | false | false |
| false | false | true | false | false | false |
Which of the following pairs of sentences are mutually exclusive? Which are exhaustive? If a pair of sentences is not mutually exclusive, identify a world at which they both hold. If a pair of sentences is not exhaustive, identify a world at which neither holds.
- (a)
- \(A \vee B\) and \(\neg A \vee \neg B\).
- (b)
- \(A \vee B\) and \(\neg A \wedge \neg B\).
- (c)
- \(A\) and \((\neg A \vee B) \wedge (\neg A \vee \neg B)\).
(a) Not mutually exclusive — both hold at \(\omega(A) = \mathsf{true}\), \(\omega(B) = \mathsf{false}\) — but exhaustive; (b) and (c) are both mutually exclusive and exhaustive. By Section 2.3.3 these ask whether \(\mathrm{Mods}(\alpha) \cap \mathrm{Mods}(\beta) = \emptyset\) and whether \(\mathrm{Mods}(\alpha) \cup \mathrm{Mods}(\beta) = \Omega\).
(a) At the exhibited world \(A \vee B\) holds via \(A\) and \(\neg A \vee \neg B\) via \(\neg B\). The first sentence excludes only the world with \(A\) and \(B\) both false, the second only the world with both true, so no world is excluded by both: the pair is exhaustive. (Equivalently, the disjunction of the two has \(A\) and \(\neg A\) among its disjuncts.)
(b) By de Morgan (Table 2.2) the second sentence is \(\neg(A \vee B)\), the negation of the first, and \(\mathrm{Mods}(\neg\gamma) = \overline{\mathrm{Mods}(\gamma)}\); a set and its complement are disjoint and cover \(\Omega\).
(c) Distribution and the inconsistency of \(B \wedge \neg B\) (Table 2.2) give \((\neg A \vee B) \wedge (\neg A \vee \neg B) = \neg A\), so the pair is \(A\) and \(\neg A\), again complementary.
In the table below, mutual exclusivity of a pair means no row carries “true” in both of its columns, exhaustiveness that no row carries “false” in both.
| \(A\) | \(B\) | \(A \vee B\) | \(\neg A \vee \neg B\) | \(\neg A \wedge \neg B\) | \((\neg A \vee B) \wedge (\neg A \vee \neg B)\) |
|---|---|---|---|---|---|
| true | true | true | false | false | false |
| true | false | true | true | false | false |
| false | true | true | true | false | true |
| false | false | false | true | true | true |
Prove that \(\alpha \models \beta\) iff \(\alpha \wedge \neg \beta\) is inconsistent. This is known as the Refutation Theorem.
By Section 2.3.3, \(\alpha \models \beta\) iff \(\mathrm{Mods}(\alpha) \subseteq \mathrm{Mods}(\beta)\); by the identities \(\mathrm{Mods}(\alpha \wedge \gamma) = \mathrm{Mods}(\alpha) \cap \mathrm{Mods}(\gamma)\) and \(\mathrm{Mods}(\neg\beta) = \overline{\mathrm{Mods}(\beta)}\) of Section 2.3.1 (complement taken in the set \(\Omega\) of all worlds),
\begin{equation*} \begin{aligned} \mathrm{Mods}(\alpha \wedge \neg\beta) &\;=\; \mathrm{Mods}(\alpha) \cap \overline{\mathrm{Mods}(\beta)} \\ &\;=\; \mathrm{Mods}(\alpha) \setminus \mathrm{Mods}(\beta) . \end{aligned} \end{equation*}
For any sets, \(S \setminus T = \emptyset\) iff \(S \subseteq T\). Hence the left-hand side is empty — that is, \(\alpha \wedge \neg\beta\) is inconsistent in the sense of Section 2.3.2 — exactly when \(\mathrm{Mods}(\alpha) \subseteq \mathrm{Mods}(\beta)\), i.e. exactly when \(\alpha \models \beta\). \(\blacksquare\)
Prove that \(\alpha \models \beta\) iff \(\alpha \Rightarrow \beta\) is valid. This is known as the Deduction Theorem.
Since \(\alpha \Rightarrow \beta\) abbreviates \(\neg\alpha \vee \beta\) (Section 2.2), the model-set identities of Section 2.3.1 give
\begin{equation*} \begin{aligned} \mathrm{Mods}(\alpha \Rightarrow \beta) &\;=\; \mathrm{Mods}(\neg\alpha) \cup \mathrm{Mods}(\beta) \\ &\;=\; \overline{\mathrm{Mods}(\alpha)} \cup \mathrm{Mods}(\beta) . \end{aligned} \end{equation*}
For subsets \(S, T \subseteq \Omega\) one has \(\overline{S} \cup T = \Omega\) iff \(S \subseteq T\), since the worlds outside \(\overline{S}\) are precisely those in \(S\). Taking \(S = \mathrm{Mods}(\alpha)\) and \(T = \mathrm{Mods}(\beta)\): validity of \(\alpha \Rightarrow \beta\), i.e. \(\mathrm{Mods}(\alpha \Rightarrow \beta) = \Omega\) (Section 2.3.2), holds iff \(\mathrm{Mods}(\alpha) \subseteq \mathrm{Mods}(\beta)\), i.e. iff \(\alpha \models \beta\). \(\blacksquare\)
Method (2): by Exercise 2.6, \(\alpha \models \beta\) iff \(\alpha \wedge \neg\beta\) is inconsistent, and a sentence \(\gamma\) is inconsistent iff \(\neg\gamma\) is valid (complementation again). De Morgan and double negation (Table 2.2) turn \(\neg(\alpha \wedge \neg\beta)\) into \(\neg\alpha \vee \beta = \alpha \Rightarrow \beta\).
Exercises 2.8–2.13
Prove that if \(\alpha \models \beta\), then \(\alpha \wedge \beta\) is equivalent to \(\alpha\).
Assume \(\alpha \models \beta\), that is, \(\mathrm{Mods}(\alpha) \subseteq \mathrm{Mods}(\beta)\) (Section 2.3.3). Since \(S \subseteq T\) implies \(S \cap T = S\), the identity of Section 2.3.1 gives
\begin{equation*} \begin{aligned} \mathrm{Mods}(\alpha \wedge \beta) &\;=\; \mathrm{Mods}(\alpha) \cap \mathrm{Mods}(\beta) \\ &\;=\; \mathrm{Mods}(\alpha) , \end{aligned} \end{equation*}
and sentences with identical model sets are equivalent. \(\blacksquare\)
Prove that if \(\alpha \models \beta\), then \(\alpha \vee \beta\) is equivalent to \(\beta\).
Assume \(\alpha \models \beta\), that is, \(\mathrm{Mods}(\alpha) \subseteq \mathrm{Mods}(\beta)\) (Section 2.3.3). Since \(S \subseteq T\) implies \(S \cup T = T\), the identity of Section 2.3.1 gives
\begin{equation*} \begin{aligned} \mathrm{Mods}(\alpha \vee \beta) &\;=\; \mathrm{Mods}(\alpha) \cup \mathrm{Mods}(\beta) \\ &\;=\; \mathrm{Mods}(\beta) , \end{aligned} \end{equation*}
so \(\alpha \vee \beta\) and \(\beta\) are equivalent. \(\blacksquare\)
Method (2): \(\alpha \models \beta\) iff \(\neg\beta \models \neg\alpha\), so Exercise 2.8 applied to that pair gives \(\neg\beta \wedge \neg\alpha \equiv \neg\beta\); negating both sides and using de Morgan (Table 2.2) yields \(\alpha \vee \beta \equiv \beta\).
Convert the following sentences into CNF:
- (a)
- \(P \Rightarrow (Q \Rightarrow R)\).
- (b)
- \(\neg((P \Rightarrow Q) \wedge (R \Rightarrow S))\).
(a) The single clause \(\neg P \vee \neg Q \vee R\); (b) the four-clause CNF displayed below. Both parts run the procedure of Section 2.7.3: eliminate implications, push negations onto variables, distribute \(\vee\) over \(\wedge\).
(a) Eliminating the inner then the outer implication,
\begin{equation*} P \Rightarrow (Q \Rightarrow R) \;\equiv\; \neg P \vee (\neg Q \vee R) \;\equiv\; \neg P \vee \neg Q \vee R , \end{equation*}
already in NNF, with no conjunction to distribute over.
(b) Eliminating implications, then de Morgan twice on the outer negation and double-negation removal,
\begin{equation*} \begin{aligned} \neg\big((P \Rightarrow Q) \wedge (R \Rightarrow S)\big) &\equiv \neg\big((\neg P \vee Q) \wedge (\neg R \vee S)\big) \\ &\equiv (P \wedge \neg Q) \vee (R \wedge \neg S) . \end{aligned} \end{equation*}
Distributing over each conjunction in turn,
\begin{equation*} \begin{aligned} (P \wedge \neg Q) \vee (R \wedge \neg S) &\equiv \big((P \wedge \neg Q) \vee R\big) \\ &\qquad \wedge \big((P \wedge \neg Q) \vee \neg S\big) \\ &\equiv (P \vee R) \wedge (\neg Q \vee R) \\ &\qquad \wedge (P \vee \neg S) \wedge (\neg Q \vee \neg S). \end{aligned} \end{equation*}
No clause is a tautology or subsumed by another, so no clause can be dropped. The table compares \(\varphi = \neg((P \Rightarrow Q) \wedge (R \Rightarrow S))\) with this CNF \(\psi\) over all sixteen worlds, writing \(I_1 = P \Rightarrow Q\) and \(I_2 = R \Rightarrow S\):
| P | Q | R | S | \(I_1\) | \(I_2\) | \(\varphi\) | \(\psi\) |
|---|---|---|---|---|---|---|---|
| t | t | t | t | t | t | f | f |
| t | t | t | f | t | f | t | t |
| t | t | f | t | t | t | f | f |
| t | t | f | f | t | t | f | f |
| t | f | t | t | f | t | t | t |
| t | f | t | f | f | f | t | t |
| t | f | f | t | f | t | t | t |
| t | f | f | f | f | t | t | t |
| f | t | t | t | t | t | f | f |
| f | t | t | f | t | f | t | t |
| f | t | f | t | t | t | f | f |
| f | t | f | f | t | t | f | f |
| f | f | t | t | t | t | f | f |
| f | f | t | f | t | f | t | t |
| f | f | f | t | t | t | f | f |
| f | f | f | f | t | t | f | f |
Let \(\Gamma\) be an NNF circuit that satisfies decomposability and determinism. Show how one can augment the circuit \(\Gamma\) with additional nodes so it also satisfies smoothness. What is the time and space complexity of your algorithm for ensuring smoothness?
Recall the definitions of Section 2.7. An NNF circuit is a rooted DAG whose leaves (inputs) are labeled with literals or with the constants \(\mathit{true}\) / \(\mathit{false}\), and whose internal nodes are and-gates and or-gates. It is decomposable if for every and-node the sentences represented by any two of its children share no variables; deterministic if for every or-node the sentences represented by any two of its children are mutually exclusive; and smooth if for every or-node the sentences represented by any two of its children mention the same set of variables.
Conjoin onto each or-node edge the valid gadgets \(X \vee \neg X\) for the variables its child is missing; with \(m = |\Gamma|\) edges and \(v\) variables this costs \(O(mv)\) time and yields a circuit of size \(O(mv)\).
Write \(\mathrm{Vars}(N)\) for the variables mentioned in the subcircuit at \(N\), and assume every node is reachable from the root.
One reverse-topological sweep computes \(\mathrm{Vars}(N)\) everywhere: \(\emptyset\) at a constant input, \(\{X\}\) at an input labeled \(X\) or \(\neg X\), and \(\bigcup_C \mathrm{Vars}( C)\) at an internal node. Store each set as a length-\(v\) bit vector.
Build once, per variable \(X\), an or-node \(S_X\) with fresh children labeled \(X\) and \(\neg X\); thus \(S_X\) is valid and \(\mathrm{Vars}(S_X) = \{X\}\).
For each edge \(N \to C\) with \(N\) an or-node, let \(D = \mathrm{Vars}(N) \setminus \mathrm{Vars}( C)\); if \(D \neq \emptyset\), redirect the edge to a fresh and-node
\begin{equation*} A_{N,C} \;=\; \mathrm{and}\Big(C,\; \{\,S_X : X \in D\,\}\Big) . \end{equation*}
The gadget must hang off the edge, not off \(C\) itself: in a DAG the same \(C\) may be a child of two or-nodes with different variable sets.
Equivalence. Each \(S_X\) is valid, so \(A_{N,C}\) is equivalent to \(C\) by \(\alpha \wedge \mathit{true} \equiv \alpha\) (Table 2.2), and replacing a child by an equivalent child preserves the sentence represented by every ancestor, hence by the root.
Variable sets are unchanged, since \(\mathrm{Vars}( C) \subseteq \mathrm{Vars}(N)\) (the latter being the union over the children) gives
\begin{equation*} \mathrm{Vars}(A_{N,C}) = \mathrm{Vars}( C) \cup D = \mathrm{Vars}(N) ; \end{equation*}
so the sets from step 1 stay valid and the or-nodes may be processed independently, in one pass, in any order.
Smoothness holds because every child of an or-node \(N\) now mentions exactly \(\mathrm{Vars}(N)\), and each \(S_X\) has both children mentioning \(\{X\}\). Decomposability is preserved: the children of \(A_{N,C}\) are \(C\) and the \(S_X\) with \(X \in D\), pairwise variable-disjoint since \(D \cap \mathrm{Vars}( C) = \emptyset\) and the gadgets are for distinct variables, while original and-nodes keep their children and their variable sets. Determinism is preserved: equivalent replacements of mutually exclusive children remain mutually exclusive, and \(X, \neg X\) are mutually exclusive.
Complexity. Step 1 performs one set union per edge, \(O(mv)\) bit operations (\(O(mv/w)\) machine words) and \(O(mv)\) bits of working space; step 2 is \(O(v)\); step 3 examines each edge once, computes a set difference in \(O(v)\), and adds at most \(1+v\) edges. Hence \(O(mv)\) time and \(O(mv)\) output size, with \(\sum_{N \to C} |\mathrm{Vars}(N) \setminus \mathrm{Vars}( C)|\) edges actually added — none on an already smooth circuit.
Let \(\Gamma\) be an NNF circuit that satisfies decomposability, is equivalent to CNF \(\Delta\), and does not contain \(\mathit{false}\). Suppose that every model of \(\Delta\) sets the same number of variables to true (we say in this case that all models of \(\Delta\) have the same cardinality). Show that circuit \(\Gamma\) must be smooth.
Were some or-node \(N\) not smooth, a child \(C_1\) would omit a variable \(X \in \mathrm{Vars}(N)\); extending a model of \(C_1\) (Step 1) to \(\mathrm{Vars}(N)\) in the two ways \(\omega_1, \omega_2\) that differ only at \(X\) gives two models of \(N\), both satisfying \(N\) through \(C_1\), with \(\#\omega_1 = \#\omega_2 + 1\) — impossible by Step 4 below. Write \(\mathrm{Vars}(N)\) and \(\mathrm{Mods}(N)\) for the variables of the subcircuit at \(N\) and its models (assignments to \(\mathrm{Vars}(N)\)), and \(\#\sigma\) for the number of variables \(\sigma\) sets to true; every node is assumed reachable from the root.
Step 1: every node is satisfiable. Bottom-up: an input is \(\mathit{true}\) or a literal, never \(\mathit{false}\) by hypothesis, and each of these is satisfiable; an or-node is satisfied through any child; and at an and-node decomposability makes the children’s variable sets pairwise disjoint with union \(\mathrm{Vars}(N)\), so models \(\sigma_i\) of the children have disjoint domains and \(\sigma_1 \cup \cdots \cup \sigma_k\) is a well-defined model of \(N\).
Step 2: local models extend coherently. For every node \(N\) and \(\sigma, \sigma^{\prime} \in \mathrm{Mods}(N)\) there are models \(\omega, \omega^{\prime}\) of \(\Gamma\) restricting to \(\sigma, \sigma^{\prime}\) on \(\mathrm{Vars}(N)\) and agreeing with each other outside \(\mathrm{Vars}(N)\). Walk a path \(N = N_0, \ldots, N_r\) to the root making the same choice on both branches at each step: at an or-parent extend both by one and the same assignment of \(\mathrm{Vars}(N_{j+1}) \setminus \mathrm{Vars}(N_j)\), which satisfies \(N_{j+1}\) through the child \(N_j\); at an and-parent adjoin one and the same model of each sibling (Step 1), legitimate because decomposability makes the domains disjoint.
Step 3: all models of \(\Gamma\) have one cardinality \(c\). \(\Gamma\) is satisfiable by Step 1, so \(\Delta\) has a model. If a variable \(X\) lay in exactly one of \(V = \mathrm{Vars}(\Delta)\) and \(\mathrm{Vars}(\Gamma)\), then over the common variable set \(V \cup \mathrm{Vars}(\Gamma)\) the sentence not mentioning \(X\) has a model set closed under flipping \(X\); the two model sets are equal, so \(\mathrm{Mods}(\Delta)\) is closed under that flip too, and flipping changes cardinality by one, contradicting the hypothesis. Hence \(\mathrm{Vars}(\Gamma) = V\) and \(\mathrm{Mods}(\Gamma) = \mathrm{Mods}(\Delta)\).
Step 4: every node inherits the property. For \(\sigma, \sigma^{\prime} \in \mathrm{Mods}(N)\), take \(\omega, \omega^{\prime}\) from Step 2; they agree outside \(\mathrm{Vars}(N)\), so
\begin{equation*} \#\sigma - \#\sigma^{\prime} \;=\; \#\omega - \#\omega^{\prime} \;=\; c - c \;=\; 0 . \end{equation*}
This contradicts \(\#\omega_1 = \#\omega_2 + 1\) above, so no or-node child omits a variable of its parent: any two children of an or-node mention the same variables, i.e. \(\Gamma\) is smooth. \(\blacksquare\)
Let \(\Gamma\) be an NNF circuit that satisfies decomposability, determinism, and smoothness. Consider the following procedure for generating a subcircuit \(\Gamma_m\) of circuit \(\Gamma\):
- Assign an integer to each node in circuit \(\Gamma\) as follows: an input node is assigned \(0\) if labeled with \(\mathit{true}\) or a positive literal, \(\infty\) if labeled with \(\mathit{false}\), and \(1\) if labeled with a negative literal. An or-node is assigned the minimum of integers assigned to its children, and an and-node is assigned the sum of integers assigned to its children.
- Obtain \(\Gamma_m\) from \(\Gamma\) by deleting every edge that extends from an or-node \(N\) to one of its children \(C\), where \(N\) and \(C\) have different integers assigned to them.
Show that the models of \(\Gamma_m\) are the minimum-cardinality models of \(\Gamma\), where the cardinality of a model is defined as the number of variables it sets to false.
The assigned integers are minimum cardinalities, and the deletion retains exactly the edges lying on a minimum-cardinality model. Write \(\|\sigma\|\) for the number of variables \(\sigma\) sets to false, \(d(N)\) for the integer at \(N\), and \(\mathrm{Mods}(N)\) for the models of the subcircuit at \(N\) (assignments to \(\mathrm{Vars}(N)\)); arithmetic uses \(\infty + x = \infty\), \(\min(\infty,x) = x\), and \(\min\emptyset = \infty\).
Lemma 1. \(d(N) = \min\{\|\sigma\| : \sigma \in \mathrm{Mods}(N)\}\) at every node. Bottom-up. The inputs read off directly: \(0\) for \(\mathit{true}\) and for a positive literal, \(1\) for a negative literal, \(\infty\) for \(\mathit{false}\) (empty model set). At an or-node, smoothness gives \(\mathrm{Vars}(C_i) = \mathrm{Vars}(N)\) for all \(i\), so \(\mathrm{Mods}(N) = \bigcup_i \mathrm{Mods}(C_i)\) with no extension needed and
\begin{equation*} \min_{\sigma \in \mathrm{Mods}(N)} \|\sigma\| \;=\; \min_i \, d(C_i) \;=\; d(N) ; \end{equation*}
smoothness is essential, since extending a child’s model to \(\mathrm{Vars}(N)\) could add false-valued variables and understate its cost. At an and-node, decomposability makes the \(\mathrm{Vars}(C_i)\) pairwise disjoint with union \(\mathrm{Vars}(N)\), so \(\mathrm{Mods}(N)\) consists of the disjoint unions \(\sigma_1 \cup \cdots \cup \sigma_k\), \(\|\cdot\|\) is additive on them, and minimizing a sum of independent terms minimizes each term:
\begin{equation*} \min_{\sigma \in \mathrm{Mods}(N)} \|\sigma\| \;=\; \sum_i \, d(C_i) \;=\; d(N) \end{equation*}
(both sides \(\infty\) if some child is unsatisfiable).
Lemma 2. At an or-node the deleted children are exactly those with \(d( C) > d(N)\), since \(d(N) = \min_i d(C_i)\), and at least one child survives; by smoothness every child carries variable set \(\mathrm{Vars}(N)\), so the surviving union is still \(\mathrm{Vars}(N)\). And-node edges are never deleted, so \(\mathrm{Vars}(N)\) is unchanged in \(\Gamma_m\), which remains decomposable, deterministic, and smooth (a subset of an or-node’s children preserves pairwise mutual exclusivity and pairwise equality of variable sets).
Main claim. For every node \(N\),
\begin{equation*} \begin{aligned} \mathrm{Mods}_{\Gamma_m}(N) \;=\; \{\, \sigma \in \mathrm{Mods}_{\Gamma}(N) : \|\sigma\| = d(N) \,\}, \end{aligned} \end{equation*}
both sides being sets of assignments to \(\mathrm{Vars}(N)\) by Lemma 2. Bottom-up.
(i) Inputs. Untouched, and each has at most one model, of cardinality \(d(N)\) by the base cases of Lemma 1; for \(\mathit{false}\) both sides are empty.
(ii) Or-nodes. By the inductive hypothesis and smoothness,
\begin{equation*} \begin{aligned} \mathrm{Mods}_{\Gamma_m}(N) &= \bigcup_{i \,:\, d(C_i) = d(N)} \{\sigma \in \mathrm{Mods}_\Gamma(C_i) : \|\sigma\| = d(N)\} \\ &= \bigcup_{i=1}^{k} \{\sigma \in \mathrm{Mods}_\Gamma(C_i) : \|\sigma\| = d(N)\}, \end{aligned} \end{equation*}
because a deleted child has \(d(C_i) > d(N)\) and by Lemma 1 all of its models cost at least \(d(C_i)\), so it contributes nothing; the last union is \(\{\sigma \in \mathrm{Mods}_\Gamma(N) : \|\sigma\| = d(N)\}\).
(iii) And-nodes. All children survive, models of \(N\) are the disjoint unions \(\bigcup_i \sigma_i\) with \(\|\bigcup_i \sigma_i\| = \sum_i \|\sigma_i\|\), and \(d(N) = \sum_i d(C_i)\) with \(\|\sigma_i\| \ge d(C_i)\) termwise (Lemma 1); so the sums agree only if \(\|\sigma_i\| = d(C_i)\) for every \(i\), which is exactly what the inductive hypothesis says \(\mathrm{Mods}_{\Gamma_m}(C_i)\) contains. (Both sides empty if some \(d(C_i) = \infty\).)
At the root, Lemma 1 identifies \(d(\mathrm{root})\) with \(\min_{\tau \in \mathrm{Mods}(\Gamma)} \|\tau\|\), so the models of \(\Gamma_m\) are precisely the minimum-cardinality models of \(\Gamma\). \(\blacksquare\)
Probability Calculus
Exercises 3.1–3.7
Consider the following joint distribution over the propositional variables \(A\), \(B\), \(C\).
| world | \(A\) | \(B\) | \(C\) | \(\Pr(.)\) |
|---|---|---|---|---|
| \(\omega_1\) | true | true | true | .075 |
| \(\omega_2\) | true | true | false | .050 |
| \(\omega_3\) | true | false | true | .225 |
| \(\omega_4\) | true | false | false | .150 |
| \(\omega_5\) | false | true | true | .025 |
| \(\omega_6\) | false | true | false | .100 |
| \(\omega_7\) | false | false | true | .075 |
| \(\omega_8\) | false | false | false | .300 |
- (a)
- What is \(\Pr(A = \text{true})\)? \(\Pr(B = \text{true})\)? \(\Pr(C = \text{true})\)?
- (b)
- Update the distribution by conditioning on the event \(C = \text{true}\), that is, construct the conditional distribution \(\Pr(. \mid C = \text{true})\).
- (c)
- What is \(\Pr(A = \text{true} \mid C = \text{true})\)? \(\Pr(B = \text{true} \mid C = \text{true})\)?
- (d)
- Is the event \(A = \text{true}\) independent of the event \(C = \text{true}\)? Is \(B = \text{true}\) independent of \(C = \text{true}\)?
(a) \(.5\), \(.25\), \(.4\); (b) the table below; (c) \(.75\) and \(.25\); (d) \(A = \text{true}\) is not independent of \(C = \text{true}\), while \(B = \text{true}\) is.
(a) Equation (3.1) sums the beliefs of the worlds satisfying each event:
\begin{equation*} \begin{aligned} \Pr(A = \text{true}) &= .075 + .050 + .225 + .150 = .5, \\ \Pr(B = \text{true}) &= .075 + .050 + .025 + .100 = .25, \\ \Pr(C = \text{true}) &= .075 + .225 + .025 + .075 = .4 . \end{aligned} \end{equation*}
(b) By (3.11) every world falsifying the evidence gets belief \(0\) and every world satisfying it is rescaled by \(\Pr(C = \text{true}) = .4\), e.g. \(.075/.4 = .1875\):
| world | \(A\) | \(B\) | \(C\) | \(\Pr(. \mid C = \text{true})\) |
|---|---|---|---|---|
| \(\omega_1\) | true | true | true | .1875 |
| \(\omega_2\) | true | true | false | 0 |
| \(\omega_3\) | true | false | true | .5625 |
| \(\omega_4\) | true | false | false | 0 |
| \(\omega_5\) | false | true | true | .0625 |
| \(\omega_6\) | false | true | false | 0 |
| \(\omega_7\) | false | false | true | .1875 |
| \(\omega_8\) | false | false | false | 0 |
(c) By (3.12), equivalently by summing the surviving entries of (b),
\begin{equation*} \Pr(A = \text{true} \mid C = \text{true}) = \frac{.075 + .225}{.4} = .75, \end{equation*}
\begin{equation*} \Pr(B = \text{true} \mid C = \text{true}) = \frac{.075 + .025}{.4} = .25 . \end{equation*}
(d) By Definition (3.13), \(\alpha\) is independent of \(\beta\) when \(\Pr(\alpha \mid \beta) = \Pr(\alpha)\). Here \(.75 \ne .5 = \Pr(A = \text{true})\), so \(A = \text{true}\) and \(C = \text{true}\) are not independent, while \(.25 = \Pr(B = \text{true})\), so \(B = \text{true}\) and \(C = \text{true}\) are. The symmetric form (3.14) agrees: \(\Pr(A = \text{true} \wedge C = \text{true}) = .3 \ne .2 = (.5)(.4)\), whereas \(\Pr(B = \text{true} \wedge C = \text{true}) = .1 = (.25)(.4)\).
Consider again the joint distribution \(\Pr\) from Exercise 3.1, repeated here for convenience.
| world | \(A\) | \(B\) | \(C\) | \(\Pr(.)\) |
|---|---|---|---|---|
| \(\omega_1\) | true | true | true | .075 |
| \(\omega_2\) | true | true | false | .050 |
| \(\omega_3\) | true | false | true | .225 |
| \(\omega_4\) | true | false | false | .150 |
| \(\omega_5\) | false | true | true | .025 |
| \(\omega_6\) | false | true | false | .100 |
| \(\omega_7\) | false | false | true | .075 |
| \(\omega_8\) | false | false | false | .300 |
- (a)
- What is \(\Pr(A = \text{true} \vee B = \text{true})\)?
- (b)
- Update the distribution by conditioning on the event \(A = \text{true} \vee B = \text{true}\), that is, construct the conditional distribution \(\Pr(. \mid A = \text{true} \vee B = \text{true})\).
- (c)
- What is \(\Pr(A = \text{true} \mid A = \text{true} \vee B = \text{true})\)? \(\Pr(B = \text{true} \mid A = \text{true} \vee B = \text{true})\)?
- (d)
- Determine whether the event \(B = \text{true}\) is conditionally independent of \(C = \text{true}\) given the event \(A = \text{true} \vee B = \text{true}\).
(a) \(.625\); (b) the table below; (c) \(.8\) and \(.4\); (d) no. Write \(\beta\) for the evidence \(A = \text{true} \vee B = \text{true}\).
(a) The worlds satisfying \(\beta\) are \(\omega_1,\ldots,\omega_6\), so by (3.1)
\begin{equation*} \Pr(\beta) = .075 + .050 + .225 + .150 + .025 + .100 = .625 . \end{equation*}
(b) By (3.11) the two falsifying worlds \(\omega_7, \omega_8\) get belief \(0\) and the rest are divided by \(.625\), e.g. \(.075/.625 = .12\):
| world | \(A\) | \(B\) | \(C\) | \(\Pr(. \mid \beta)\) |
|---|---|---|---|---|
| \(\omega_1\) | true | true | true | .12 |
| \(\omega_2\) | true | true | false | .08 |
| \(\omega_3\) | true | false | true | .36 |
| \(\omega_4\) | true | false | false | .24 |
| \(\omega_5\) | false | true | true | .04 |
| \(\omega_6\) | false | true | false | .16 |
| \(\omega_7\) | false | false | true | 0 |
| \(\omega_8\) | false | false | false | 0 |
(c) A world with \(A\) true already satisfies \(\beta\), so \((A = \text{true}) \wedge \beta \equiv (A = \text{true})\), and likewise for \(B\); hence by (3.12)
\begin{equation*} \Pr(A = \text{true} \mid \beta) = \frac{.5}{.625} = .8, \qquad \Pr(B = \text{true} \mid \beta) = \frac{.25}{.625} = .4 . \end{equation*}
(d) Not conditionally independent. By (3.16) the test is whether \(\Pr(B = \text{true} \wedge C = \text{true} \mid \beta)\) equals the product of the two separate conditionals. The worlds with \(B\) and \(C\) true are \(\omega_1, \omega_5\), both satisfying \(\beta\); those with \(C\) true satisfying \(\beta\) are \(\omega_1, \omega_3, \omega_5\). So
\begin{equation*} \Pr(B = \text{true} \wedge C = \text{true} \mid \beta) = \frac{.1}{.625} = .16 , \end{equation*}
\begin{equation*} \Pr(C = \text{true} \mid \beta) = \frac{.325}{.625} = .52 , \end{equation*}
while \(\Pr(B = \text{true} \mid \beta)\Pr(C = \text{true} \mid \beta) = (.4)(.52) = .208 \ne .16\).
Suppose that we tossed two unbiased coins \(C_1\) and \(C_2\).
- (a)
- Given that the first coin landed heads, \(C_1 = h\), what is the probability that the second coin landed tails, \(\Pr(C_2 = t \mid C_1 = h)\)?
- (b)
- Given that at least one of the coins landed heads, \(C_1 = h \vee C_2 = h\), what is the probability that both coins landed heads, \(\Pr(C_1 = h \wedge C_2 = h \mid C_1 = h \vee C_2 = h)\)?
Unbiasedness gives \(\Pr(C_1 = h) = \Pr(C_2 = h) = 1/2\), and tossing two separate coins makes the outcomes independent, so by (3.14) each world carries the product \(1/4\):
| world | \(C_1\) | \(C_2\) | \(\Pr(.)\) |
|---|---|---|---|
| \(\omega_1\) | \(h\) | \(h\) | 1/4 |
| \(\omega_2\) | \(h\) | \(t\) | 1/4 |
| \(\omega_3\) | \(t\) | \(h\) | 1/4 |
| \(\omega_4\) | \(t\) | \(t\) | 1/4 |
(a) \(1/2\). The evidence holds in \(\omega_1, \omega_2\) and \(C_2 = t \wedge C_1 = h\) only in \(\omega_2\), so by Bayes conditioning (3.12),
\begin{equation*} \Pr(C_2 = t \mid C_1 = h) = \frac{1/4}{1/2} = \frac{1}{2}. \end{equation*}
(b) \(1/3\). Put \(\beta : C_1 = h \vee C_2 = h\), holding in \(\omega_1,\omega_2,\omega_3\), and \(\alpha : C_1 = h \wedge C_2 = h\), holding only in \(\omega_1\); since \(\alpha \models \beta\) we have \(\alpha \wedge \beta \equiv \alpha\), so by (3.12)
\begin{equation*} \Pr(\alpha \mid \beta) = \frac{1/4}{3/4} = \frac{1}{3}. \end{equation*}
Suppose that 24% of a population are smokers and that 5% of the population have cancer. Suppose further that 86% of the population with cancer are also smokers. What is the probability that a smoker will also have cancer?
About \(17.9\%\). Writing \(S\) for “the individual smokes” and \(C\) for “the individual has cancer” under uniform sampling from the population, the data read \(\Pr(S) = .24\), \(\Pr( C) = .05\), \(\Pr(S \mid C) = .86\), and Bayes rule (3.19) supplies the reverse conditional:
\begin{equation*} \Pr(C \mid S) = \frac{\Pr(S \mid C)\,\Pr( C)}{\Pr(S)} = \frac{(.86)(.05)}{.24} = \frac{.043}{.24} \approx .1792 . \end{equation*}
Consider again the population from Exercise 3.4, in which 24% are smokers, 5% have cancer, and 86% of those with cancer are smokers. What is the relative change in the odds that a member of the population has cancer upon learning that they are also a smoker?
The odds of cancer are multiplied by \(k \approx 4.147\), rising from about \(1{:}19\) to about \(1{:}4.58\). Keeping \(S\) and \(C\) and the data of Exercise 3.4, the quantity asked for is the Bayes factor \(k = O^{\prime}( C)/O( C)\), with \(O(\gamma) = \Pr(\gamma)/\Pr(\neg\gamma)\) the odds (3.23) and \(O^{\prime}\) computed in \(\Pr^{\prime} = \Pr(. \mid S)\). From Exercise 3.4, \(\Pr(C \mid S) = .043/.24\), so \(\Pr(\neg C \mid S) = (.24 - .043)/.24 = .197/.24\) and the common denominator \(\Pr(S)\) cancels:
\begin{equation*} k = \frac{O^{\prime}( C)}{O( C)} = \frac{.043/.197}{.05/.95} = \frac{(.043)(.95)}{(.197)(.05)} = \frac{817}{197} \approx 4.147 . \end{equation*}
Method (2): applying (3.19) to numerator and denominator of \(O^{\prime}( C)\) cancels \(\Pr(S)\) and gives \(k = \Pr(S \mid C)/\Pr(S \mid \neg C)\); case analysis (3.17) yields \(\Pr(S \wedge \neg C) = .24 - .043 = .197\), so \(\Pr(S \mid \neg C) = .197/.95\) and \(k = (.86)(.95)/.197 \approx 4.147\).
Consider a family with two children, ages four and nine.
- (a)
- What is the probability that the older child is a boy?
- (b)
- What is the probability that the older child is a boy given that the younger child is a boy?
- (c)
- What is the probability that the older child is a boy given that at least one of the children is a boy?
- (d)
- What is the probability that both children are boys given that at least one of them is a boy?
Define your variables and the corresponding joint probability distribution. Moreover, for each of these questions define \(\alpha\) and \(\beta\) for which \(\Pr(\alpha \mid \beta)\) is the answer.
Take \(O\) for the sex of the older child and \(Y\) for that of the younger, each with values \(b\) and \(g\); the differing ages make the children distinguishable. Under the usual idealization each child is equally likely a boy or a girl and the two sexes are independent, so by (3.14) every world carries the product \(1/2 \times 1/2\):
| world | \(O\) | \(Y\) | \(\Pr(.)\) |
|---|---|---|---|
| \(\omega_1\) | \(b\) | \(b\) | 1/4 |
| \(\omega_2\) | \(b\) | \(g\) | 1/4 |
| \(\omega_3\) | \(g\) | \(b\) | 1/4 |
| \(\omega_4\) | \(g\) | \(g\) | 1/4 |
The event “at least one child is a boy” is \(O = b \vee Y = b\), holding in \(\omega_1,\omega_2,\omega_3\), of belief \(3/4\).
(a) \(\alpha : O = b\), \(\beta : \top\); since \(\Pr(\top) = 1\), the answer is \(\Pr(O = b) = 1/4 + 1/4 = 1/2\).
(b) \(\alpha : O = b\), \(\beta : Y = b\). The evidence holds in \(\omega_1,\omega_3\) and the conjunction only in \(\omega_1\), so by (3.12) the answer is \((1/4)/(1/2) = 1/2\) — the independence assumption showing itself.
(c) \(\alpha : O = b\), \(\beta : O = b \vee Y = b\). Here \(\alpha \models \beta\), so \(\alpha \wedge \beta \equiv \alpha\) and
\begin{equation*} \Pr(O = b \mid O = b \vee Y = b) = \frac{1/2}{3/4} = \frac{2}{3} . \end{equation*}
(d) \(\alpha : O = b \wedge Y = b\), \(\beta : O = b \vee Y = b\). Again \(\alpha \models \beta\), so
\begin{equation*} \Pr(O = b \wedge Y = b \mid O = b \vee Y = b) = \frac{1/4}{3/4} = \frac13 . \end{equation*}
Prove Equation 3.19, that is, Bayes rule:
\begin{equation*} \Pr(\alpha \mid \beta) = \frac{\Pr(\beta \mid \alpha)\,\Pr(\alpha)}{\Pr(\beta)} . \end{equation*}
Bayes conditioning (3.12) applied twice to the same joint belief. Assume \(\Pr(\alpha) \ne 0\) and \(\Pr(\beta) \ne 0\), without which \(\Pr(\beta \mid \alpha)\) and the right-hand side are undefined. Applying (3.12) with evidence \(\alpha\) and multiplying through,
\begin{equation*} \begin{aligned} \Pr(\beta \mid \alpha)\,\Pr(\alpha) &= \Pr(\beta \wedge \alpha) \;=\; \Pr(\alpha \wedge \beta), \end{aligned} \end{equation*}
the second equality because \(\alpha \wedge \beta\) and \(\beta \wedge \alpha\) have the same models and (3.1) reads belief off the model set alone. Substituting that numerator into (3.12) with evidence \(\beta\),
\begin{equation*} \Pr(\alpha \mid \beta) = \frac{\Pr(\alpha \wedge \beta)}{\Pr(\beta)} = \frac{\Pr(\beta \mid \alpha)\,\Pr(\alpha)}{\Pr(\beta)} . \qquad \blacksquare \end{equation*}
Exercises 3.8–3.14
Suppose that we have a patient who was just tested for a particular disease and the test came out positive. We know that one in every thousand people has this disease. We also know that the test is not reliable: it has a false positive rate of \(2\%\) and a false negative rate of \(5\%\). We have seen previously that the probability of having the disease is \(\approx 4.5\%\) given a positive test result. Suppose that the test is repeated \(n\) times and all tests come out positive. What is the smallest \(n\) for which the belief in the disease is greater than \(95\%\), assuming the errors of various tests are independent? Justify your answer.
\(n = 3\). Let \(D\) be the disease and \(T_i\) the event that test \(i\) reads positive, so \(\Pr(D) = .001\), \(f_p = \Pr(T_i \mid \neg D) = .02\) and \(f_n = \Pr(\neg T_i \mid D) = .05\). “Errors independent” means the readings are mutually independent given \(D\) and given \(\neg D\) — conditional independence (3.16), not unconditional independence — so for \(e_n = T_1 \wedge \cdots \wedge T_n\),
\begin{equation*} \Pr(e_n \mid D) = (.95)^n, \qquad \Pr(e_n \mid \neg D) = (.02)^n . \end{equation*}
Applying (3.12) to numerator and denominator of the odds, each reading contributes the noisy-sensor Bayes factor \(k^{+} = (1-f_n)/f_p = 47.5\) of Section 3.6.4:
\begin{equation*} O(D \mid e_n) = \frac{\Pr(e_n \mid D)\Pr(D)}{\Pr(e_n \mid \neg D)\Pr(\neg D)} = (47.5)^n \cdot \frac{.001}{.999} = \frac{(47.5)^n}{999} . \end{equation*}
A belief exceeds \(95\%\) exactly when its odds exceed \(.95/.05 = 19\), so we need \((47.5)^n > 18981\), i.e. \(n > \ln 18981 / \ln 47.5 \approx 2.552\); since \((47.5)^n\) increases with \(n\), the least such integer is \(n = 3\). Converting back with \(\Pr = O/(1+O)\):
| \(n\) | \(O(D\mid e_n) = 47.5^n/999\) | \(\Pr(D\mid e_n)\) |
|---|---|---|
| 1 | \(.047548\) | \(.04539\) |
| 2 | \(2.25851\) | \(.69311\) |
| 3 | \(107.279\) | \(.99076\) |
Consider the following distribution over three variables:
| world | \(A\) | \(B\) | \(C\) | \(\Pr(.)\) |
|---|---|---|---|---|
| \(\omega_1\) | true | true | true | .27 |
| \(\omega_2\) | true | true | false | .18 |
| \(\omega_3\) | true | false | true | .03 |
| \(\omega_4\) | true | false | false | .02 |
| \(\omega_5\) | false | true | true | .02 |
| \(\omega_6\) | false | true | false | .03 |
| \(\omega_7\) | false | false | true | .18 |
| \(\omega_8\) | false | false | false | .27 |
For each pair of variables, state whether they are independent. State also whether they are independent given the third variable. Justify your answers.
No pair is marginally independent, and the only conditional independence of the three is \(B \perp C \mid A\). Write \(a\) for \(A = \text{true}\), \(\bar a\) for \(A = \text{false}\), similarly for \(B\) and \(C\); by (3.14) a pair of variables is independent only if \(\Pr(x,y) = \Pr(x)\Pr(y)\) at every instantiation, so one violation refutes it.
Summing the worlds by (3.1) gives \(\Pr(a) = \Pr(b) = \Pr( c) = .50\), so independence of a pair would force each joint entry to be \(.25\). It does not:
\begin{equation*} \begin{aligned} \Pr(a,b) &= .27+.18 = .45, \\ \Pr(a,c) &= .27+.03 = .30, \\ \Pr(b,c) &= .27+.02 = .29 . \end{aligned} \end{equation*}
(i) \(B\) and \(C\) are independent given \(A\). Conditioning on \(a\) (of probability \(.50\)), with \(\Pr(b \mid a) = (.27+.18)/.5 = .90\) and \(\Pr(c \mid a) = (.27+.03)/.5 = .60\):
| \(BC\) | \(\Pr(\cdot\mid a)\) | product of the two marginals |
|---|---|---|
| \(b,c\) | \(.54\) | \((.90)(.60) = .54\) |
| \(b,\bar c\) | \(.36\) | \((.90)(.40) = .36\) |
| \(\bar b, c\) | \(.06\) | \((.10)(.60) = .06\) |
| \(\bar b,\bar c\) | \(.04\) | \((.10)(.40) = .04\) |
Conditioning on \(\bar a\) (also \(.50\)), with \(\Pr(b \mid \bar a) = (.02+.03)/.5 = .10\) and \(\Pr(c \mid \bar a) = (.02+.18)/.5 = .40\):
| \(BC\) | \(\Pr(\cdot\mid \bar a)\) | product of the two marginals |
|---|---|---|
| \(b,c\) | \(.04\) | \((.10)(.40) = .04\) |
| \(b,\bar c\) | \(.06\) | \((.10)(.60) = .06\) |
| \(\bar b, c\) | \(.36\) | \((.90)(.40) = .36\) |
| \(\bar b,\bar c\) | \(.54\) | \((.90)(.60) = .54\) |
Every entry of both tables factorizes, so by (3.16) \(I_{\Pr}(B, A, C)\) holds.
(ii) \(A\) and \(B\) are not independent given \(C\). Conditioning on \(c\), with \(\Pr(a \mid c) = (.27+.03)/.5 = .60\) and \(\Pr(b \mid c) = (.27+.02)/.5 = .58\),
\begin{equation*} \Pr(a,b \mid c) = \frac{.27}{.50} = .54 \qquad\text{but}\qquad (.60)(.58) = .348 . \end{equation*}
(iii) \(A\) and \(C\) are not independent given \(B\). Conditioning on \(b\), with \(\Pr(a \mid b) = (.27+.18)/.5 = .90\) and \(\Pr(c \mid b) = (.27+.02)/.5 = .58\),
\begin{equation*} \Pr(a,c \mid b) = \frac{.27}{.50} = .54 \qquad\text{but}\qquad (.90)(.58) = .522 . \end{equation*}
Show the following:
- (a)
- If \(\alpha \models \beta\) and \(\Pr(\beta) = 0\), then \(\Pr(\alpha) = 0\).
- (b)
- \(\Pr(\alpha \wedge \beta) \le \Pr(\alpha) \le \Pr(\alpha \vee \beta)\).
- (c)
- If \(\alpha \models \beta\), then \(\Pr(\alpha) \le \Pr(\beta)\).
- (d)
- If \(\alpha \models \beta \models \gamma\), then \(\Pr(\alpha \mid \beta) \ge \Pr(\alpha \mid \gamma)\).
All four parts follow from monotonicity: if \(\alpha \models \beta\) then \(\Pr(\alpha) \le \Pr(\beta)\). Indeed \(\alpha \models \beta\) says \(\mathrm{Mods}(\alpha) \subseteq \mathrm{Mods}(\beta)\), so splitting the sum (3.1) along that inclusion,
\begin{equation*} \begin{aligned} \Pr(\beta) &\;=\; \Pr(\alpha) + \sum_{\omega \models \beta \wedge \neg\alpha} \Pr(\omega) \;\ge\; \Pr(\alpha), \end{aligned} \end{equation*}
the second term being a sum of nonnegative beliefs. That is (c), with the sharper identity \(\Pr(\beta) - \Pr(\alpha) = \Pr(\beta \wedge \neg\alpha)\).
(a) By (c), \(\Pr(\alpha) \le \Pr(\beta) = 0\), while \(\Pr(\alpha) \ge 0\) by (3.2).
(b) Two applications of (c), to \(\alpha \wedge \beta \models \alpha\) and to \(\alpha \models \alpha \vee \beta\).
(d) Assume \(\Pr(\beta) > 0\), as both conditionals require; \(\beta \models \gamma\) and (c) then give \(\Pr(\gamma) \ge \Pr(\beta) > 0\), so \(\Pr(\alpha \mid \gamma)\) is defined too. From \(\alpha \models \beta\), \(\mathrm{Mods}(\alpha \wedge \beta) = \mathrm{Mods}(\alpha) \cap \mathrm{Mods}(\beta) = \mathrm{Mods}(\alpha)\), i.e. \(\alpha \wedge \beta \equiv \alpha\); transitivity of \(\models\) gives \(\alpha \models \gamma\) and hence \(\alpha \wedge \gamma \equiv \alpha\) as well. So by (3.12),
\begin{equation*} \Pr(\alpha \mid \beta) = \frac{\Pr(\alpha)}{\Pr(\beta)} \;\ge\; \frac{\Pr(\alpha)}{\Pr(\gamma)} = \Pr(\alpha \mid \gamma), \end{equation*}
since \(0 < \Pr(\beta) \le \Pr(\gamma)\) and \(\Pr(\alpha) \ge 0\).
Let \(\alpha\) and \(\beta\) be two propositional sentences over disjoint sets of variables \(\mathbf{X}\) and \(\mathbf{Y}\), respectively. Show that \(\alpha\) and \(\beta\) are independent, that is,
\begin{equation*} \Pr(\alpha \wedge \beta) = \Pr(\alpha)\Pr(\beta), \end{equation*}
if the variable sets \(\mathbf{X}\) and \(\mathbf{Y}\) are independent, that is, \(\Pr(\mathbf{x}, \mathbf{y}) = \Pr(\mathbf{x})\Pr(\mathbf{y})\) for all instantiations \(\mathbf{x}\) of \(\mathbf{X}\) and \(\mathbf{y}\) of \(\mathbf{Y}\).
Group the worlds by their \(\mathbf{X}\)- and \(\mathbf{Y}\)-parts, then apply the hypothesis. As \(\mathbf{X} \cap \mathbf{Y} = \emptyset\), every world splits uniquely as \(\omega = (\mathbf{x},\mathbf{y},\mathbf{z})\) with \(\mathbf{z}\) the instantiation of the remaining variables; and since \(\alpha\) mentions only \(\mathbf{X}\), its truth value at \(\omega\) depends on \(\mathbf{x}\) alone, so \(\omega \models \alpha\) iff \(\mathbf{x} \models \alpha\), and likewise \(\omega \models \beta\) iff \(\mathbf{y} \models \beta\). Hence by (3.1), regrouping finite sums of nonnegative terms so that the omitted variables are summed out into marginals,
\begin{equation*} \begin{aligned} \Pr(\alpha) = \sum_{\mathbf{x} \models \alpha} \Pr(\mathbf{x}), \qquad \Pr(\beta) = \sum_{\mathbf{y} \models \beta} \Pr(\mathbf{y}) . \end{aligned} \end{equation*}
The same regrouping, followed by the hypothesis \(\Pr(\mathbf{x},\mathbf{y}) = \Pr(\mathbf{x})\Pr(\mathbf{y})\), factors the double sum:
\begin{equation*} \begin{aligned} \Pr(\alpha \wedge \beta) &= \sum_{\mathbf{x}\models\alpha}\ \sum_{\mathbf{y}\models\beta} \Pr(\mathbf{x})\Pr(\mathbf{y}) \\ &= \Big(\sum_{\mathbf{x}\models\alpha} \Pr(\mathbf{x})\Big) \Big(\sum_{\mathbf{y}\models\beta} \Pr(\mathbf{y})\Big) \;=\; \Pr(\alpha)\,\Pr(\beta), \end{aligned} \end{equation*}
which is the definition (3.14) of independence of the events. \(\blacksquare\)
The identical regrouping over \(k\) pairwise disjoint blocks \(\mathbf{X}_1,\ldots,\mathbf{X}_k\) whose joint distribution factorizes gives \(\Pr(\alpha_1 \wedge \cdots \wedge \alpha_k) = \prod_i \Pr(\alpha_i)\) for sentences \(\alpha_i\) over \(\mathbf{X}_i\); Exercise 3.12 needs that form at its and-nodes.
Consider a propositional sentence \(\alpha\) that is represented by an NNF circuit that satisfies the properties of decomposability and determinism. (Recall from Section 2.7 that an NNF circuit is a DAG whose leaves are labeled with literals or with the constants true/false and whose internal nodes are and-gates and or-gates; it is decomposable if for every and-node and every pair of its children \(C_1, C_2\) the sentences represented by \(C_1\) and \(C_2\) share no variables, and deterministic if for every or-node and every pair of its children \(C_1, C_2\) the sentences represented by \(C_1\) and \(C_2\) are mutually exclusive.) Suppose the circuit inputs are over variables \(X_1, \ldots, X_n\) and that each variable \(X_i\) is independent of every other set of variables that does not contain \(X_i\). Show that if given the probability distribution \(\Pr(x_i)\) for each variable \(X_i\), the probability of \(\alpha\) can be computed in time linear in the size of the NNF circuit.
Replace each literal input by its probability, each and-gate by multiplication and each or-gate by addition, then evaluate the resulting arithmetic circuit bottom-up with the values cached at the nodes; one pass costs \(O(|\Gamma|)\).
The distribution factorizes. Each \(X_{k+1}\) is independent of \(\{X_1,\ldots,X_k\}\), so the event form (3.14) gives \(\Pr(x_1,\ldots,x_{k+1}) = \Pr(x_{k+1})\Pr(x_1,\ldots,x_k)\), and induction on \(k\) yields
\begin{equation*} \Pr(x_1,\ldots,x_n) = \prod_{i=1}^{n} \Pr(x_i) \end{equation*}
for every instantiation: the \(n\) given marginals specify \(\Pr\) completely. Summing this over the variables outside pairwise disjoint blocks \(\mathbf{Y}_1,\ldots,\mathbf{Y}_k\) shows the marginal factorizes too, so the \(k\)-block form of Exercise 3.11 applies: for sentences \(\alpha_j\) over \(\mathbf{Y}_j\),
\begin{equation*} \Pr(\alpha_1 \wedge \cdots \wedge \alpha_k) = \prod_{j=1}^{k} \Pr(\alpha_j) . \tag{\(\dagger\)} \end{equation*}
The algorithm. In topological order (children before parents) store \(v(N) = \Pr(\ell)\) at a leaf labeled with literal \(\ell\), \(v(N) = 1\) at \(\mathit{true}\) and \(0\) at \(\mathit{false}\), \(v(N) = \prod_j v(C_j)\) at an and-node, and \(v(N) = \sum_j v(C_j)\) at an or-node; output \(v(\mathrm{root})\).
Correctness. \(v(N) = \Pr(\alpha_N)\), by induction along that order. Leaves are immediate, the constants by (3.4) and (3.3). At an and-node, decomposability makes the variable sets \(\mathbf{Y}_j\) of the children pairwise disjoint, so \((\dagger)\) applies and \(\Pr(\alpha_N) = \prod_j \Pr(\alpha_{C_j}) = \prod_j v(C_j)\). At an or-node, determinism makes the \(\mathrm{Mods}(\alpha_{C_j})\) pairwise disjoint with union \(\mathrm{Mods}(\alpha_N)\), so the sum (3.1) splits along that disjoint union:
\begin{equation*} \Pr(\alpha_N) = \sum_{j=1}^{k} \sum_{\omega \models \alpha_{C_j}} \Pr(\omega) = \sum_{j=1}^{k} \Pr(\alpha_{C_j}) = \sum_{j=1}^{k} v(C_j) = v(N) . \end{equation*}
At the root this gives \(\Pr(\alpha)\).
Complexity. Caching means each node is visited once and performs one arithmetic operation per child edge, for a total of \(O(|\mathrm{nodes}(\Gamma)| + |\mathrm{edges}(\Gamma)|) = O(|\Gamma|)\); the topological order costs the same and each lookup \(\Pr(x_i)\) is \(O(1)\). (Without caching, a shared subcircuit would be re-evaluated once per parent, costing the size of the unfolded tree.)
(After Pearl) We have three urns labeled 1, 2, and 3. The urns contain, respectively, three white and three black balls, four white and two black balls, and one white and two black balls. An experiment consists of selecting an urn at random then drawing a ball from it.
- (a)
- Define the set of worlds that correspond to the various outcomes of this experiment. Assume you have two variables \(U\) with values 1, 2, and 3 and \(C\) with values black and white.
- (b)
- Define the joint probability distribution over the set of possible worlds identified in (a).
- (c)
- Find the probability of drawing a black ball.
- (d)
- Find the conditional probability that urn 2 was selected given that a black ball was drawn.
- (e)
- Find the probability of selecting urn 1 or a white ball.
(a) The worlds are the \(3 \times 2 = 6\) instantiations of \(U \in \{1,2,3\}\) and \(C \in \{\mathrm{b}, \mathrm{w}\}\) (black, white):
\begin{equation*} \begin{aligned} \omega_1 &= (U{=}1, C{=}\mathrm{b}), &\quad \omega_2 &= (U{=}1, C{=}\mathrm{w}), \\ \omega_3 &= (U{=}2, C{=}\mathrm{b}), &\quad \omega_4 &= (U{=}2, C{=}\mathrm{w}), \\ \omega_5 &= (U{=}3, C{=}\mathrm{b}), &\quad \omega_6 &= (U{=}3, C{=}\mathrm{w}). \end{aligned} \end{equation*}
(b) “At random” means \(\Pr(U{=}1) = \Pr(U{=}2) = \Pr(U{=}3) = 1/3\), and given the urn the ball is drawn uniformly from its contents:
| urn | white | black | total | \(\Pr(\mathrm{b}\mid U)\) | \(\Pr(\mathrm{w}\mid U)\) |
|---|---|---|---|---|---|
| 1 | 3 | 3 | 6 | \(3/6 = 1/2\) | \(1/2\) |
| 2 | 4 | 2 | 6 | \(2/6 = 1/3\) | \(2/3\) |
| 3 | 1 | 2 | 3 | \(2/3\) | \(1/3\) |
By the chain rule, \(\Pr(u, c) = \Pr(c \mid u)\Pr(u)\), giving the joint distribution:
| world | \(U\) | \(C\) | \(\Pr(.)\) |
|---|---|---|---|
| \(\omega_1\) | 1 | black | \(\tfrac13 \cdot \tfrac12 = \tfrac16\) |
| \(\omega_2\) | 1 | white | \(\tfrac13 \cdot \tfrac12 = \tfrac16\) |
| \(\omega_3\) | 2 | black | \(\tfrac13 \cdot \tfrac13 = \tfrac19\) |
| \(\omega_4\) | 2 | white | \(\tfrac13 \cdot \tfrac23 = \tfrac29\) |
| \(\omega_5\) | 3 | black | \(\tfrac13 \cdot \tfrac23 = \tfrac29\) |
| \(\omega_6\) | 3 | white | \(\tfrac13 \cdot \tfrac13 = \tfrac19\) |
(The six entries sum to \(18/18 = 1\). Check!)
(c) Summing the black worlds by (3.1),
\begin{equation*} \Pr(C{=}\mathrm{b}) = \tfrac16 + \tfrac19 + \tfrac29 = \tfrac{3+2+4}{18} = \tfrac12 . \end{equation*}
(d) By Bayes conditioning (3.12),
\begin{equation*} \Pr(U{=}2 \mid C{=}\mathrm{b}) = \frac{\Pr(U{=}2, C{=}\mathrm{b})}{\Pr(C{=}\mathrm{b})} = \frac{1/9}{1/2} = \frac{2}{9} \approx .2222 . \end{equation*}
(e) For \(\alpha = (U{=}1) \vee (C{=}\mathrm{w})\), inclusion-exclusion (3.6) with \(\Pr(C{=}\mathrm{w}) = 1 - \Pr(C{=}\mathrm{b}) = 1/2\) by (3.5) gives
\begin{equation*} \Pr(\alpha) = \tfrac13 + \tfrac12 - \tfrac16 = \tfrac{2+3-1}{6} = \tfrac{2}{3} . \end{equation*}
Suppose we are presented with two urns labeled 1 and 2 and we want to distribute \(k\) white balls and \(k\) black balls between these urns. In particular, say that we want to pick an \(n\) and \(m\) where we place \(n\) white balls and \(m\) black balls into urn 1 and the remaining \(k - n\) white balls and \(k - m\) black balls into urn 2. Once we distribute the balls to urns, say that we play a game where we pick an urn at random and draw a ball from it.
- (a)
- What is the probability that we draw a white ball for a given \(n\) and \(m\)?
Suppose now that we want to choose \(n\) and \(m\) so that we maximize the probability that we draw a white ball. Clearly, if both urns have an equal number of white and black balls (i.e., \(n = m\)), then the probability that we draw a white ball is \(\tfrac{1}{2}\).
- (b)
- Suppose that \(k = 3\). Can we choose an \(n\) and \(m\) so that we increase the probability of drawing a white ball to \(\tfrac{7}{10}\)?
- (c)
- Can we design a strategy for choosing \(n\) and \(m\) so that as \(k\) tends to infinity, the probability of drawing a white ball tends to \(\tfrac{3}{4}\)?
(a) Writing \(U\) for the urn picked and \(C\) for the color drawn, case analysis (3.18) over \(U\) gives
\begin{equation*} \Pr(C{=}\mathrm{w}) = \frac{1}{2}\cdot\frac{n}{n+m} \;+\; \frac{1}{2}\cdot\frac{k-n}{2k-n-m} , \end{equation*}
valid whenever both urns are nonempty, i.e. \((n,m) \ne (0,0)\) and \((n,m) \ne (k,k)\).
(b) Yes: take \(n = 1\), \(m = 0\), a single white ball alone in urn 1 and the rest (2 white, 3 black) in urn 2. Then
\begin{equation*} \Pr(C{=}\mathrm{w}) = \frac12 \cdot \frac{1}{1} + \frac12 \cdot \frac{2}{5} = \frac12 + \frac15 = \frac{7}{10} . \end{equation*}
(c) Yes: use the same rule \(n = 1\), \(m = 0\) for every \(k\), so that urn 2 holds \(k-1\) white and \(k\) black balls. Then
\begin{equation*} p_k := \Pr(C{=}\mathrm{w}) = \frac12 + \frac{k-1}{2(2k-1)} = \frac{3k-2}{4k-2}, \end{equation*}
and dividing numerator and denominator by \(k\),
\begin{equation*} \lim_{k \to \infty} p_k = \lim_{k\to\infty} \frac{3 - 2/k}{4 - 2/k} = \frac{3}{4} . \end{equation*}
(Consistently \(p_3 = 7/10\), the value found in (b).)
Exercises 3.15–3.21
Prove the equivalence between the two definitions of conditional independence given by Equations 3.15 and 3.16. That is, show that for any events \(\alpha\), \(\beta\), \(\gamma\) and any state of belief \(Pr\), the condition
\begin{equation*} Pr(\alpha \mid \beta \wedge \gamma) = Pr(\alpha \mid \gamma) \quad\text{or}\quad Pr(\beta \wedge \gamma) = 0 \tag{3.15} \end{equation*}
holds if and only if
\begin{equation*} Pr(\alpha \wedge \beta \mid \gamma) = Pr(\alpha \mid \gamma) Pr(\beta \mid \gamma) \quad\text{or}\quad Pr(\gamma) = 0 . \tag{3.16} \end{equation*}
Three exhaustive cases, in each of which (3.15) and (3.16) hold or fail together.
(i) \(Pr(\gamma) = 0\). Then (3.16) holds by its second disjunct; and \(\beta \wedge \gamma \models \gamma\), so monotonicity (Exercise 3.10(c)) gives \(Pr(\beta \wedge \gamma) \le Pr(\gamma) = 0\) and (3.15) holds by its second disjunct.
(ii) \(Pr(\gamma) > 0\) but \(Pr(\beta \wedge \gamma) = 0\). Then (3.15) holds by its second disjunct. For (3.16), \(\alpha \wedge \beta \wedge \gamma \models \beta \wedge \gamma\) forces \(Pr(\alpha \wedge \beta \wedge \gamma) = 0\), so
\begin{equation*} Pr(\alpha \wedge \beta \mid \gamma) = 0 = Pr(\alpha \mid \gamma)\,Pr(\beta \mid \gamma), \end{equation*}
the right-hand side because \(Pr(\beta \mid \gamma) = Pr(\beta \wedge \gamma)/Pr(\gamma) = 0\).
(iii) \(Pr(\beta \wedge \gamma) > 0\). Then \(Pr(\gamma) \ge Pr(\beta \wedge \gamma) > 0\), so both second disjuncts fail and every conditional probability below is defined. The chain rule inside \(\gamma\) is the bridge:
\begin{equation*} \begin{aligned} Pr(\alpha \wedge \beta \mid \gamma) &= \frac{Pr(\alpha \mid \beta \wedge \gamma)\, Pr(\beta \wedge \gamma)}{Pr(\gamma)} \\ &= Pr(\alpha \mid \beta \wedge \gamma)\, Pr(\beta \mid \gamma). \end{aligned} \tag{\(\ast\)} \end{equation*}
Substituting \(Pr(\alpha \mid \beta \wedge \gamma) = Pr(\alpha \mid \gamma)\) into \((\ast)\) turns (3.15) into (3.16); conversely, (3.16) and \((\ast)\) give \(Pr(\alpha \mid \beta \wedge \gamma)Pr(\beta \mid \gamma) = Pr(\alpha \mid \gamma)Pr(\beta \mid \gamma)\), and \(Pr(\beta \mid \gamma) = Pr(\beta \wedge \gamma)/Pr(\gamma) > 0\) cancels, leaving (3.15).
Let \(X\) and \(Y\) be two binary variables, with values written \(x, \bar{x}\) and \(y, \bar{y}\) respectively. Show that \(X\) and \(Y\) are independent if and only if
\begin{equation*} Pr(x, y)\, Pr(\bar{x}, \bar{y}) = Pr(x, \bar{y})\, Pr(\bar{x}, y). \end{equation*}
Abbreviate the joint by \(a = Pr(x,y)\), \(b = Pr(x,\bar{y})\), \(c = Pr(\bar{x},y)\), \(d = Pr(\bar{x},\bar{y})\), so \(a+b+c+d = 1\) and case analysis on the eliminated variable gives
\begin{equation*} \begin{aligned} Pr(x) &= a + b, & Pr(\bar{x}) &= c + d, \\ Pr(y) &= a + c, & Pr(\bar{y}) &= b + d. \end{aligned} \end{equation*}
Independence \(I_{Pr}(X, \emptyset, Y)\) is, by Equation 3.14, the four equations \(Pr(x^{\prime},y^{\prime}) = Pr(x^{\prime})Pr(y^{\prime})\) over \(x^{\prime} \in \{x,\bar{x}\}\), \(y^{\prime} \in \{y,\bar{y}\}\); the claim is that these hold iff \(ad = bc\).
(\(\Rightarrow\)) Independence gives \(a = Pr(x)Pr(y)\), \(b = Pr(x)Pr(\bar{y})\), \(c = Pr(\bar{x})Pr(y)\), \(d = Pr(\bar{x})Pr(\bar{y})\), whence by commutativity
\begin{equation*} ad = Pr(x)Pr(y)Pr(\bar{x})Pr(\bar{y}) = \bigl(Pr(x)Pr(\bar{y})\bigr)\bigl(Pr(\bar{x})Pr(y)\bigr) = bc . \end{equation*}
(\(\Leftarrow\)) Assume \(ad = bc\). Expanding and substituting \(ad\) for \(bc\),
\begin{equation*} \begin{aligned} Pr(x)\,Pr(y) &= (a+b)(a+c) = a^{2} + ac + ab + bc \\ &= a\,(a + b + c + d) = a = Pr(x, y). \end{aligned} \end{equation*}
The other three cells are the same computation with the same substitution: \((a+b)(b+d) = b(a+c+b+d) = b\), \((c+d)(a+c) = c(a+c+b+d) = c\), and \((c+d)(b+d) = d(a+c+b+d) = d\). (Check!) All four product equations hold, so \(X\) and \(Y\) are independent.
Show that \(Pr(\alpha) = O(\alpha)/(1 + O(\alpha))\), where the odds of an event are defined by Equation 3.23,
\begin{equation*} O(\alpha) \;\stackrel{\text{def}}{=}\; \frac{Pr(\alpha)}{Pr(\neg \alpha)} . \end{equation*}
Write \(p = Pr(\alpha)\); Equation 3.23 requires \(Pr(\neg\alpha) = 1 - p \neq 0\), so \(O(\alpha) = p/(1-p)\) is a finite nonnegative number and \(1 + O(\alpha) \neq 0\). Clearing the inner fraction by \(1 - p > 0\),
\begin{equation*} \frac{O(\alpha)}{1 + O(\alpha)} = \frac{p/(1-p)}{\bigl((1-p) + p\bigr)/(1-p)} = \frac{p}{(1-p) + p} = p = Pr(\alpha). \end{equation*}
Show that
\begin{equation*} \frac{O(\alpha \mid \beta)}{O(\alpha)} = \frac{Pr(\beta \mid \alpha)}{Pr(\beta \mid \neg \alpha)} , \end{equation*}
where \(O(\alpha \mid \beta) = Pr(\alpha \mid \beta)/Pr(\neg\alpha \mid \beta)\) is the odds of \(\alpha\) after conditioning on \(\beta\). Note: the quantity \(Pr(\beta \mid \alpha)/Pr(\beta \mid \neg \alpha)\) is called the likelihood ratio.
Rewrite both conditional probabilities in the conditional odds by Bayes rule; assume \(Pr(\beta) > 0\), \(Pr(\alpha) > 0\) and \(Pr(\beta \wedge \neg\alpha) > 0\), which is exactly what makes every quantity in the statement defined and \(O(\alpha)\) positive. Then
\begin{equation*} \begin{aligned} O(\alpha \mid \beta) &= \frac{Pr(\alpha \mid \beta)}{Pr(\neg\alpha \mid \beta)} \\[4pt] &= \frac{Pr(\beta \mid \alpha)\, Pr(\alpha) / Pr(\beta)} {Pr(\beta \mid \neg\alpha)\, Pr(\neg\alpha) / Pr(\beta)} \\[4pt] &= \frac{Pr(\beta \mid \alpha)}{Pr(\beta \mid \neg\alpha)} \cdot \frac{Pr(\alpha)}{Pr(\neg\alpha)} \\[4pt] &= \frac{Pr(\beta \mid \alpha)}{Pr(\beta \mid \neg\alpha)} \cdot O(\alpha), \end{aligned} \end{equation*}
the common factor \(1/Pr(\beta)\) cancelling and the last line using Equation 3.23. Dividing by \(O(\alpha) > 0\) gives the claim.
Show that events \(\alpha\) and \(\beta\) are independent if and only if \(O(\alpha \mid \beta) = O(\alpha \mid \neg \beta)\), where \(O(\alpha \mid \gamma) = Pr(\alpha \mid \gamma)/Pr(\neg\alpha \mid \gamma)\).
Assume \(0 < Pr(\beta) < 1\) and \(Pr(\neg\alpha \mid \beta), Pr(\neg\alpha \mid \neg\beta) > 0\), which is exactly what makes the two conditional odds defined; then the second disjunct of (3.13) is unavailable and independence means \(Pr(\alpha \mid \beta) = Pr(\alpha)\).
(\(\Rightarrow\)) From \(Pr(\alpha \wedge \beta) = Pr(\alpha)Pr(\beta)\) (Equation 3.14) and case analysis on \(\beta\),
\begin{equation*} Pr(\alpha \wedge \neg\beta) = Pr(\alpha) - Pr(\alpha)Pr(\beta) = Pr(\alpha)Pr(\neg\beta), \end{equation*}
so dividing by \(Pr(\neg\beta) > 0\) gives \(Pr(\alpha \mid \neg\beta) = Pr(\alpha) = Pr(\alpha \mid \beta)\). Taking complements within each conditional distribution makes the denominators agree as well, whence
\begin{equation*} O(\alpha \mid \beta) = \frac{Pr(\alpha)}{1 - Pr(\alpha)} = O(\alpha \mid \neg\beta). \end{equation*}
(\(\Leftarrow\)) Let \(t\) be the common value of the two odds. Each of \(Pr(\cdot \mid \beta)\) and \(Pr(\cdot \mid \neg\beta)\) is itself a state of belief, so Exercise 3.17 applies inside each and yields \(Pr(\alpha \mid \beta) = t/(1+t) = Pr(\alpha \mid \neg\beta) =: p\). Case analysis on \(\beta\) together with (3.12) then recovers the prior,
\begin{equation*} Pr(\alpha) = Pr(\alpha \mid \beta)Pr(\beta)
- Pr(\alpha \mid \neg\beta)Pr(\neg\beta) = p , \end{equation*}
so \(Pr(\alpha \mid \beta) = p = Pr(\alpha)\), which is (3.13).
Let \(\alpha\) and \(\beta\) be two events such that \(Pr(\alpha) \neq 0\) and \(Pr(\beta) \neq 1\). Suppose that \(Pr(\alpha \Rightarrow \beta) = 1\). Show that:
- (a)
- Knowing \(\neg\alpha\) will decrease the probability of \(\beta\), that is, \(Pr(\beta \mid \neg\alpha) < Pr(\beta)\).
- (b)
- Knowing \(\beta\) will increase the probability of \(\alpha\), that is, \(Pr(\alpha \mid \beta) > Pr(\alpha)\).
Since \(\neg(\alpha \Rightarrow \beta) = \alpha \wedge \neg\beta\), the hypothesis says \(Pr(\alpha \wedge \neg\beta) = 0\), so case analysis on \(\beta\) gives
\begin{equation*} Pr(\alpha) = Pr(\alpha \wedge \beta) + Pr(\alpha \wedge \neg\beta) = Pr(\alpha \wedge \beta), \tag{1} \end{equation*}
and monotonicity (Exercise 3.10(c)) applied to \(\alpha \wedge \beta \models \beta\) gives
\begin{equation*} 0 < Pr(\alpha) = Pr(\alpha \wedge \beta) \le Pr(\beta) < 1 , \tag{2} \end{equation*}
so \(Pr(\beta) > 0\) and \(Pr(\neg\alpha) > 0\) and both conditionings below are legitimate.
(a) Splitting \(\beta\) on \(\alpha\) and using (1), \(Pr(\neg\alpha \wedge \beta) = Pr(\beta) - Pr(\alpha)\), so dividing by \(Pr(\neg\alpha) = 1 - Pr(\alpha) > 0\),
\begin{equation*} Pr(\beta \mid \neg\alpha) = \frac{Pr(\beta) - Pr(\alpha)}{1 - Pr(\alpha)} < Pr(\beta) , \end{equation*}
the inequality because, multiplied through by \(1 - Pr(\alpha) > 0\), it reduces to \(Pr(\alpha)\bigl(1 - Pr(\beta)\bigr) > 0\), which holds by (2).
(b) By (1) and \(Pr(\beta) < 1\),
\begin{equation*} Pr(\alpha \mid \beta) = \frac{Pr(\alpha \wedge \beta)}{Pr(\beta)} = \frac{Pr(\alpha)}{Pr(\beta)} > Pr(\alpha) . \end{equation*}
Consider Section 3.6.3 and the investigator Rich with his state of belief regarding murder suspects. There is a single variable \(Killer\) with three values, and Rich’s state of belief is:
| world | Killer | Pr(.) |
|---|---|---|
| \(\omega_1\) | david | \(2/3\) |
| \(\omega_2\) | dick | \(1/6\) |
| \(\omega_3\) | jane | \(1/6\) |
Of the three suspects, David and Dick are male and Jane is female, so the event “the killer is male” is \(\omega_1 \vee \omega_2\).
Suppose now that Rich receives some new evidence that triples his odds of the killer being male. What is the new belief of Rich that David is the killer? What would this belief be if after accommodating the evidence, Rich’s belief in the killer being male is \(93.75\%\)?
Both questions have the same answer, \(Pr^{\prime}(Killer = david) = 3/4\).
Write \(\beta\) for \(Killer \in \{david, dick\}\) (“the killer is male”) and \(\alpha\) for \(Killer = david\). From the table \(Pr(\beta) = 2/3 + 1/6 = 5/6\) and \(Pr(\neg\beta) = 1/6\), so \(O(\beta) = 5\) by Equation 3.23; and \(\alpha \models \beta\), so \(Pr(\alpha \wedge \beta) = 2/3\) and \(Pr(\alpha \wedge \neg\beta) = 0\).
Bayes factor \(k = 3\). Equation 3.25 gives directly
\begin{equation*} \begin{aligned} Pr^{\prime}(\alpha) &= \frac{k\,Pr(\alpha \wedge \beta) + Pr(\alpha \wedge \neg\beta)} {k\,Pr(\beta) + Pr(\neg\beta)} \\[4pt] &= \frac{3 \cdot \tfrac{2}{3} + 0}{3 \cdot \tfrac{5}{6} + \tfrac{1}{6}} = \frac{2}{\tfrac{16}{6}} = \frac{3}{4} = 75\% . \end{aligned} \end{equation*}
The same formula, with the same denominator \(16/6\), supplies the rest of the new state of belief:
| world | Killer | Pr(.) | Pr’(.) |
|---|---|---|---|
| \(\omega_1\) | david | \(2/3\) | \(3/4\) |
| \(\omega_2\) | dick | \(1/6\) | \(3/16\) |
| \(\omega_3\) | jane | \(1/6\) | \(1/16\) |
\(Pr^{\prime}(\beta) = 93.75\%\). This is Jeffrey’s rule (Equation 3.21) with \(q = 15/16\), \(Pr(\alpha \mid \beta) = (2/3)/(5/6) = 4/5\) and \(Pr(\alpha \mid \neg\beta) = 0\) (David is male):
\begin{equation*} Pr^{\prime}(\alpha) = \frac{15}{16}\cdot\frac{4}{5} + \frac{1}{16}\cdot 0 = \frac{3}{4} = 75\% . \end{equation*}
The two agree because \(k = 3\) raises \(O(\beta) = 5\) to \(O^{\prime}(\beta) = 15\), i.e. \(Pr^{\prime}(\beta) = 15/16 = 93.75\%\) by Exercise 3.17, so the two specifications describe the same evidence.
Exercises 3.22–3.27
Consider a distribution \(Pr\) over variables \(\mathbf{X} \cup \{S\}\). Let \(U\) be a variable in \(\mathbf{X}\) and suppose that \(S\) is independent of \(\mathbf{X} \setminus \{U\}\) given \(U\). For a given value \(s\) of variable \(S\), suppose that \(Pr(s|u) = \eta f(u)\) for all values \(u\), where \(f\) is some function and \(\eta > 0\) is a constant. Show that \(Pr(\mathbf{x}|s)\) does not depend on the constant \(\eta\). That is, \(Pr(\mathbf{x}|s)\) is the same for any value of \(\eta > 0\) such that \(0 \le \eta f(u) \le 1\).
The independence collapses the likelihood of \(\mathbf{x}\) to \(\eta f(u)\), and the common factor \(\eta\) then cancels against the normalizer. Write \(\mathbf{x} = u\mathbf{z}\) with \(\mathbf{z}\) the restriction of \(\mathbf{x}\) to \(\mathbf{Z} = \mathbf{X} \setminus \{U\}\), let \(P = Pr(\mathbf{X})\) be the marginal (which changing \(\eta\) leaves alone, \(\eta\) affecting only the \(s\)-row of \(Pr(S \mid \mathbf{X})\)), and assume \(Pr(s) > 0\). The hypothesis \(I_{Pr}(S, U, \mathbf{Z})\) is Equation 3.15 at every instantiation with \(Pr(u\mathbf{z}) \ne 0\), that is, \(Pr(s \mid u\mathbf{z}) = Pr(s \mid u)\), so \(Pr(s \mid \mathbf{x}) = \eta f(u)\). By Bayes rule (Equation 3.19) with the denominator expanded by case analysis over the instantiations \(\mathbf{x}^\star\) of \(\mathbf{X}\),
\begin{equation*} \begin{aligned} Pr(\mathbf{x} \mid s) &= \frac{Pr(s \mid \mathbf{x}) \, P(\mathbf{x})} {\sum_{\mathbf{x}^\star} Pr(s \mid \mathbf{x}^\star) \, P(\mathbf{x}^\star)} \\ &= \frac{\eta \, f(u) \, P(\mathbf{x})} {\eta \sum_{\mathbf{x}^\star} f(u^\star) \, P(\mathbf{x}^\star)} = \frac{f(u) \, P(\mathbf{x})}{\sum_{u^\star} f(u^\star) \, P(u^\star)} , \end{aligned} \end{equation*}
where \(u^\star\) is the value \(\mathbf{x}^\star\) assigns to \(U\), the last step collects the \(\mathbf{x}^\star\) by that value, and cancelling \(\eta > 0\) is legitimate because the denominator is \(Pr(s) > 0\). The right-hand side mentions only \(P\) and \(f\), so it is one and the same number for every admissible \(\eta\).
Prove Equation 3.21. That is, let \(Pr\) be a state of belief and let \(\beta\) be an event with \(0 < Pr(\beta) < 1\). Let \(Pr^{\prime}\) be the state of belief that results from accommodating soft evidence on \(\beta\) under the “all things considered” method with \(Pr^{\prime}(\beta) = q\), so that \(Pr^{\prime}\) is defined on worlds by Equation 3.20:
\begin{equation*} Pr^{\prime}(\omega) \;\stackrel{\text{def}}{=}\; \begin{cases} \dfrac{q}{Pr(\beta)}\,Pr(\omega), & \text{if } \omega \models \beta \\[2mm] \dfrac{1-q}{Pr(\neg\beta)}\,Pr(\omega), & \text{if } \omega \models \neg\beta . \end{cases} \end{equation*}
Show that for every event \(\alpha\),
\begin{equation*} Pr^{\prime}(\alpha) = q\,Pr(\alpha|\beta) + (1-q)\,Pr(\alpha|\neg\beta) . \end{equation*}
Every world satisfying \(\alpha\) satisfies exactly one of \(\alpha \wedge \beta\) and \(\alpha \wedge \neg\beta\), so partitioning \(Pr^{\prime}(\alpha) = \sum_{\omega \models \alpha} Pr^{\prime}(\omega)\) (Equation 3.1) accordingly and substituting Equation 3.20 in each part,
\begin{equation*} \begin{aligned} Pr^{\prime}(\alpha) &= \frac{q}{Pr(\beta)} \sum_{\omega \models \alpha \wedge \beta} Pr(\omega)
- \frac{1-q}{Pr(\neg\beta)} \sum_{\omega \models \alpha \wedge \neg\beta} Pr(\omega) \\ &= \frac{q}{Pr(\beta)} \, Pr(\alpha \wedge \beta)
- \frac{1-q}{Pr(\neg\beta)} \, Pr(\alpha \wedge \neg\beta) \\ &= q\,Pr(\alpha|\beta) + (1-q)\,Pr(\alpha|\neg\beta) , \end{aligned} \end{equation*}
the second line by Equation 3.1 again, applied to \(\alpha \wedge \beta\) and \(\alpha \wedge \neg\beta\), and the third by Bayes conditioning (Equation 3.12), both quotients being defined since \(0 < Pr(\beta) < 1\). This is Equation 3.21.
Prove Equations 3.24 and 3.25. That is, recall that the odds of an event \(\beta\) are defined by Equation 3.23 as
\begin{equation*} O(\beta) \;\stackrel{\text{def}}{=}\; \frac{Pr(\beta)}{Pr(\neg\beta)} , \end{equation*}
and that soft evidence on \(\beta\) may be specified by the Bayes factor
\begin{equation*} k = \frac{O^{\prime}(\beta)}{O(\beta)}, \qquad O^{\prime}(\beta) = \frac{Pr^{\prime}(\beta)}{Pr^{\prime}(\neg\beta)} , \end{equation*}
where \(Pr^{\prime}\) is the state of belief after the evidence is accommodated. Assuming \(0 < Pr(\beta) < 1\) and \(k > 0\), show that
\begin{equation*} Pr^{\prime}(\beta) = \frac{k\,Pr(\beta)}{k\,Pr(\beta) + Pr(\neg\beta)} \end{equation*}
(this is Equation 3.24) and that, if \(Pr^{\prime}\) is then obtained from \(Pr\) by Jeffrey’s rule (Equation 3.21) with \(Pr^{\prime}(\beta) = q\) given by 3.24, then for every event \(\alpha\)
\begin{equation*} Pr^{\prime}(\alpha) = \frac{k\,Pr(\alpha \wedge \beta) + Pr(\alpha \wedge \neg\beta)} {k\,Pr(\beta) + Pr(\neg\beta)} , \end{equation*}
which is Equation 3.25.
Equation 3.24. With \(q = Pr^{\prime}(\beta)\) the constraint \(O^{\prime}(\beta) = k\,O(\beta)\) reads \(q/(1-q) = k\,Pr(\beta)/Pr(\neg\beta)\), whose right-hand side is finite because \(Pr(\neg\beta) > 0\); hence \(q \neq 1\) and cross-multiplying is legitimate:
\begin{equation*} q\,Pr(\neg\beta) = k\,Pr(\beta)\,(1-q), \qquad\text{i.e.}\qquad q\,\bigl(k\,Pr(\beta) + Pr(\neg\beta)\bigr) = k\,Pr(\beta) . \end{equation*}
The coefficient is strictly positive (\(k > 0\) and \(0 < Pr(\beta) < 1\)), so dividing by it gives Equation 3.24, and correspondingly
\begin{equation*} 1 - q \;=\; \frac{Pr(\neg\beta)}{k\,Pr(\beta) + Pr(\neg\beta)} . \end{equation*}
Equation 3.25. Abbreviate \(D = k\,Pr(\beta) + Pr(\neg\beta) > 0\). Jeffrey’s rule (Equation 3.21) with these \(q\) and \(1-q\), together with Bayes conditioning (Equation 3.12), gives
\begin{equation*} \begin{aligned} Pr^{\prime}(\alpha) &= q\,Pr(\alpha|\beta) + (1-q)\,Pr(\alpha|\neg\beta) \\ &= \frac{k\,Pr(\beta)}{D} \cdot \frac{Pr(\alpha \wedge \beta)}{Pr(\beta)}
- \frac{Pr(\neg\beta)}{D} \cdot \frac{Pr(\alpha \wedge \neg\beta)}{Pr(\neg\beta)} \\ &= \frac{k\,Pr(\alpha \wedge \beta) + Pr(\alpha \wedge \neg\beta)} {k\,Pr(\beta) + Pr(\neg\beta)} , \end{aligned} \end{equation*}
the cancellations being legitimate because \(Pr(\beta)\) and \(Pr(\neg\beta)\) are nonzero.
For the burglary state of belief of Section 3.6.2,
| world | Alarm | Burglary | \(Pr(.)\) |
|---|---|---|---|
| \(\omega_1\) | true | true | .000095 |
| \(\omega_2\) | true | false | .009999 |
| \(\omega_3\) | false | true | .000005 |
| \(\omega_4\) | false | false | .989901 |
we have \(Pr(Alarm) = .010094\) and \(Pr(\neg Alarm) = .989906\), so \(\alpha : Burglary\), \(\beta : Alarm\) and \(k = 4\) in 3.25 give
\begin{equation*} Pr^{\prime}(Burglary) = \frac{4(.000095) + .000005}{4(.010094) + .989906} = \frac{.000385}{1.030282} \approx 3.74 \times 10^{-4} . \end{equation*}
Suppose we transmit a bit across a noisy channel but for bit \(0\) we send a signal \(-1\) and for bit \(1\) we send a signal \(+1\). Suppose again that Gaussian noise is added to the reading \(y\) from the noisy channel, with densities
\begin{equation*} \begin{aligned} f(y|X = 0) &= \frac{1}{\sqrt{2\pi\sigma^2}}\, e^{-(y+1)^2/2\sigma^2} \\ f(y|X = 1) &= \frac{1}{\sqrt{2\pi\sigma^2}}\, e^{-(y-1)^2/2\sigma^2} . \end{aligned} \end{equation*}
(a) Show that if we treat the reading \(y\) of a continuous variable \(Y\) as soft evidence on \(X = 0\), the corresponding Bayes factor is
\begin{equation*} k = e^{-2y/\sigma^2} . \end{equation*}
(b) Give the corresponding Bayes factors for the following readings \(y\) and standard deviations \(\sigma\):
- (i)
- \(y = +\tfrac{1}{2}\) and \(\sigma = \tfrac{1}{4}\)
- (ii)
- \(y = -\tfrac{1}{2}\) and \(\sigma = \tfrac{1}{4}\)
- (iii)
- \(y = -\tfrac{3}{2}\) and \(\sigma = \tfrac{4}{5}\)
- (iv)
- \(y = +\tfrac{1}{4}\) and \(\sigma = \tfrac{4}{5}\)
- (v)
- \(y = -1\) and \(\sigma = 2\)
(c) What reading \(y\) would result in neutral evidence regardless of the standard deviation? What reading \(y\) would result in a Bayes factor of \(2\) given a standard deviation \(\sigma = 0.2\)?
(a) By Equation 3.28 the Bayes factor of the reading \(y\) as soft evidence on \(X = 0\) is the likelihood ratio \(f(y|X{=}0)/f(y|X{=}1)\). The identical normalizers \(1/\sqrt{2\pi\sigma^2}\) cancel and \(-(y+1)^2 + (y-1)^2 = -4y\), so
\begin{equation*} k = e^{[-(y+1)^2 + (y-1)^2]/2\sigma^2} = e^{-4y/2\sigma^2} = e^{-2y/\sigma^2} . \end{equation*}
(b) Evaluating \(k = e^{-2y/\sigma^2}\) in each case:
| case | \(y\) | \(\sigma\) | exponent \(-2y/\sigma^2\) | \(k\) | \(k\) (numeric) |
|---|---|---|---|---|---|
| (i) | \(+1/2\) | \(1/4\) | \(-16\) | \(e^{-16}\) | \(1.13 \times 10^{-7}\) |
| (ii) | \(-1/2\) | \(1/4\) | \(+16\) | \(e^{16}\) | \(8.89 \times 10^{6}\) |
| (iii) | \(-3/2\) | \(4/5\) | \(+75/16\) | \(e^{75/16}\) | \(108.6\) |
| (iv) | \(+1/4\) | \(4/5\) | \(-25/32\) | \(e^{-25/32}\) | \(0.458\) |
| (v) | \(-1\) | \(2\) | \(+1/2\) | \(\sqrt{e}\) | \(1.649\) |
(c) The reading \(y = 0\), and only that reading, is neutral for every \(\sigma\):
\begin{equation*} e^{-2y/\sigma^2} = 1 \iff -\frac{2y}{\sigma^2} = 0 \iff y = 0 , \end{equation*}
since \(\sigma^2 > 0\). For a Bayes factor of \(2\) with \(\sigma = 0.2\), so \(\sigma^2 = 0.04\),
\begin{equation*} e^{-50y} = 2 \iff -50y = \ln 2 \iff y = -\frac{\ln 2}{50} \approx -0.0139 . \end{equation*}
Prove Equation 3.27. That is, let \(X\) be a binary variable with values \(\{x, \bar{x}\}\) and let \(Y\) be a continuous variable with values \(y \in (-\infty, +\infty)\), where the conditional densities of \(Y\) given the two values of \(X\) are \(f(y|x)\) and \(f(y|\bar{x})\). Show that
\begin{equation*} \frac{Pr(x|y)/Pr(\bar{x}|y)}{Pr(x)/Pr(\bar{x})} \;=\; \frac{f(y|x)}{f(y|\bar{x})} . \end{equation*}
Hint: Show first that \(Pr(x|y)/Pr(x) = f(y|x)/f(y)\), where \(f(y)\) is the PDF for variable \(Y\).
Since \(Y = y\) typically has probability zero, \(Pr(x|y)\) means the limit of conditioning on a shrinking interval, \(Pr(x|y) = \lim_{\Delta \to 0^{+}} Pr(x \mid A_\Delta)\) with \(A_\Delta\) the event \(y \le Y \le y + \Delta\). Assume \(0 < Pr(x) < 1\), that \(f(\cdot|x)\) and \(f(\cdot|\bar{x})\) are continuous at \(y\), and that \(f(y) > 0\) and \(f(y|\bar{x}) > 0\).
Case analysis on \(X\) applied to the event \(Y \le t\) gives \(F(t) = F(t|x)Pr(x) + F(t|\bar{x})Pr(\bar{x})\) for the CDFs, so differentiating (each CDF is the integral of its density, Section 3.7.1),
\begin{equation*} f(t) = f(t|x)\,Pr(x) + f(t|\bar{x})\,Pr(\bar{x}) , \end{equation*}
whence \(f\) is continuous at \(y\) too. Bayes rule (Equation 3.19) applied to the ordinary event \(A_\Delta\) — legitimate for all small \(\Delta > 0\), since \(Pr(A_\Delta) \ge \Delta \cdot \min_{[y,y+\Delta]} f > 0\) by continuity and positivity of \(f\) at \(y\) — gives, after dividing by \(Pr(x) > 0\) and writing each probability as an integral scaled by \(\Delta\),
\begin{equation*} \frac{Pr(x \mid A_\Delta)}{Pr(x)} = \frac{Pr(A_\Delta \mid x)}{Pr(A_\Delta)} = \frac{\frac{1}{\Delta}\int_{y}^{y+\Delta} f(t|x)\,dt} {\frac{1}{\Delta}\int_{y}^{y+\Delta} f(t)\,dt} . \end{equation*}
Each average lies between the minimum and the maximum of a function continuous at \(y\), so it tends to that function’s value at \(y\) as \(\Delta \to 0^{+}\); the quotient therefore tends to \(f(y|x)/f(y)\), and the left side to \(Pr(x|y)/Pr(x)\), which is the hint:
\begin{equation*} \frac{Pr(x|y)}{Pr(x)} = \frac{f(y|x)}{f(y)} . \end{equation*}
The identical argument with \(\bar{x}\) in place of \(x\) gives \(Pr(\bar{x}|y)/Pr(\bar{x}) = f(y|\bar{x})/f(y)\), which is nonzero; dividing the two identities cancels \(f(y)\), and rearranging the four factors on the left,
\begin{equation*} \frac{Pr(x|y)/Pr(x)}{Pr(\bar{x}|y)/Pr(\bar{x})} = \frac{Pr(x|y)\,Pr(\bar{x})}{Pr(\bar{x}|y)\,Pr(x)} = \frac{Pr(x|y)/Pr(\bar{x}|y)}{Pr(x)/Pr(\bar{x})} = \frac{f(y|x)}{f(y|\bar{x})} , \end{equation*}
which is Equation 3.27.
Method (2): apply Bayes rule to \(A_\Delta\) at both values of \(X\) and take the ratio, so that \(Pr(A_\Delta)\) cancels at once:
\begin{equation*} \frac{Pr(x|A_\Delta)}{Pr(\bar{x}|A_\Delta)} = \frac{Pr(A_\Delta|x)\,Pr(x)}{Pr(A_\Delta|\bar{x})\,Pr(\bar{x})} ; \end{equation*}
dividing by \(Pr(x)/Pr(\bar{x})\) and letting \(\Delta \to 0^{+}\) gives 3.27 without the marginal density.
Suppose we have a sensor that bears on event \(\beta\) and has a false positive rate \(f_p\) and a false negative rate \(f_n\). Suppose further that we want a positive reading of this sensor to increase the odds of \(\beta\) by a factor of \(k > 1\) and a negative reading to decrease the odds of \(\beta\) by the same factor \(k\). Prove that these conditions imply that \(f_p = f_n = 1/(k+1)\).
Let \(S\) be the event that the sensor reads positive, so \(f_p = Pr(S|\neg\beta)\) and \(f_n = Pr(\neg S|\beta)\), whence \(Pr(S|\beta) = 1 - f_n\) and \(Pr(\neg S|\neg\beta) = 1 - f_p\) by Equation 3.5; assume \(0 < Pr(\beta) < 1\) and \(0 < f_p < 1\), which is exactly what makes \(O(\beta)\) positive and both Bayes factors finite. Bayes rule (Equation 3.19) applied to numerator and denominator of the posterior odds, with the common factor \(Pr(S)\) cancelling, gives
\begin{equation*} O^{\prime}(\beta) = \frac{Pr(S|\beta)\,Pr(\beta)}{Pr(S|\neg\beta)\,Pr(\neg\beta)} = \frac{1 - f_n}{f_p}\, O(\beta) , \end{equation*}
so \(k^{+} = (1 - f_n)/f_p\); the same computation with \(\neg S\) for \(S\) gives \(k^{-} = f_n/(1 - f_p)\). The two requirements are \(k^{+} = k\) and \(k^{-} = 1/k\) (a decrease by a factor \(k\) divides the odds by \(k\)), that is, clearing the nonzero denominators,
\begin{equation*} 1 - f_n = k\,f_p , \qquad k\,f_n = 1 - f_p . \end{equation*}
Substituting \(f_p = 1 - k f_n\) from the second into the first,
\begin{equation*} 1 - f_n = k\,(1 - k f_n) \iff (k^{2} - 1)\,f_n = k - 1 \iff (k-1)(k+1)\,f_n = k - 1 , \end{equation*}
and \(k > 1\) permits cancelling \(k - 1\), leaving \(f_n = 1/(k+1)\) and hence
\begin{equation*} f_p = 1 - k f_n = 1 - \frac{k}{k+1} = \frac{1}{k+1} = f_n . \end{equation*}
Bayesian Networks
Exercises 4.1–4.7
Consider the Bayesian network of Figure 4.14. Its DAG \(G\) has eight binary variables \(A,B,C,D,E,F,G,H\) and the following edges:
\begin{equation*} A \to C,\quad A \to D,\quad B \to D,\quad B \to E, \end{equation*}
\begin{equation*} C \to F,\quad D \to F,\quad F \to G,\quad F \to H,\quad E \to H. \end{equation*}
So \(A\) and \(B\) are roots; \(C\) has parent \(A\); \(D\) has parents \(A,B\); \(E\) has parent \(B\); \(F\) has parents \(C,D\); \(G\) has parent \(F\); and \(H\) has parents \(E,F\). Some of the CPTs are given:
| \(A\) | \(\Theta_A\) |
|---|---|
| 1 | .2 |
| 0 | .8 |
| \(B\) | \(\Theta_B\) |
|---|---|
| 1 | .7 |
| 0 | .3 |
| \(B\) | \(E\) | \(\Theta_{E\mid B}\) |
|---|---|---|
| 1 | 1 | .1 |
| 1 | 0 | .9 |
| 0 | 1 | .9 |
| 0 | 0 | .1 |
| \(A\) | \(B\) | \(D\) | \(\Theta_{D\mid AB}\) |
|---|---|---|---|
| 1 | 1 | 1 | .5 |
| 1 | 1 | 0 | .5 |
| 1 | 0 | 1 | .6 |
| 1 | 0 | 0 | .4 |
| 0 | 1 | 1 | .1 |
| 0 | 1 | 0 | .9 |
| 0 | 0 | 1 | .8 |
| 0 | 0 | 0 | .2 |
- (a) List the Markovian assumptions asserted by the DAG.
- (b) Express \(\Pr(a,b,c,d,e,f,g,h)\) in terms of network parameters.
- (c) Compute \(\Pr(A=0, B=0)\) and \(\Pr(E=1 \mid A=1)\). Justify your answers.
- (d) True or false? Why?
- \(\mathrm{dsep}(A, BH, E)\)
- \(\mathrm{dsep}(G, D, E)\)
- \(\mathrm{dsep}(AB, F, GH)\)
Part (a). By (4.1), \(\mathrm{Markov}(G)\) has one statement \(I(V, \mathrm{Parents}(V), \mathrm{NonDescendants}(V))\) per variable \(V\); reading the descendants off the DAG, the Markovian assumptions are
\begin{equation*} \begin{aligned} I(A, \emptyset, \{B,E\}), \qquad & I(B, \emptyset, \{A,C\}),\\ I(C, A, \{B,D,E\}), \qquad & I(D, AB, \{C,E\}),\\ I(E, B, \{A,C,D,F,G\}), \qquad & I(F, CD, \{A,B,E\}),\\ I(G, F, \{A,B,C,D,E,H\}), \qquad & I(H, EF, \{A,B,C,D,G\}). \end{aligned} \end{equation*}
Part (b). By the chain rule for Bayesian networks (4.2), each variable contributes exactly one factor, its own parameter given the values its parents receive:
\begin{equation*} \Pr(a,b,c,d,e,f,g,h) = \theta_a\,\theta_b\,\theta_{c\mid a}\,\theta_{d\mid ab}\, \theta_{e\mid b}\,\theta_{f\mid cd}\,\theta_{g\mid f}\,\theta_{h\mid ef}. \end{equation*}
Part (c). Both quantities are decided by independencies the DAG guarantees, so the incomplete parametrization is no obstacle.
\(\Pr(A=0,B=0)\). Since \(I(B, \emptyset, \{A,C\})\) lies in \(\mathrm{Markov}(G)\), decomposition (4.4) yields \(I_{\Pr}(B, \emptyset, A)\) (equivalently, \(A, B\) are distinct roots, so Exercise 4.3 and Theorem 4.2 apply), whence
\begin{equation*} \Pr(A=0, B=0) = \theta_{A=0}\,\theta_{B=0} = (.8)(.3) = .24 . \end{equation*}
\(\Pr(E=1 \mid A=1)\). Here \(\mathrm{dsep}_G(A, \emptyset, E)\) holds: with an empty conditioning set a convergent valve is automatically closed, and each path from \(A\) to \(E\) carries one (the neighbours of \(E\) are only \(B\) and \(H\), so every path ends \(B \to E\) or \(H \leftarrow E\)):
\begin{equation*} \begin{aligned} &A \to D \leftarrow B \to E &&\text{closed at } D,\\ &A \to C \to F \leftarrow D \leftarrow B \to E &&\text{closed at } F,\\ &A \to C \to F \to H \leftarrow E &&\text{closed at } H,\\ &A \to D \to F \to H \leftarrow E &&\text{closed at } H, \end{aligned} \end{equation*}
so every path is blocked. By Theorem 4.2, \(I_{\Pr}(A, \emptyset, E)\), whence
\begin{equation*} \Pr(E=1 \mid A=1) = \Pr(E=1) = \sum_b \theta_{E=1 \mid b}\,\theta_b = (.1)(.7) + (.9)(.3) = .34 . \end{equation*}
Part (d). All three are false; one open path each.
(i) \(\mathrm{dsep}(A, \{B,H\}, E)\): the path \(A \to C \to F \to H \leftarrow E\) is sequential at \(C\) and at \(F\), neither in \(\{B,H\}\), and convergent at \(H \in \{B,H\}\), so every valve is open.
(ii) \(\mathrm{dsep}(G, D, E)\): on the path
\begin{equation*} G \leftarrow F \leftarrow C \leftarrow A \to D \leftarrow B \to E \end{equation*}
the valves are sequential at \(F\) and \(C\), divergent at \(A\) and at \(B\), none of them \(D\), and convergent at the evidence node \(D\) — all open.
(iii) \(\mathrm{dsep}(AB, F, GH)\): the path \(B \to E \to H\) joins \(B \in \{A,B\}\) to \(H \in \{G,H\}\) through its single valve, sequential at \(E \notin \{F\}\), hence open.
Consider the DAG \(G\) in Figure 4.15. It has nine nodes arranged in a \(3 \times 3\) grid, \(A_1 A_2 A_3\) on top, \(B_1 B_2 B_3\) in the middle and \(C_1 C_2 C_3\) at the bottom, with edges
\begin{equation*} \begin{aligned} &A_1 \to A_2, && A_2 \to A_3, && A_1 \to B_2, && A_2 \to B_3,\\ &B_1 \to B_2, && B_2 \to B_3, && B_1 \to C_2, && B_2 \to C_3,\\ &C_1 \to C_2, && C_2 \to C_3. &&&& \end{aligned} \end{equation*}
Equivalently, the parent sets are \(\mathrm{Parents}(A_1) = \mathrm{Parents}(B_1) = \mathrm{Parents}(C_1) = \emptyset\), \(\mathrm{Parents}(A_2) = \{A_1\}\), \(\mathrm{Parents}(B_2) = \{A_1, B_1\}\), \(\mathrm{Parents}(C_2) = \{B_1, C_1\}\), \(\mathrm{Parents}(A_3) = \{A_2\}\), \(\mathrm{Parents}(B_3) = \{A_2, B_2\}\), \(\mathrm{Parents}(C_3) = \{B_2, C_2\}\).
Determine if any of \(\mathrm{dsep}_G(A_i, \emptyset, B_i)\), \(\mathrm{dsep}_G(A_i, \emptyset, C_i)\), or \(\mathrm{dsep}_G(B_i, \emptyset, C_i)\) hold for \(i = 1, 2, 3\).
With an empty conditioning set every convergent valve is closed and every sequential or divergent valve open, so an unblocked path is exactly one that climbs from one endpoint to some node \(W\) and descends to the other. Hence
\begin{equation*} \mathrm{dsep}_G(X, \emptyset, Y) \ \text{fails} \iff \mathrm{Anc}(X) \cap \mathrm{Anc}(Y) \neq \emptyset, \end{equation*}
where \(\mathrm{Anc}(V)\) is \(V\) together with its ancestors. (Left to right, the turning point \(W\) is a common ancestor. Right to left, pick a common ancestor \(W\) minimising the total length of shortest directed paths \(W \to \cdots \to X\) and \(W \to \cdots \to Y\); these share no node but \(W\), since a shared node would be a common ancestor with a smaller total, so splicing them gives a path all of whose valves are sequential or divergent.)
The ancestral sets in this DAG are
\begin{equation*} \begin{aligned} &\mathrm{Anc}(A_1) = \{A_1\}, && \mathrm{Anc}(B_1) = \{B_1\},\\ &\mathrm{Anc}(C_1) = \{C_1\}, && \mathrm{Anc}(A_2) = \{A_1, A_2\},\\ &\mathrm{Anc}(B_2) = \{A_1, B_1, B_2\}, && \mathrm{Anc}(C_2) = \{B_1, C_1, C_2\},\\ &\mathrm{Anc}(A_3) = \{A_1, A_2, A_3\},\\ &\mathrm{Anc}(B_3) = \{A_1, A_2, B_1, B_2, B_3\},\\ &\mathrm{Anc}(C_3) = \{A_1, B_1, B_2, C_1, C_2, C_3\}. \end{aligned} \end{equation*}
Case \(i = 1\). All three hold: \(A_1, B_1, C_1\) are roots, so their ancestral sets are the pairwise disjoint singletons \(\{A_1\}, \{B_1\}, \{C_1\}\) (also immediate from Exercise 4.3).
Case \(i = 2\). \(\mathrm{dsep}_G(A_2, \emptyset, B_2)\) fails: \(A_1\) is a common ancestor, witnessing the unblocked path \(A_2 \leftarrow A_1 \to B_2\), divergent at \(A_1\). Likewise \(\mathrm{dsep}_G(B_2, \emptyset, C_2)\) fails on the common ancestor \(B_1\) and the path \(B_2 \leftarrow B_1 \to C_2\). But \(\mathrm{dsep}_G(A_2, \emptyset, C_2)\) holds, since \(\mathrm{Anc}(A_2) = \{A_1, A_2\}\) and \(\mathrm{Anc}(C_2) = \{B_1, C_1, C_2\}\) are disjoint; explicitly, each of the paths
\begin{equation*} \begin{aligned} &A_2 \leftarrow A_1 \to B_2 \leftarrow B_1 \to C_2 &&\text{closed at } B_2,\\ &A_2 \leftarrow A_1 \to B_2 \to C_3 \leftarrow C_2 &&\text{closed at } C_3,\\ &A_2 \to B_3 \leftarrow B_2 \leftarrow B_1 \to C_2 &&\text{closed at } B_3,\\ &A_2 \to B_3 \leftarrow B_2 \to C_3 \leftarrow C_2 &&\text{closed at } B_3, \end{aligned} \end{equation*}
contains a convergent valve, which is closed given \(\emptyset\).
Case \(i = 3\). All three fail, on the common ancestors \(A_2\), \(A_1\) and \(B_2\) respectively, which give the unblocked paths
\begin{equation*} \begin{aligned} &A_3 \leftarrow A_2 \to B_3, \\ &A_3 \leftarrow A_2 \leftarrow A_1 \to B_2 \to C_3, \\ &B_3 \leftarrow B_2 \to C_3, \end{aligned} \end{equation*}
whose valves are all sequential or divergent, hence open.
Summary. Of the nine statements exactly four hold: all three at \(i = 1\), plus \(\mathrm{dsep}_G(A_2, \emptyset, C_2)\).
Show that every root variable \(X\) in a DAG \(G\) is d-separated from every other root variable \(Y\). (A root variable is one with no parents; the claim is that \(\mathrm{dsep}_G(X, \emptyset, Y)\) holds.)
Every path between two distinct roots contains a convergent valve, which is closed given \(\emptyset\). Let
\begin{equation*} \pi:\ X = N_0 - N_1 - \cdots - N_k = Y \end{equation*}
be any path between roots \(X \neq Y\), and let \(d_j \in \{\rightarrow, \leftarrow\}\) record the orientation of the \(j\)-th edge as traversed from \(N_0\). Then \(k \ge 2\): \(k \ge 1\) as \(X \neq Y\), and \(k = 1\) would make one root a parent of the other. Moreover \(d_1 = \rightarrow\) and \(d_k = \leftarrow\), since no edge points into a root. Take the smallest \(i\) with \(d_{i+1} = \leftarrow\), well defined because \(d_k = \leftarrow\); then \(d_i = \rightarrow\) by minimality (for \(i = 1\) this is \(d_1\)), so \(\pi\) contains
\begin{equation*} N_{i-1} \to N_i \leftarrow N_{i+1}, \end{equation*}
a convergent valve at \(N_i\), closed by Definition 4.2 because \(\mathbf{Z} = \emptyset\) contains neither \(N_i\) nor any of its descendants. Hence every path is blocked and \(\mathrm{dsep}_G(X, \emptyset, Y)\).
Consider a Bayesian network over variables \(\mathbf{X}, S\) that induces a distribution \(\Pr\). Suppose that \(S\) is a leaf node in the network that has a single parent \(U \in \mathbf{X}\). For a given value \(s\) of variable \(S\), show that \(\Pr(\mathbf{x} \mid s)\) does not change if we change the CPT of variable \(S\) as follows:
\begin{equation*} \theta^{\prime}_{s \mid u} = \eta\, \theta_{s \mid u} \end{equation*}
for all \(u\) and some constant \(\eta > 0\).
Because \(S\) is a leaf it belongs to no family but its own, so its parameter factors out of the chain rule (4.2) and the rescaling becomes a common factor. Write \(u(\mathbf{x})\) for the value \(\mathbf{x}\) assigns to \(U\) and
\begin{equation*} f(\mathbf{x}) \;=\; \prod_{X \in \mathbf{X}} \theta_{x \mid \mathbf{u}_X} \end{equation*}
for the product of the parameters contributed by the families of \(\mathbf{X}\), none of which mentions \(S\). Then (4.2) gives
\begin{equation*} \Pr(\mathbf{x}, s) = \theta_{s \mid u(\mathbf{x})}\, f(\mathbf{x}), \qquad \Pr^{\prime}(\mathbf{x}, s) = \eta\, \theta_{s \mid u(\mathbf{x})}\, f(\mathbf{x}) = \eta\, \Pr(\mathbf{x}, s), \end{equation*}
with the same constant \(\eta\) for every \(\mathbf{x}\), precisely because \(\eta\) does not depend on \(u\). (Only the \(s\)-row of \(\Theta_{S \mid U}\) is constrained; the other rows may be set to restore normalisation, and the argument never touches them.) Summing over the instantiations \(\mathbf{x}\) gives \(\Pr^{\prime}(s) = \eta\,\Pr(s)\), so assuming \(\Pr(s) > 0\) — needed for \(\Pr(\mathbf{x} \mid s)\) to be defined, and giving \(\Pr^{\prime}(s) > 0\) since \(\eta > 0\) —
\begin{equation*} \Pr^{\prime}(\mathbf{x} \mid s) = \frac{\eta\, \Pr(\mathbf{x}, s)}{\eta\, \Pr(s)} = \Pr(\mathbf{x} \mid s). \end{equation*}
Consider the distribution \(\Pr\) defined by Equation 4.2 and DAG \(G\). That is, \(G\) is a DAG over variables \(\mathbf{Z}\), each variable \(X\) with parents \(\mathbf{U}\) carries a CPT \(\Theta_{X \mid \mathbf{U}}\) with entries \(\theta_{x \mid \mathbf{u}} \ge 0\) satisfying \(\sum_x \theta_{x \mid \mathbf{u}} = 1\) for every parent instantiation \(\mathbf{u}\), and
\begin{equation*} \Pr(\mathbf{z}) \;\overset{\text{def}}{=} \prod_{\theta_{x \mid \mathbf{u}} \sim \mathbf{z}} \theta_{x \mid \mathbf{u}} . \end{equation*}
Show the following:
- (a) \(\sum_{\mathbf{z}} \Pr(\mathbf{z}) = 1\).
- (b) \(\Pr\) satisfies the independencies in \(\mathrm{Markov}(G)\).
- (c) \(\Pr(x \mid \mathbf{u}) = \theta_{x \mid \mathbf{u}}\) for every value \(x\) of variable \(X\) and every instantiation \(\mathbf{u}\) of its parents \(\mathbf{U}\).
Everything follows from one lemma about prefixes of a topological order. Fix a topological ordering \(X_1, \ldots, X_n\) of \(\mathbf{Z}\) (it exists since \(G\) is acyclic), so the parents \(\mathbf{U}_i\) of \(X_i\) occur among \(X_1, \ldots, X_{i-1}\); let \(\mathbf{u}_i\) be the value an instantiation assigns to \(\mathbf{U}_i\). Each variable contributes exactly one compatible parameter, so (4.2) reads
\begin{equation*} \Pr(x_1, \ldots, x_n) = \prod_{i=1}^{n} \theta_{x_i \mid \mathbf{u}_i}. \qquad (\ast) \end{equation*}
Lemma. For every \(0 \le k \le n\) and every instantiation \(x_1 \cdots x_k\),
\begin{equation*} \Pr(x_1, \ldots, x_k) = \sum_{x_{k+1}, \ldots, x_n} \Pr(x_1, \ldots, x_n) = \prod_{i=1}^{k} \theta_{x_i \mid \mathbf{u}_i}. \qquad (\dagger) \end{equation*}
Downward induction on \(k\): at \(k = n\) this is \((\ast)\), and summing \((\dagger)\) at \(k+1\) over the values of \(X_{k+1}\) factors out \(\prod_{i \le k} \theta_{x_i \mid \mathbf{u}_i}\) — legitimately, since \(\mathbf{U}_{k+1} \subseteq \{X_1, \ldots, X_k\}\) makes \(\mathbf{u}_{k+1}\) a function of \(x_1 \cdots x_k\) alone — and leaves \(\sum_{x} \theta_{x \mid \mathbf{u}_{k+1}} = 1\) by Definition 4.1.
Part (a). Take \(k = 0\): the empty product is \(1\), so \(\sum_{\mathbf{z}} \Pr(\mathbf{z}) = 1\); and \(\Pr(\mathbf{z}) \ge 0\) since every parameter is nonnegative.
Part (c). For \(X = X_i\) with parents \(\mathbf{U}\), applying \((\dagger)\) at \(k = i\) and at \(k = i-1\) gives, for every \(x_1 \cdots x_{i-1}\) assigning \(\mathbf{u}\) to \(\mathbf{U}\),
\begin{equation*} \Pr(x_1, \ldots, x_{i-1}, x) = \Pr(x_1, \ldots, x_{i-1})\, \theta_{x \mid \mathbf{u}}, \end{equation*}
the factor \(\theta_{x \mid \mathbf{u}}\) depending on \(x_1 \cdots x_{i-1}\) only through \(\mathbf{u}\). Summing over the instantiations \(\mathbf{v}\) of \(\mathbf{V} = \{X_1, \ldots, X_{i-1}\} \setminus \mathbf{U}\),
\begin{equation*} \Pr(x, \mathbf{u}) = \theta_{x \mid \mathbf{u}} \sum_{\mathbf{v}} \Pr(\mathbf{v}, \mathbf{u}) = \theta_{x \mid \mathbf{u}}\, \Pr(\mathbf{u}), \end{equation*}
so \(\Pr(x \mid \mathbf{u}) = \theta_{x \mid \mathbf{u}}\) whenever \(\Pr(\mathbf{u}) > 0\) (otherwise the claim is vacuous).
Part (b). The lemma holds for every topological order, so choose one adapted to \(X\). Put \(\mathbf{D} = \{X\} \cup \mathrm{Descendants}(X)\), so that \(\mathbf{Z} \setminus \mathbf{D} = \mathbf{U} \cup \mathbf{N}\) with \(\mathbf{N} = \mathrm{NonDescendants}(X)\); this set is closed under parents, since a parent in \(\mathbf{D}\) would make its child a descendant of \(X\). Hence listing \(\mathbf{Z} \setminus \mathbf{D}\) first, then \(X\), then \(\mathbf{D} \setminus \{X\}\), each block in a topological order of the sub-DAG it induces, is a topological order of \(G\). With it \(X = X_i\) and \(\{X_1, \ldots, X_{i-1}\} = \mathbf{U} \cup \mathbf{N}\), so \((\dagger)\) at \(k = i\) and \(k = i-1\) gives
\begin{equation*} \Pr(x, \mathbf{u}, \mathbf{n}) = \Pr(\mathbf{u}, \mathbf{n})\, \theta_{x \mid \mathbf{u}} . \end{equation*}
When \(\Pr(\mathbf{u}, \mathbf{n}) > 0\), dividing gives \(\Pr(x \mid \mathbf{u}, \mathbf{n}) = \theta_{x \mid \mathbf{u}}\), and \(\Pr(\mathbf{u}) \ge \Pr(\mathbf{u}, \mathbf{n}) > 0\) lets part (c) rewrite the right-hand side as \(\Pr(x \mid \mathbf{u})\); the instantiations with \(\Pr(\mathbf{u}, \mathbf{n}) = 0\) are excused by the definition of \(I_{\Pr}\) in Section 4.4. Hence \(I_{\Pr}(X, \mathbf{U}, \mathbf{N})\) for every \(X\), which is \(\mathrm{Markov}(G)\).
Use the graphoid axioms to prove \(\mathrm{dsep}_G(S_1, S_2, \{S_3, \ldots, S_n\})\) in the DAG \(G\) of Figure 4.11. Assume that you are given the Markovian assumptions for DAG \(G\).
Figure 4.11 is the hidden Markov model structure: it has state variables \(S_1, S_2, \ldots, S_n\) forming a chain
\begin{equation*} S_1 \to S_2 \to S_3 \to \cdots \to S_n, \end{equation*}
together with an observation variable \(O_i\) for each \(i\), with the single edge \(S_i \to O_i\). Thus \(\mathrm{Parents}(S_1) = \emptyset\), \(\mathrm{Parents}(S_i) = \{S_{i-1}\}\) for \(i \ge 2\), and \(\mathrm{Parents}(O_i) = \{S_i\}\) for all \(i\). Assume \(n \ge 3\).
Induct on \(k\) to get \((\mathrm{C}_k) = I(S_1, S_2, \{S_3, \ldots, S_k\})\) for \(3 \le k \le n\); at \(k = n\) this is the independence that \(\mathrm{dsep}_G(S_1, S_2, \{S_3, \ldots, S_n\})\) asserts.
The descendants of \(S_i\) are \(S_{i+1}, \ldots, S_n\) and \(O_i, \ldots, O_n\), so for \(i \ge 2\) the set \(\mathrm{Markov}(G)\) contains \(I(S_i, S_{i-1}, \{S_1, \ldots, S_{i-2}\} \cup \{O_1, \ldots, O_{i-1}\})\), and decomposition (4.4) discards the observation variables, leaving
\begin{equation*} I\bigl(S_i,\ S_{i-1},\ \{S_1, \ldots, S_{i-2}\}\bigr). \qquad (\mathrm{N}_i) \end{equation*}
Base \(k = 3\): \((\mathrm{N}_3)\) is \(I(S_3, S_2, \{S_1\})\), so symmetry (4.3) gives \((\mathrm{C}_3)\).
Step: let \(3 \le k < n\) and assume \((\mathrm{C}_k)\). Weak union (4.7) applied to \((\mathrm{N}_{k+1})\) with \(\mathbf{Z} = \{S_k\}\), \(\mathbf{Y} = \{S_2, \ldots, S_{k-1}\}\), \(\mathbf{W} = \{S_1\}\), followed by symmetry (4.3), yields
\begin{equation*} I\bigl(S_1,\ \{S_2, \ldots, S_k\},\ S_{k+1}\bigr). \end{equation*}
Contraction (4.9) on \((\mathrm{C}_k)\) and this statement, with \(\mathbf{Z} = \{S_2\}\), \(\mathbf{Y} = \{S_3, \ldots, S_k\}\) (so \(\mathbf{Z} \cup \mathbf{Y} = \{S_2, \ldots, S_k\}\)) and \(\mathbf{W} = \{S_{k+1}\}\), gives \((\mathrm{C}_{k+1})\).
Show that \(\mathrm{dsep}_G(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) can be decided in time and space that are linear in the size of DAG \(G\) based on Theorem 4.1.
Recall Theorem 4.1: testing whether \(\mathbf{X}\) and \(\mathbf{Y}\) are d-separated by \(\mathbf{Z}\) in DAG \(G\) is equivalent to testing whether \(\mathbf{X}\) and \(\mathbf{Y}\) are disconnected in the DAG \(G^{\prime}\) obtained by pruning \(G\) as follows: repeatedly delete any leaf node \(W\) that does not belong to \(\mathbf{X} \cup \mathbf{Y} \cup \mathbf{Z}\), until no more nodes can be deleted; then delete all edges outgoing from nodes in \(\mathbf{Z}\). The connectivity test on \(G^{\prime}\) ignores edge directions.
Store \(G\), with \(n\) nodes and \(e\) edges, in adjacency-list form with each node holding its child list and its parent list (either is computable from the other in \(O(n+e)\)); the three steps below run in \(O(n+e)\) time and \(O(n)\) auxiliary space, which is linear in the size \(\Theta(n+e)\) of \(G\).
Preprocessing, \(O(n+e)\): boolean arrays \(\mathrm{marked}\) (true exactly on \(\mathbf{X} \cup \mathbf{Y} \cup \mathbf{Z}\)), \(\mathrm{inZ}\), \(\mathrm{inY}\), \(\mathrm{deleted}\) (initially false), and an integer array \(\mathrm{outdeg}[V]\) holding the number of children of \(V\).
Step 1, prune leaves to a fixed point. A node is a leaf of the current graph iff \(\mathrm{outdeg} = 0\). Initialise a work list \(Q\) with every unmarked node of out-degree \(0\); while \(Q\) is nonempty, pop an undeleted \(W\), set \(\mathrm{deleted}[W]\), and for each undeleted parent \(P\) of \(W\) decrement \(\mathrm{outdeg}[P]\), pushing \(P\) if that makes it an unmarked leaf. Since \(\mathrm{outdeg}[V]\) is invariantly the number of undeleted children of \(V\), a node enters \(Q\) exactly when it first becomes an unmarked leaf, so the loop halts precisely at the fixed point Theorem 4.1 demands; out-degrees only decrease, so each node is pushed once and each parent list scanned once, giving \(O(n+e)\).
Step 2, delete the edges outgoing from \(\mathbf{Z}\): no change to the data structure is needed. Declare an edge \(P \to C\) usable iff neither endpoint is deleted and \(\mathrm{inZ}[P] = \mathbf{false}\), and let Step 3 cross usable edges in either direction. The test must be on the tail \(P\) even when the search sits at \(C\), since deleting \(P \to C\) makes it unusable both ways: in \(A \to P \to C\) with \(\mathbf{Z} = \{P\}\), \(\mathbf{X} = \{C\}\), \(\mathbf{Y} = \{A\}\), the graph \(G^{\prime}\) isolates \(C\), so \(\mathrm{dsep}_G(C, P, A)\) holds, whereas a search climbing from \(C\) to its parent \(P\) would report the opposite. Each test is \(O(1)\).
Step 3, undirected connectivity. Breadth-first search on \(G^{\prime}\) ignoring edge directions, seeded with all undeleted nodes of \(\mathbf{X}\): pop \(V\), report that \(\mathrm{dsep}_G(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) fails if \(\mathrm{inY}[V]\), otherwise enqueue every unvisited undeleted neighbour reachable under the Step 2 rule; report that it holds if the queue empties first. Each node is visited once and each adjacency list scanned once, so this is \(O(n+e)\) time and \(O(n)\) space.
Steps 1 and 2 realise exactly the two pruning rules of Theorem 4.1, and no node of \(\mathbf{X} \cup \mathbf{Y} \cup \mathbf{Z}\) is ever deleted, so the search reaches \(\mathbf{Y}\) iff \(\mathbf{X}\) and \(\mathbf{Y}\) are connected in \(G^{\prime}\), which by Theorem 4.1 is iff d-separation fails.
Exercises 4.8–4.14
Show that the graphoid axioms imply the chain rule
\begin{equation*} I(\mathbf{X}, \mathbf{Y}, \mathbf{Z}) \ \text{and}\ I(\mathbf{X} \cup \mathbf{Y}, \mathbf{Z}, \mathbf{W}) \ \text{only if}\ I(\mathbf{X}, \mathbf{Y}, \mathbf{W}), \end{equation*}
where \(\mathbf{X}, \mathbf{Y}, \mathbf{Z}, \mathbf{W}\) are pairwise disjoint sets of variables and \(I(\mathbf{A}, \mathbf{B}, \mathbf{C})\) asserts that \(\mathbf{A}\) and \(\mathbf{C}\) are independent given \(\mathbf{B}\).
Symmetry (4.3), weak union (4.7), contraction (4.9) and decomposition (4.4), in that order. Write (1) for \(I(\mathbf{X}, \mathbf{Y}, \mathbf{Z})\) and (2) for \(I(\mathbf{X} \cup \mathbf{Y}, \mathbf{Z}, \mathbf{W})\).
Symmetry turns (2) into \(I(\mathbf{W}, \mathbf{Z}, \mathbf{X} \cup \mathbf{Y})\); weak union, \(I(\mathbf{A}, \mathbf{S}, \mathbf{B} \cup \mathbf{C}) \Rightarrow I(\mathbf{A}, \mathbf{S} \cup \mathbf{B}, \mathbf{C})\) with \(\mathbf{B} = \mathbf{Y}\), \(\mathbf{C} = \mathbf{X}\), gives \(I(\mathbf{W}, \mathbf{Z} \cup \mathbf{Y}, \mathbf{X})\); and symmetry again
\begin{equation*} (3)\quad I(\mathbf{X}, \mathbf{Y} \cup \mathbf{Z}, \mathbf{W}). \end{equation*}
Contraction, \(I(\mathbf{A}, \mathbf{S}, \mathbf{B})\) and \(I(\mathbf{A}, \mathbf{S} \cup \mathbf{B}, \mathbf{C})\) only if \(I(\mathbf{A}, \mathbf{S}, \mathbf{B} \cup \mathbf{C})\), has (1) and (3) as its two premises under \(\mathbf{S} = \mathbf{Y}\), \(\mathbf{B} = \mathbf{Z}\), \(\mathbf{C} = \mathbf{W}\), so it yields \(I(\mathbf{X}, \mathbf{Y}, \mathbf{Z} \cup \mathbf{W})\); decomposition then drops \(\mathbf{Z}\), leaving
\begin{equation*} I(\mathbf{X}, \mathbf{Y}, \mathbf{W}). \end{equation*}
Every set operation is legitimate because the premises force \(\mathbf{X}, \mathbf{Y}, \mathbf{Z}, \mathbf{W}\) to be pairwise disjoint, the three arguments of an independence statement being disjoint.
Prove that the graphoid axioms hold for probability distributions, and that the intersection axiom holds for strictly positive distributions. That is, for a distribution \(\Pr\) and pairwise disjoint sets of variables \(\mathbf{X}, \mathbf{Y}, \mathbf{Z}, \mathbf{W}\), prove
- triviality: \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \emptyset)\);
- symmetry: \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) if and only if \(I_{\Pr}(\mathbf{Y}, \mathbf{Z}, \mathbf{X})\);
- decomposition: \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y} \cup \mathbf{W})\) only if \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) and \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{W})\);
- weak union: \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y} \cup \mathbf{W})\) only if \(I_{\Pr}(\mathbf{X}, \mathbf{Z} \cup \mathbf{Y}, \mathbf{W})\);
- contraction: \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) and \(I_{\Pr}(\mathbf{X}, \mathbf{Z} \cup \mathbf{Y}, \mathbf{W})\) only if \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y} \cup \mathbf{W})\);
- intersection: \(I_{\Pr}(\mathbf{X}, \mathbf{Z} \cup \mathbf{W}, \mathbf{Y})\) and \(I_{\Pr}(\mathbf{X}, \mathbf{Z} \cup \mathbf{Y}, \mathbf{W})\) only if \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y} \cup \mathbf{W})\), whenever \(\Pr\) is strictly positive.
Recall from Section 4.4 that \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) means \(\Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{y}) = \Pr(\mathbf{x} \mid \mathbf{z})\) or \(\Pr(\mathbf{y}, \mathbf{z}) = 0\), for all instantiations \(\mathbf{x}, \mathbf{y}, \mathbf{z}\).
Two reformulations of the definition do all the work; throughout, \(\mathbf{x}, \mathbf{y}, \mathbf{z}, \mathbf{w}\) range over instantiations and \(\Pr\) of a partial instantiation is the corresponding marginal.
Lemma A (product form). \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) iff
\begin{equation*} \Pr(\mathbf{x}, \mathbf{y}, \mathbf{z}) \, \Pr(\mathbf{z}) = \Pr(\mathbf{x}, \mathbf{z}) \, \Pr(\mathbf{y}, \mathbf{z}) \quad \text{for all } \mathbf{x}, \mathbf{y}, \mathbf{z}. \tag{A} \end{equation*}
Indeed, if \(\Pr(\mathbf{y}, \mathbf{z}) = 0\) then \(\Pr(\mathbf{x}, \mathbf{y}, \mathbf{z}) = 0\) too and both sides of (A) vanish; otherwise \(\Pr(\mathbf{z}) > 0\) and (A) is the defining equation multiplied by \(\Pr(\mathbf{y}, \mathbf{z})\Pr(\mathbf{z})\), a reversible step.
Lemma B (factorization). \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) iff there are nonnegative \(f, g\) with
\begin{equation*} \Pr(\mathbf{x}, \mathbf{y}, \mathbf{z}) = f(\mathbf{x}, \mathbf{z}) \, g(\mathbf{y}, \mathbf{z}) \quad \text{for all } \mathbf{x}, \mathbf{y}, \mathbf{z}. \tag{B} \end{equation*}
(\(\Rightarrow\)) Take \(f = \Pr(\mathbf{x}, \mathbf{z})\) and \(g = \Pr(\mathbf{y}, \mathbf{z})/\Pr(\mathbf{z})\) when \(\Pr(\mathbf{z}) > 0\), \(g = 0\) otherwise; then (A) gives \(fg = \Pr(\mathbf{x}, \mathbf{y}, \mathbf{z})\) in the first case, and both sides vanish in the second. (\(\Leftarrow\)) With \(F(\mathbf{z}) = \sum_{\mathbf{x}} f\) and \(G(\mathbf{z}) = \sum_{\mathbf{y}} g\), summing (B) gives \(\Pr(\mathbf{x}, \mathbf{z}) = fG\), \(\Pr(\mathbf{y}, \mathbf{z}) = Fg\) and \(\Pr(\mathbf{z}) = FG\), whence
\begin{equation*} \Pr(\mathbf{x}, \mathbf{z}) \Pr(\mathbf{y}, \mathbf{z}) = f g F G = \Pr(\mathbf{x}, \mathbf{y}, \mathbf{z}) \Pr(\mathbf{z}), \end{equation*}
which is (A).
Triviality. For \(\mathbf{Y} = \emptyset\) the single empty instantiation gives \(\Pr(\mathbf{x}, \mathbf{z}) = \Pr(\mathbf{x}, \mathbf{z}) \cdot 1\), which is (B) with \(g \equiv 1\).
Symmetry. Condition (A) is unchanged when \(\mathbf{X}\) and \(\mathbf{Y}\) are interchanged.
Decomposition. By Lemma B the premise is \(\Pr(\mathbf{x}, \mathbf{y}, \mathbf{w}, \mathbf{z}) = f(\mathbf{x}, \mathbf{z}) g(\mathbf{y}, \mathbf{w}, \mathbf{z})\); summing over \(\mathbf{w}\) leaves \(f(\mathbf{x}, \mathbf{z})\, g^{\prime}(\mathbf{y}, \mathbf{z})\), again of the form (B), so \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\); summing over \(\mathbf{y}\) instead gives \(I_{\Pr}(\mathbf{X}, \mathbf{Z}, \mathbf{W})\).
Weak union. In that same factorization read \(\mathbf{z}\mathbf{y}\) as one instantiation of \(\mathbf{Z} \cup \mathbf{Y}\) and set \(f^{\prime}(\mathbf{x}, \mathbf{z}\mathbf{y}) = f(\mathbf{x}, \mathbf{z})\), \(g^{\prime}(\mathbf{w}, \mathbf{z}\mathbf{y}) = g(\mathbf{y}, \mathbf{w}, \mathbf{z})\): this is (B) for the triple \((\mathbf{X}, \mathbf{Z} \cup \mathbf{Y}, \mathbf{W})\).
Contraction. If \(\Pr(\mathbf{y}, \mathbf{w}, \mathbf{z}) = 0\) the required disjunct holds; otherwise \(\Pr(\mathbf{y}, \mathbf{z}) > 0\) as well, and the second premise (at \(\mathbf{w}\) and \(\mathbf{z}\mathbf{y}\)) followed by the first gives
\begin{equation*} \Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{y}, \mathbf{w}) = \Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{y}) = \Pr(\mathbf{x} \mid \mathbf{z}). \end{equation*}
Intersection, \(\Pr\) strictly positive. Every instantiation now has nonzero probability, so all conditionals below are defined and the two premises read \(\Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{w}, \mathbf{y}) = \Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{w})\) and \(\Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{y}, \mathbf{w}) = \Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{y})\); their left-hand sides coincide, so
\begin{equation*} \Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{w}) = \Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{y}) \quad \text{for all } \mathbf{y}, \mathbf{w}. \tag{C} \end{equation*}
Fixing one \(\mathbf{w}_0\), (C) makes \(\Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{y}) = \Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{w}_0) =: h(\mathbf{x}, \mathbf{z})\) for every \(\mathbf{y}\), so
\begin{equation*} \Pr(\mathbf{x} \mid \mathbf{z}) = \sum_{\mathbf{y}} \Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{y}) \Pr(\mathbf{y} \mid \mathbf{z}) = h(\mathbf{x}, \mathbf{z}), \end{equation*}
and therefore \(\Pr(\mathbf{x} \mid \mathbf{z}, \mathbf{y}, \mathbf{w}) = h(\mathbf{x}, \mathbf{z}) = \Pr(\mathbf{x} \mid \mathbf{z})\). Strict positivity is what makes (C) available for all pairs \(\mathbf{y}, \mathbf{w}\) simultaneously.
Provide a probability distribution over three variables \(X\), \(Y\), and \(Z\) that violates the composition axiom. That is, show that \(I_{\Pr}(Z, \emptyset, X)\) and \(I_{\Pr}(Z, \emptyset, Y)\) but not \(I_{\Pr}(Z, \emptyset, XY)\). Hint: Assume that \(X\) and \(Y\) are inputs to a noisy gate and \(Z\) is its output.
Take \(X\) and \(Y\) to be independent uniform binary inputs to an exclusive-or gate with output \(Z\): the DAG \(X \rightarrow Z \leftarrow Y\) with CPTs
\begin{equation*} \theta_{X=1} = \theta_{Y=1} = \tfrac{1}{2}, \qquad \theta_{Z=1 \mid x, y} = [\, x \oplus y = 1 \,], \end{equation*}
where \([\cdot]\) is \(1\) when the condition holds and \(0\) otherwise. The chain rule (Equation 4.2) induces
| \(X\) | \(Y\) | \(Z\) | \(\Pr(x,y,z)\) |
|---|---|---|---|
| 0 | 0 | 0 | 1/4 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1/4 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1/4 |
| 1 | 1 | 0 | 1/4 |
| 1 | 1 | 1 | 0 |
Summing the table, \(\Pr(X = 1) = \Pr(Y = 1) = \Pr(Z = 1) = \tfrac{1}{2}\). Conditioning on \(X = 1\) leaves \(Y\) uniform with \(Z = 1\) exactly when \(Y = 0\), and conditioning on \(X = 0\) gives \(Z = Y\), so
\begin{equation*} \Pr(Z = 1 \mid X = 1) = \Pr(Z = 1 \mid X = 0) = \tfrac{1}{2} = \Pr(Z = 1), \end{equation*}
that is, \(I_{\Pr}(Z, \emptyset, X)\); and \(I_{\Pr}(Z, \emptyset, Y)\) by the symmetry of the gate and of the input distribution in \(X\) and \(Y\). But the two inputs together determine the output:
\begin{equation*} \Pr(Z = 1 \mid X = 1, Y = 1) = 0 \ne \tfrac{1}{2} = \Pr(Z = 1), \end{equation*}
so \(I_{\Pr}(Z, \emptyset, XY)\) fails and composition (Equation 4.5) is violated.
Provide a probability distribution over three variables \(X\), \(Y\), and \(Z\) that violates the intersection axiom. That is, show that \(I_{\Pr}(X, Z, Y)\) and \(I_{\Pr}(X, Y, Z)\) but not \(I_{\Pr}(X, \emptyset, YZ)\).
Take \(X\), \(Y\), \(Z\) binary and always equal, the common value set by a fair coin:
\begin{equation*} \Pr(X = Y = Z = 1) = \Pr(X = Y = Z = 0) = \tfrac{1}{2}, \end{equation*}
every other instantiation having probability \(0\). By Exercise 4.9 intersection holds for every strictly positive distribution, so a counterexample must encode a logical constraint, and equality is the simplest one.
| \(X\) | \(Y\) | \(Z\) | \(\Pr(x,y,z)\) |
|---|---|---|---|
| 0 | 0 | 0 | 1/2 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1/2 |
It is induced by \(X \rightarrow Y \rightarrow Z\) with \(\theta_{X=1} = \tfrac{1}{2}\) and the deterministic CPTs \(\theta_{Y = y \mid X = x} = [\, y = x \,]\), \(\theta_{Z = z \mid Y = y} = [\, z = y \,]\).
(i) \(I_{\Pr}(X, Z, Y)\). Given \(Z = z\), which has probability \(\tfrac{1}{2} > 0\), all mass sits on \(X = Y = z\); so \(\Pr(y,z) > 0\) forces \(y = z\) and then \(\Pr(x \mid z, y) = [\, x = z \,] = \Pr(x \mid z)\), while for \(y \ne z\) we have \(\Pr(y,z) = 0\) and the second disjunct of the definition applies.
(ii) \(I_{\Pr}(X, Y, Z)\). The same argument with \(Y\) and \(Z\) interchanged: \(Y = y\) pins \(X = y\), so \(\Pr(x \mid y,z) = [\, x = y \,] = \Pr(x \mid y)\) whenever \(\Pr(y,z) > 0\).
(iii) \(I_{\Pr}(X, \emptyset, YZ)\) fails, since \(\Pr(Y=1, Z=1) = \tfrac{1}{2} \ne 0\) and
\begin{equation*} \Pr(X = 1 \mid Y = 1, Z = 1) = 1 \ne \tfrac{1}{2} = \Pr(X = 1), \end{equation*}
so neither disjunct holds. Intersection, Equation 4.13, is therefore violated.
Construct two distinct DAGs over variables \(A\), \(B\), \(C\), and \(D\). Each DAG must have exactly four edges and the DAGs must agree on d-separation, that is, for all disjoint sets of nodes \(\mathbf{X}, \mathbf{Z}, \mathbf{Y}\) we must have \(\mathrm{dsep}_{G_1}(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) if and only if \(\mathrm{dsep}_{G_2}(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\).
Take the two DAGs
\begin{equation*} \begin{aligned} G_1 &: \quad A \rightarrow B, \quad B \rightarrow C, \quad C \rightarrow D, \quad A \rightarrow D,\\ G_2 &: \quad B \rightarrow A, \quad B \rightarrow C, \quad C \rightarrow D, \quad A \rightarrow D. \end{aligned} \end{equation*}
Both have four edges, both are acyclic (topological orders \(A,B,C,D\) and \(B,A,C,D\)), and they differ in the orientation of the edge between \(A\) and \(B\). By Definition 4.2, \(\mathrm{dsep}(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) holds iff \(\mathrm{dsep}(X, \mathbf{Z}, Y)\) for every \(X \in \mathbf{X}\) and \(Y \in \mathbf{Y}\), so only singleton pairs need checking.
(i) Adjacent pairs. Both DAGs have the skeleton \(A - B - C - D - A\), and a single-edge path carries no valve and is never blocked, so \(\{A,B\}\), \(\{B,C\}\), \(\{C,D\}\), \(\{A,D\}\) are d-separated by no \(\mathbf{Z}\) in either DAG.
(ii) The pair \(\{A, C\}\), where \(\mathbf{Z} \subseteq \{B, D\}\). The two paths are \(A \rightarrow B \rightarrow C\) (sequential at \(B\)) and \(A \rightarrow D \leftarrow C\) in \(G_1\), and \(A \leftarrow B \rightarrow C\) (divergent at \(B\)) with the same \(A \rightarrow D \leftarrow C\) in \(G_2\). Sequential and divergent valves close under the identical condition \(B \in \mathbf{Z}\), and \(D\) is a leaf in both DAGs, so both give:
| \(\mathbf{Z}\) | valve at \(B\) | valve at \(D\) | d-separated? |
|---|---|---|---|
| \(\emptyset\) | open | closed | no |
| \(\{B\}\) | closed | closed | yes |
| \(\{D\}\) | open | open | no |
| \(\{B, D\}\) | closed | open | no |
So in both DAGs \(A\) and \(C\) are d-separated exactly by \(\mathbf{Z} = \{B\}\).
(iii) The pair \(\{B, D\}\), where \(\mathbf{Z} \subseteq \{A, C\}\). The paths are \(B \rightarrow C \rightarrow D\) together with \(B \leftarrow A \rightarrow D\) in \(G_1\) and \(B \rightarrow A \rightarrow D\) in \(G_2\); every valve is again sequential or divergent, hence closed exactly when its node lies in \(\mathbf{Z}\):
| \(\mathbf{Z}\) | valve at \(C\) | valve at \(A\) | d-separated? |
|---|---|---|---|
| \(\emptyset\) | open | open | no |
| \(\{A\}\) | open | closed | no |
| \(\{C\}\) | closed | open | no |
| \(\{A, C\}\) | closed | closed | yes |
Again identical: \(B\) and \(D\) are d-separated exactly by \(\mathbf{Z} = \{A, C\}\). Agreeing on every singleton query, \(G_1\) and \(G_2\) agree on every d-separation query.
Prove that d-separation satisfies the properties of intersection and chordality, stated in Section 4.5.3 as
\begin{equation*} \mathrm{dsep}(\mathbf{X}, \mathbf{Z} \cup \mathbf{W}, \mathbf{Y}) \ \text{and}\ \mathrm{dsep}(\mathbf{X}, \mathbf{Z} \cup \mathbf{Y}, \mathbf{W}) \ \text{only if}\ \mathrm{dsep}(\mathbf{X}, \mathbf{Z}, \mathbf{Y} \cup \mathbf{W}) \end{equation*}
for disjoint sets of nodes \(\mathbf{X}, \mathbf{Y}, \mathbf{Z}, \mathbf{W}\), and
\begin{equation*} \mathrm{dsep}(X, \{Z, W\}, Y) \ \text{and}\ \mathrm{dsep}(W, \{X, Y\}, Z) \ \text{only if}\ \mathrm{dsep}(X, Z, Y) \ \text{or}\ \mathrm{dsep}(X, W, Y) \end{equation*}
for distinct single nodes \(X, Y, Z, W\).
Both hold, with blocking as in Definition 4.2.
Observation. If \(\mathbf{S} \subseteq \mathbf{S}^{\prime}\) and a valve of a path is closed given \(\mathbf{S}^{\prime}\) but open given \(\mathbf{S}\), it is sequential or divergent with node in \(\mathbf{S}^{\prime}\setminus\mathbf{S}\): such a valve is closed exactly when its node lies in the conditioning set, while a convergent valve closed given \(\mathbf{S}^{\prime}\) is a fortiori closed given the smaller \(\mathbf{S}\), which contains neither its node nor a descendant.
Intersection. Assume (1) \(\mathrm{dsep}(\mathbf{X}, \mathbf{Z}\cup\mathbf{W}, \mathbf{Y})\) and (2) \(\mathrm{dsep}(\mathbf{X}, \mathbf{Z}\cup\mathbf{Y}, \mathbf{W})\), and suppose the conclusion fails; the premises force \(\mathbf{X},\mathbf{Y},\mathbf{Z},\mathbf{W}\) pairwise disjoint. Let \(\pi\) be a shortest path from \(s \in \mathbf{X}\) to \(t \in \mathbf{Y}\cup\mathbf{W}\) unblocked by \(\mathbf{Z}\).
- (i) \(t \in \mathbf{Y}\): by (1) some valve of \(\pi\) is closed given \(\mathbf{Z}\cup\mathbf{W}\), and it is open given \(\mathbf{Z}\), so by the Observation it is sequential or divergent at an interior node \(V \in \mathbf{W}\).
- (ii) \(t \in \mathbf{W}\): by (2), symmetrically, at an interior node \(V \in \mathbf{Y}\).
Either way the sub-path of \(\pi\) from \(s\) to \(V\) carries the same valve types at the same interior nodes, so it too is unblocked by \(\mathbf{Z}\); it runs from \(\mathbf{X}\) into \(\mathbf{Y}\cup\mathbf{W}\) and is shorter, contradicting the choice of \(\pi\). Hence \(\mathrm{dsep}(\mathbf{X}, \mathbf{Z}, \mathbf{Y}\cup\mathbf{W})\).
Chordality. Write \(An(\mathbf{S})\) for \(\mathbf{S}\) with all ancestors of its members and \(M(\mathbf{S})\) for the moral graph of \(G\) restricted to \(An(\mathbf{S})\). By Exercise 4.24, for disjoint sets \(\mathrm{dsep}_G(\mathbf{X},\mathbf{Z},\mathbf{Y})\) iff \(\mathbf{Z}\) separates \(\mathbf{X}\) from \(\mathbf{Y}\) in \(M(\mathbf{X}\cup\mathbf{Y}\cup\mathbf{Z})\). Monotonicity: for \(\mathbf{S}^{\prime}\subseteq\mathbf{S}\), \(M(\mathbf{S}^{\prime})\) is a subgraph of \(M(\mathbf{S})\), since \(An(\mathbf{S}^{\prime}) \subseteq An(\mathbf{S})\) and a marriage through a common child \(c \in An(\mathbf{S}^{\prime})\) is a marriage through \(c \in An(\mathbf{S})\). (Check!)
Assume (1) \(\mathrm{dsep}(X,\{Z,W\},Y)\) and (2) \(\mathrm{dsep}(W,\{X,Y\},Z)\) for distinct \(X,Y,Z,W\), and for contradiction that (3) \(\mathrm{dsep}(X,Z,Y)\) and (4) \(\mathrm{dsep}(X,W,Y)\) both fail. Put \(A = An(\{X,Y,Z,W\})\), \(M = M(\{X,Y,Z,W\})\), \(M_1 = M(\{X,Y,Z\})\), \(M_2 = M(\{X,Y,W\})\); premises (1) and (2) are read in \(M\), and \(M_1, M_2\) are subgraphs of \(M\) by monotonicity.
- \(X\) and \(Y\) are non-adjacent in \(M\): an edge would be an \(X\)-\(Y\) path meeting neither \(Z\) nor \(W\), against (1).
- By (3) and Exercise 4.24 there is an \(X\)-\(Y\) path \(p\) of \(M_1\), hence of \(M\), avoiding \(Z\); by 1 it has an interior node and by (1) it meets \(\{Z,W\}\), so it contains \(W\). Then \(W \in An(\{X,Y,Z\})\setminus\{X,Y,Z\}\), i.e. \(W\) is a proper ancestor of \(X\), \(Y\), or \(Z\). Symmetrically (4) gives an \(X\)-\(Y\) path \(q\) of \(M\) avoiding \(W\) and containing \(Z\), with \(Z\) a proper ancestor of \(X\), \(Y\), or \(W\).
- In \(M^{-} = M\) minus \(X\) and \(Y\), premise (2) puts \(W\) and \(Z\) in distinct components \(C_W \ne C_Z\) joined by no edge of \(M\), and \(\mathrm{interior}(p) \subseteq C_W\), \(\mathrm{interior}(q) \subseteq C_Z\).
- Let \(R\) be the last of \(X,Y,Z,W\) in a topological order of \(G\); \(R\) is a proper ancestor of none of the others, which by 2 excludes \(Z\) and \(W\), so \(R \in \{X,Y\}\). All of (1), (3), (4) are symmetric in their outer arguments, (2) mentions \(\{X,Y\}\) as a set, and \(A, M, M_1, M_2\) are unchanged by the swap, so take \(R = Y\).
- \(Y\) has no child in \(A\): a child \(U \in A\) has \(U \notin An(Y)\) by acyclicity, hence is an ancestor of or equal to one of \(X, Z, W\), making \(Y\) a proper ancestor of one of them against 4.
- So every neighbour of \(Y\) in \(M\) is a parent of \(Y\) in \(G[A]\): the other two sources of an \(M\)-edge at \(Y\), namely \(Y\) being a parent of the neighbour or the two being co-parents of a node of \(A\), both need \(Y\) to have a child in \(A\).
- Let \(c\) and \(d\) be the neighbours of \(Y\) on \(p\) and on \(q\); by 1 and 3 they are interior, with \(c \in C_W\) and \(d \in C_Z\), so \(c \ne d\). By 6 both are parents of \(Y\), so moralization puts \(c - d\) in \(M\), joining \(C_W\) to \(C_Z\) against 3.
Hence (3) and (4) cannot both fail: \(\mathrm{dsep}(X, Z, Y)\) or \(\mathrm{dsep}(X, W, Y)\).
Consider the DAG \(G\) in Figure 4.4, over the five propositional variables \(A\) (Winter?), \(B\) (Sprinkler?), \(C\) (Rain?), \(D\) (Wet Grass?) and \(E\) (Slippery Road?), with edges
\begin{equation*} A \rightarrow B, \quad A \rightarrow C, \quad B \rightarrow D, \quad C \rightarrow D, \quad C \rightarrow E. \end{equation*}
Suppose that this DAG is a P-MAP of some distribution \(\Pr\). Construct a minimal I-MAP \(G^{\prime}\) for \(\Pr\) using each of the following variable orders:
- (a) \(A, D, B, C, E\)
- (b) \(A, B, C, D, E\)
- (c) \(E, D, C, B, A\)
Run the procedure of Section 4.6.2, giving \(X_i\) as parents a minimal \(\mathbf{P} \subseteq \{X_1,\dots,X_{i-1}\}\) with \(I_{\Pr}(X_i, \mathbf{P}, \{X_1,\dots,X_{i-1}\}\setminus\mathbf{P})\); since \(G\) is a P-MAP of \(\Pr\), each test is the corresponding \(\mathrm{dsep}_G\) test. Two facts shorten every step: a predecessor adjacent to \(X_i\) lies in every admissible \(\mathbf{P}\) (a single edge carries no valve, Definition 4.2), and \(D\) is a leaf, so a convergent valve at \(D\) is closed exactly when \(D \notin \mathbf{P}\).
(a) Order \(A, D, B, C, E\).
- \(A\): \(\mathbf{P} = \emptyset\).
- \(D\): \(\mathrm{dsep}_G(D, \emptyset, A)\) fails, the sequential valve at \(B\) on \(A \rightarrow B \rightarrow D\) being open, so \(\mathbf{P} = \{A\}\).
- \(B\): adjacent to \(A\) and \(D\), so \(\mathbf{P} = \{A, D\}\).
- \(C\): adjacent to \(A\) and \(D\), and \(\mathrm{dsep}_G(C, \{A,D\}, B)\) fails because the convergent valve at \(D\) on \(C \rightarrow D \leftarrow B\) is open; so \(\mathbf{P} = \{A,B,D\}\).
- \(E\): adjacent to \(C\), and \(\{C\}\) suffices, every path out of \(E\) beginning \(E \leftarrow C\) and so carrying a sequential or divergent valve at \(C\).
\begin{equation*} A \rightarrow D, \quad A \rightarrow B, \quad D \rightarrow B, \quad A \rightarrow C, \quad B \rightarrow C, \quad D \rightarrow C, \quad C \rightarrow E. \end{equation*}
(b) Order \(A, B, C, D, E\), a topological order of \(G\), returns \(G\) itself:
- \(A\): \(\emptyset\); \(B\): adjacent to \(A\), so \(\{A\}\).
- \(C\): adjacent to \(A\), and \(\{A\}\) suffices, since \(C \leftarrow A \rightarrow B\) is closed at the divergent valve \(A\) and \(C \rightarrow D \leftarrow B\) at the convergent valve \(D\).
- \(D\): adjacent to \(B\) and \(C\), and \(\{B,C\}\) suffices, the paths \(D \leftarrow B \leftarrow A\) and \(D \leftarrow C \leftarrow A\) being closed at their sequential valves.
- \(E\): \(\{C\}\) as in (a).
\begin{equation*} A \rightarrow B, \quad A \rightarrow C, \quad B \rightarrow D, \quad C \rightarrow D, \quad C \rightarrow E. \end{equation*}
(c) Order \(E, D, C, B, A\).
- \(E\): \(\emptyset\).
- \(D\): \(\mathrm{dsep}_G(D, \emptyset, E)\) fails at the divergent valve \(C\) of \(D \leftarrow C \rightarrow E\), so \(\mathbf{P} = \{E\}\).
- \(C\): adjacent to \(D\) and \(E\), so \(\mathbf{P} = \{D, E\}\).
- \(B\): adjacent to \(D\), and \(\{C,D\}\) passes, since \(B \leftarrow A \rightarrow C \rightarrow E\) is closed at the sequential valve \(C\) and \(B \rightarrow D \leftarrow C \rightarrow E\) at the divergent valve \(C\) (its valve at \(D\) being open). Both \(\{D\}\) and \(\{D,E\}\) leave \(C\) on the right, where \(B \leftarrow A \rightarrow C\) is unblocked. So \(\mathbf{P} = \{C, D\}\).
- \(A\): adjacent to \(B\) and \(C\), and \(\{B,C\}\) suffices: \(A \rightarrow B \rightarrow D\), \(A \rightarrow C \rightarrow D\) and \(A \rightarrow C \rightarrow E\) are blocked at their sequential valves, and \(A \rightarrow B \rightarrow D \leftarrow C \rightarrow E\) at \(B\).
\begin{equation*} E \rightarrow D, \quad E \rightarrow C, \quad D \rightarrow C, \quad C \rightarrow B, \quad D \rightarrow B, \quad B \rightarrow A, \quad C \rightarrow A. \end{equation*}
Exercises 4.15–4.21
Identify a DAG that is a D-MAP for all distributions \(\Pr\) over variables \(\mathbf{X}\). Similarly, identify another DAG that is an I-MAP for all distributions \(\Pr\) over variables \(\mathbf{X}\).
The edgeless DAG \(G_\emptyset\) over \(\mathbf{X}\) is a D-MAP of every distribution, and the complete DAG \(G_c\) on any fixed ordering \(X_1,\dots,X_n\) (edges \(X_i \to X_j\) for \(i<j\)) is an I-MAP of every distribution. Both conditions of Section 4.6 are implications, and each graph satisfies its own vacuously.
D-MAP. \(G_\emptyset\) has no path at all between a node of \(\mathbf{X}_1\) and a node of \(\mathbf{Y}\), so the blocking condition of Definition 4.2 is met vacuously and \(\mathrm{dsep}_{G_\emptyset}(\mathbf{X}_1,\mathbf{Z},\mathbf{Y})\) holds for every disjoint triple. The consequent of
\begin{equation*} I_{\Pr}(\mathbf{X}_1,\mathbf{Z},\mathbf{Y}) \ \text{only if}\ \mathrm{dsep}_{G_\emptyset}(\mathbf{X}_1,\mathbf{Z},\mathbf{Y}) \end{equation*}
is thus always true, for every \(\Pr\).
I-MAP. \(G_c\) is acyclic, all edges running forward in the ordering. If \(\mathbf{X}_1,\mathbf{Z},\mathbf{Y}\) are disjoint with \(\mathbf{X}_1\) and \(\mathbf{Y}\) nonempty, pick \(X \in \mathbf{X}_1\) and \(Y \in \mathbf{Y}\); the edge joining them is a path with no valves, hence never blocked, so \(\mathrm{dsep}_{G_c}(\mathbf{X}_1,\mathbf{Z},\mathbf{Y})\) fails. D-separation holds in \(G_c\) only when \(\mathbf{X}_1 = \emptyset\) or \(\mathbf{Y} = \emptyset\), and for those triples \(I_{\Pr}\) holds by triviality. So the antecedent of
\begin{equation*} \mathrm{dsep}_{G_c}(\mathbf{X}_1,\mathbf{Z},\mathbf{Y}) \ \text{only if}\ I_{\Pr}(\mathbf{X}_1,\mathbf{Z},\mathbf{Y}) \end{equation*}
is never nontrivially true, for every \(\Pr\).
Consider the DAG \(G\) in Figure 4.15. This DAG has nine nodes, \(A_1,A_2,A_3\), \(B_1,B_2,B_3\), \(C_1,C_2,C_3\), arranged in three rows of three, and the following ten edges:
\begin{equation*} \begin{aligned} &A_1 \to A_2, \quad A_2 \to A_3, \quad A_1 \to B_2, \quad A_2 \to B_3, \\ &B_1 \to B_2, \quad B_2 \to B_3, \quad B_1 \to C_2, \quad B_2 \to C_3, \\ &C_1 \to C_2, \quad C_2 \to C_3. \end{aligned} \end{equation*}
That is, each node in row \(A\) points to the next node in its own row and to the next node in row \(B\); each node in row \(B\) points to the next node in its own row and to the next node in row \(C\); each node in row \(C\) points only to the next node in row \(C\). Suppose that this DAG is a P-MAP of a distribution \(\Pr\).
(a) What is the Markov boundary for the variable \(C_2\)?
(b) Is the Markov boundary of \(A_1\) a Markov blanket of \(B_3\)?
(c) Which variable has the smallest Markov boundary?
(a) \(\{B_1, C_1, C_3, B_2\}\); (b) yes; (c) \(A_3\), whose boundary \(\{A_2\}\) has size one.
By Corollary 1 the set \(\mathrm{mb}(X)\) of parents, children, and spouses of \(X\) (a spouse being another parent of a child of \(X\)) is a Markov blanket for \(X\); under the P-MAP hypothesis it is the Markov boundary, since it sits inside every blanket \(\mathbf{B}\). For \(I_{\Pr}(X,\mathbf{B},\mathbf{X}\setminus\mathbf{B}\setminus\{X\})\) gives \(\mathrm{dsep}_G(X,\mathbf{B},\mathbf{X}\setminus\mathbf{B}\setminus\{X\})\), \(G\) being a D-MAP, and any \(Y \in \mathrm{mb}(X)\setminus\mathbf{B}\) refutes that d-separation:
- \(Y\) a parent or child of \(X\): the edge between them is a valveless path, never blocked;
- \(Y\) a spouse through a child \(Z \in \mathbf{B}\): the only valve of \(X \to Z \leftarrow Y\) is convergent at \(Z\), hence open;
- \(Y\) a spouse through a child \(Z \notin \mathbf{B}\): the edge \(X \to Z\) is itself an unblocked path into the third argument.
(a) \(C_2\) has parents \(B_1, C_1\), sole child \(C_3\), and through \(C_3\) the single spouse \(B_2\):
\begin{equation*} \mathrm{mb}(C_2) = \{B_1, C_1, C_3, B_2\}. \end{equation*}
(b) Yes. The root \(A_1\) has children \(A_2, B_2\) and one spouse \(B_1\) (the other parent of \(B_2\)), so \(\mathrm{mb}(A_1) = \{A_2, B_2, B_1\}\); the leaf \(B_3\) has parents \(A_2, B_2\), so \(\mathrm{mb}(B_3) = \{A_2, B_2\}\) is a blanket of \(B_3\) by Corollary 1. Since \(\{A_2,B_2\} \subseteq \mathrm{mb}(A_1)\) and \(B_3 \notin \mathrm{mb}(A_1)\), it is enough that a superset \(\mathbf{B} \supseteq \mathbf{S}\) of a blanket with \(X \notin \mathbf{B}\) is again a blanket: splitting \(\mathbf{X}\setminus\mathbf{S}\setminus\{X\}\) as \((\mathbf{B}\setminus\mathbf{S}) \cup (\mathbf{X}\setminus\mathbf{B}\setminus\{X\})\), weak union turns \(I_{\Pr}(X,\mathbf{S},\mathbf{X}\setminus\mathbf{S}\setminus\{X\})\) into
\begin{equation*} I_{\Pr}\bigl(X,\ \mathbf{B},\ \mathbf{X}\setminus\mathbf{B}\setminus\{X\}\bigr). \end{equation*}
(c) Tabulating parents, children, and spouses for all nine nodes:
| node | parents | children | spouses | boundary | size |
|---|---|---|---|---|---|
| \(A_1\) | — | \(A_2, B_2\) | \(B_1\) | \(\{A_2,B_2,B_1\}\) | 3 |
| \(A_2\) | \(A_1\) | \(A_3, B_3\) | \(B_2\) | \(\{A_1,A_3,B_3,B_2\}\) | 4 |
| \(A_3\) | \(A_2\) | — | — | \(\{A_2\}\) | 1 |
| \(B_1\) | — | \(B_2, C_2\) | \(A_1, C_1\) | \(\{B_2,C_2,A_1,C_1\}\) | 4 |
| \(B_2\) | \(A_1, B_1\) | \(B_3, C_3\) | \(A_2, C_2\) | \(\{A_1,B_1,B_3,C_3,A_2,C_2\}\) | 6 |
| \(B_3\) | \(A_2, B_2\) | — | — | \(\{A_2,B_2\}\) | 2 |
| \(C_1\) | — | \(C_2\) | \(B_1\) | \(\{C_2,B_1\}\) | 2 |
| \(C_2\) | \(B_1, C_1\) | \(C_3\) | \(B_2\) | \(\{B_1,C_1,C_3,B_2\}\) | 4 |
| \(C_3\) | \(B_2, C_2\) | — | — | \(\{B_2,C_2\}\) | 2 |
The smallest is \(\mathrm{mb}(A_3) = \{A_2\}\), and it is a boundary: its only proper subset \(\emptyset\) fails, since the edge \(A_2 \to A_3\) is an unblockable path and the D-MAP property then denies \(A_3\) marginal independence of the rest.
Prove that for strictly positive distributions, if \(\mathbf{B}_1\) and \(\mathbf{B}_2\) are Markov blankets for some variable \(X\), then \(\mathbf{B}_1 \cap \mathbf{B}_2\) is also a Markov blanket for \(X\). Hint: Appeal to the intersection axiom.
Partition \(\mathbf{R} = \mathbf{X}\setminus\{X\}\) into
\begin{equation*} \begin{aligned} \mathbf{S} &= \mathbf{B}_1 \cap \mathbf{B}_2, &\qquad \mathbf{D}_1 &= \mathbf{B}_1 \setminus \mathbf{B}_2, \\ \mathbf{D}_2 &= \mathbf{B}_2 \setminus \mathbf{B}_1, &\qquad \mathbf{O} &= \mathbf{R} \setminus (\mathbf{B}_1 \cup \mathbf{B}_2), \end{aligned} \end{equation*}
so that by Definition 4.3 the hypotheses read \(I_{\Pr}(X, \mathbf{S}\cup\mathbf{D}_1, \mathbf{D}_2\cup\mathbf{O})\) and \(I_{\Pr}(X, \mathbf{S}\cup\mathbf{D}_2, \mathbf{D}_1\cup\mathbf{O})\), while the goal is \(I_{\Pr}(X, \mathbf{S}, \mathbf{D}_1\cup\mathbf{D}_2\cup\mathbf{O})\); the side condition \(X \notin \mathbf{S}\) follows from \(X \notin \mathbf{B}_1\). Weak union (4.7) and the intersection axiom (4.13), the latter available because \(\Pr\) is strictly positive, give
\begin{equation*} \begin{aligned} (1)\quad &I_{\Pr}(X,\ \mathbf{S}\cup\mathbf{D}_1\cup\mathbf{O},\ \mathbf{D}_2), \\ (2)\quad &I_{\Pr}(X,\ \mathbf{S}\cup\mathbf{D}_2\cup\mathbf{O},\ \mathbf{D}_1), \\ (3)\quad &I_{\Pr}(X,\ \mathbf{S}\cup\mathbf{O},\ \mathbf{D}_1\cup\mathbf{D}_2), \\ (4)\quad &I_{\Pr}(X,\ \mathbf{S}\cup\mathbf{D}_1\cup\mathbf{D}_2,\ \mathbf{O}), \end{aligned} \end{equation*}
where (1) and (2) are weak union on the two hypotheses with \(\mathbf{Y} = \mathbf{O}\); (3) is intersection on (1) and (2) with \(\mathbf{Z} = \mathbf{S}\cup\mathbf{O}\), \(\mathbf{W} = \mathbf{D}_1\), \(\mathbf{Y} = \mathbf{D}_2\); and (4) is weak union on the first hypothesis with \(\mathbf{Y} = \mathbf{D}_2\), \(\mathbf{W} = \mathbf{O}\). Intersection once more, on (3) and (4) with \(\mathbf{Z} = \mathbf{S}\), \(\mathbf{W} = \mathbf{O}\), \(\mathbf{Y} = \mathbf{D}_1\cup\mathbf{D}_2\), yields
\begin{equation*} I_{\Pr}(X,\ \mathbf{S},\ \mathbf{D}_1\cup\mathbf{D}_2\cup\mathbf{O}), \end{equation*}
which with \(X \notin \mathbf{S}\) is exactly the statement that \(\mathbf{B}_1\cap\mathbf{B}_2\) is a Markov blanket for \(X\). \(\blacksquare\)
(After Pearl) Consider the following independence statements over the four variables \(A, B, C, D\): \(I(A,\emptyset,B)\) and \(I(AB,C,D)\).
(a) Find all independence statements that follow from these two statements using the positive graphoid axioms.
(b) Construct minimal I-MAPs of the statements in (a) (original and derived) using the following variable orders:
- \(A, B, C, D\)
- \(D, C, B, A\)
- \(A, D, B, C\)
(a) The closure is the twelve statements displayed below; (b) the three orders return \(G_1\) (three edges), a four-edge DAG, and the complete DAG.
(a) From \(I(A,\emptyset,B)\) only symmetry is productive, both outer arguments being singletons and the conditioning set empty. From \(I(AB,C,D)\), symmetry gives \(I(D,C,AB)\), whose right argument is a pair: decomposition then gives \(I(D,C,A)\) and \(I(D,C,B)\), weak union (4.7) gives \(I(D,\{C,B\},A)\) and \(I(D,\{C,A\},B)\), and symmetry doubles each. Contraction (4.9) on \(I(D,C,A)\) and \(I(D,\{C,A\},B)\) returns \(I(D,C,AB)\), as does intersection (4.13) on \(I(D,\{C,A\},B)\) and \(I(D,\{C,B\},A)\), so the derivation has stabilized; modulo the triviality statements \(I(\mathbf{X}_1,\mathbf{Z},\emptyset)\):
\begin{equation*} \begin{aligned} &I(A,\emptyset,B), && I(B,\emptyset,A), \\ &I(AB,C,D), && I(D,C,AB), \\ &I(A,C,D), && I(D,C,A), \\ &I(B,C,D), && I(D,C,B), \\ &I(A,\{B,C\},D), && I(D,\{B,C\},A), \\ &I(B,\{A,C\},D), && I(D,\{A,C\},B). \end{aligned} \end{equation*}
That the list is closed is proved rather than inspected. Let \(G_1\) be the DAG \(A \to C\), \(B \to C\), \(C \to D\); its d-separations over disjoint triples are exactly the twelve statements above, both seeds among them, since \(A\) and \(B\) are non-adjacent roots joined only through the convergent valve at \(C\) and \(C\) blocks every path from \(\{A,B\}\) to \(D\). D-separation obeys every positive graphoid axiom — symmetry, decomposition, weak union, contraction and triviality from Definition 4.2, intersection from Exercise 4.13 — so the set of triples d-separated in \(G_1\) is closed under the axioms and contains the seeds, hence contains the closure, hence equals it. Note that \(C\) never occurs as an outer argument.
(b) By Section 4.6.2, \(\mathbf{P} \subseteq \{X_1,\dots,X_{i-1}\}\) is admissible for \(X_i\) exactly when \(I(X_i,\mathbf{P},\{X_1,\dots,X_{i-1}\}\setminus\mathbf{P})\) lies in the closure, and with \(\Pr\) strictly positive the minimal such \(\mathbf{P}\) is unique.
Order \(A, B, C, D\), giving \(G_1\) itself, hence a P-MAP of the statements in (a):
- \(A\): \(\emptyset\). \(B\): \(\emptyset\), by \(I(B,\emptyset,A)\).
- \(C\): none of \(I(C,\emptyset,AB)\), \(I(C,A,B)\), \(I(C,B,A)\) is in the closure, so \(\{A,B\}\).
- \(D\): \(I(D,C,AB)\) is in the closure and \(\emptyset\), \(\{A\}\), \(\{B\}\) fail, so \(\{C\}\).
Order \(D, C, B, A\), giving \(D \to C\), \(C \to B\), \(C \to A\), \(B \to A\):
- \(D\): \(\emptyset\). \(C\): \(I(C,\emptyset,D)\) absent, so \(\{D\}\).
- \(B\): \(I(B,\emptyset,\{C,D\})\) and \(I(B,D,C)\) absent, \(I(B,C,D)\) present, so \(\{C\}\).
- \(A\): \(I(A,\emptyset,\{B,C,D\})\), \(I(A,B,\{C,D\})\), \(I(A,C,\{B,D\})\), \(I(A,D,\{B,C\})\) all absent, \(I(A,\{B,C\},D)\) present, so \(\{B,C\}\).
This is an I-MAP, the d-separations it asserts being \(\mathrm{dsep}(D,C,A)\), \(\mathrm{dsep}(D,C,B)\), \(\mathrm{dsep}(D,C,AB)\), \(\mathrm{dsep}(D,\{B,C\},A)\) and \(\mathrm{dsep}(D,\{A,C\},B)\), all in the closure; it is not a P-MAP, the edge \(B \to A\) destroying \(I(A,\emptyset,B)\).
Order \(A, D, B, C\), giving the complete DAG \(A \to D\), \(A \to B\), \(A \to C\), \(D \to B\), \(D \to C\), \(B \to C\):
- \(A\): \(\emptyset\). \(D\): \(I(D,\emptyset,A)\) absent, only \(I(D,C,A)\) being present, so \(\{A\}\).
- \(B\): \(I(B,\emptyset,\{A,D\})\) is absent, since composition is not a graphoid axiom and so \(I(B,\emptyset,A)\) with \(I(B,C,D)\) does not combine; \(I(B,A,D)\) and \(I(B,D,A)\) are absent too, so \(\{A,D\}\).
- \(C\): no closure statement has \(C\) as an outer argument, so \(\{A,D,B\}\).
Asserting no independence at all, it is trivially an I-MAP, and minimal by Exercise 4.19: deleting \(A \to C\), for instance, would assert \(\mathrm{dsep}(C,\{D,B\},A)\), absent from the closure.
Assume that the algorithm in Section 4.6.2 is correct as far as producing an I-MAP \(G\) for the given distribution \(\Pr\). Prove that \(G\) must also be a minimal I-MAP.
Recall the algorithm: given an ordering \(X_1,\dots,X_n\) of the variables of \(\Pr\), start with an edgeless DAG and process the variables in order; for each \(X_i\) identify a minimal subset \(\mathbf{P}_i \subseteq \{X_1,\dots,X_{i-1}\}\) such that \(I_{\Pr}(X_i,\mathbf{P}_i,\{X_1,\dots,X_{i-1}\}\setminus\mathbf{P}_i)\), and make \(\mathbf{P}_i\) the parents of \(X_i\).
Delete an arbitrary edge \(U \to X_i\) of \(G\), obtaining \(G^{\prime}\); we exhibit a d-separation that holds in \(G^{\prime}\) while the matching independence fails in \(\Pr\), so that \(G^{\prime}\) is not an I-MAP. Every edge of \(G\) issues from a member of \(\mathbf{P}_i\) into \(X_i\), so \(U \in \mathbf{P}_i\) and in \(G^{\prime}\) the parents of \(X_i\) are \(\mathbf{P}_i^{\prime} = \mathbf{P}_i\setminus\{U\}\), those of every other node unchanged. Put
\begin{equation*} \mathbf{V}_i = \{X_1,\dots,X_{i-1}\}, \qquad \mathbf{Y} = \mathbf{V}_i \setminus \mathbf{P}_i^{\prime}. \end{equation*}
Claim: \(\mathrm{dsep}_{G^{\prime}}(X_i, \mathbf{P}_i^{\prime}, \mathbf{Y})\). Apply Theorem 4.1 with \(\mathbf{X}_1 \cup \mathbf{Z} \cup \mathbf{Y} = \{X_1,\dots,X_i\}\). The algorithm draws edges only from earlier to later variables, so \(X_1,\dots,X_n\) is a topological order of \(G^{\prime}\) and deleting \(X_n, X_{n-1},\dots,X_{i+1}\) in turn prunes leaves lying outside \(\{X_1,\dots,X_i\}\). Deleting next the edges outgoing from \(\mathbf{Z} = \mathbf{P}_i^{\prime}\) isolates \(X_i\): its outgoing edges went with its pruned children, and its incoming edges all issue from \(\mathbf{P}_i^{\prime}\). Theorem 4.1 then gives the claim, which is just the local Markov property, \(\mathbf{Y}\) consisting of non-descendants of \(X_i\).
Were \(G^{\prime}\) an I-MAP of \(\Pr\), the claim would force
\begin{equation*} I_{\Pr}\bigl(X_i,\ \mathbf{P}_i \setminus \{U\},\ \{X_1,\dots,X_{i-1}\}\setminus(\mathbf{P}_i\setminus\{U\})\bigr), \end{equation*}
exhibiting \(\mathbf{P}_i\setminus\{U\}\) as a proper subset of \(\mathbf{P}_i\) meeting the very condition the algorithm minimized over, a contradiction. As the edge was arbitrary, \(G\) is a minimal I-MAP of \(\Pr\). \(\blacksquare\)
Suppose that \(G\) is a DAG and let \(\mathbf{W}\) be a set of nodes in \(G\) with deterministic CPTs (i.e., their parameters are either \(0\) or \(1\)). Propose a modification to the d-separation test that can take advantage of nodes \(\mathbf{W}\) and that will be stronger than d-separation (i.e., discover independencies that d-separation cannot discover).
Run the ordinary test on the determined set \(\mathrm{det}(\mathbf{Z})\) in place of \(\mathbf{Z}\): for disjoint \(\mathbf{X}, \mathbf{Z}, \mathbf{Y}\), declare \(\mathbf{X}\) and \(\mathbf{Y}\) independent given \(\mathbf{Z}\) whenever
\begin{equation*} \mathrm{dsep}_G\bigl(\mathbf{X}\setminus\mathrm{det}(\mathbf{Z}),\ \mathrm{det}(\mathbf{Z}),\ \mathbf{Y}\setminus\mathrm{det}(\mathbf{Z})\bigr), \end{equation*}
where \(\mathrm{det}(\mathbf{Z})\) is the least set with \(\mathbf{Z} \subseteq \mathrm{det}(\mathbf{Z})\) and \(V \in \mathrm{det}(\mathbf{Z})\) whenever \(V \in \mathbf{W}\) and \(\mathrm{Parents}(V) \subseteq \mathrm{det}(\mathbf{Z})\). The point is that a node of \(\mathbf{W}\) is a function of its parents, exactly one of its parameters being \(1\) per parent instantiation, so knowledge propagates beyond the evidence set, which the ordinary test cannot see. One topological sweep computes the closure, so the test stays linear-time.
Soundness. By Exercise 4.5(c), \(\Pr(v\mid\mathbf{u}) = \theta_{v\mid\mathbf{u}}\), so each \(V \in \mathbf{W}\) with \(\mathbf{U} = \mathrm{Parents}(V)\) has a unique value \(v = f_V(\mathbf{u})\) of parameter \(1\), whence \(\Pr(V \ne f_V(\mathbf{u}), \mathbf{u}) = 0\) and \(\Pr(f_V(\mathbf{u})\mid e) = 1\) for every positive-probability \(e\) implying \(\mathbf{U} = \mathbf{u}\). Enumerate \(\mathbf{D} = \mathrm{det}(\mathbf{Z})\setminus\mathbf{Z}\) as \(V_1,\dots,V_k\) in the order the closure added them, so that \(\mathrm{Parents}(V_j) \subseteq \mathbf{Z}\cup\{V_1,\dots,V_{j-1}\}\), and fix \(\mathbf{z}\) with \(\Pr(\mathbf{z}) > 0\). If \(\Pr(v_1\cdots v_{j-1}\mid\mathbf{z}) = 1\) then \(\mathbf{z}v_1\cdots v_{j-1}\) is a positive-probability event fixing \(\mathrm{Parents}(V_j)\), so \(\Pr(v_j \mid \mathbf{z}v_1\cdots v_{j-1}) = 1\) and the product is again \(1\); at \(j = k\) a unique \(\mathbf{d}\) has \(\Pr(\mathbf{d}\mid\mathbf{z}) = 1\), and hence \(\Pr(\alpha\mid\mathbf{z}) = \Pr(\alpha\mid\mathbf{z},\mathbf{d})\) for every event \(\alpha\). Split \(\mathbf{x}\) into its part \(\mathbf{x}_1\) over \(\mathbf{X}\setminus\mathrm{det}(\mathbf{Z})\) and \(\mathbf{x}_2\) over \(\mathbf{X}\cap\mathrm{det}(\mathbf{Z})\), and likewise \(\mathbf{y}\). If \(\mathbf{x}_2\) or \(\mathbf{y}_2\) contradicts \(\mathbf{z}\mathbf{d}\), both sides of the independence equation vanish; otherwise \(\mathbf{z}\mathbf{d}\) implies them and
\begin{equation*} \begin{aligned} \Pr(\mathbf{x},\mathbf{y}\mid\mathbf{z}) &= \Pr(\mathbf{x}_1,\mathbf{y}_1\mid\mathbf{z}\mathbf{d}) \\ &= \Pr(\mathbf{x}_1\mid\mathbf{z}\mathbf{d})\, \Pr(\mathbf{y}_1\mid\mathbf{z}\mathbf{d}) = \Pr(\mathbf{x}\mid\mathbf{z})\,\Pr(\mathbf{y}\mid\mathbf{z}), \end{aligned} \end{equation*}
the middle equality being Theorem 4.2 applied to the displayed d-separation, since \(\mathbf{z}\mathbf{d}\) is an instantiation of \(\mathrm{det}(\mathbf{Z})\), and the last holding because \(\mathbf{z}\mathbf{d}\) implies \(\mathbf{x}_2\) and \(\mathbf{y}_2\). Hence \(I_{\Pr}(\mathbf{X},\mathbf{Z},\mathbf{Y})\).
Never weaker. Let \(\mathrm{dsep}_G(\mathbf{X},\mathbf{Z},\mathbf{Y})\) hold and let \(p\) run from \(\mathbf{X}\setminus\mathrm{det}(\mathbf{Z})\) to \(\mathbf{Y}\setminus\mathrm{det}(\mathbf{Z})\); being also an \(\mathbf{X}\)-\(\mathbf{Y}\) path, it has a valve closed given \(\mathbf{Z}\).
- (i) Sequential or divergent at \(N \in \mathbf{Z}\): then \(N \in \mathrm{det}(\mathbf{Z})\) and the valve is still closed.
- (ii) Convergent at \(N\), with no descendant of \(N\) in \(\mathbf{Z}\). If \(N \notin \mathrm{det}(\mathbf{Z})\) then no descendant \(M\) of \(N\) is in \(\mathrm{det}(\mathbf{Z})\) either: every node on a directed path from \(N\) to such an \(M\) is a descendant of \(N\), hence outside \(\mathbf{Z}\), hence in \(\mathrm{det}(\mathbf{Z})\setminus\mathbf{Z}\), which drags its parents in and would force \(N \in \mathrm{det}(\mathbf{Z})\). So the valve stays closed. If instead \(N \in \mathrm{det}(\mathbf{Z})\setminus\mathbf{Z}\), all parents of \(N\) lie in \(\mathrm{det}(\mathbf{Z})\), in particular the two neighbours of \(N\) on \(p\); each has an edge into \(N\), so it is not convergent, and it is either an endpoint removed from the modified query or a sequential or divergent valve in \(\mathrm{det}(\mathbf{Z})\), closed.
Either way \(p\) is blocked, so the modified test succeeds whenever the original does.
Strictly stronger. Take \(A \to V \leftarrow B\), \(V \to C\), \(V \to D\) with binary variables, \(\mathbf{W} = \{V\}\) and the deterministic CPT \(V = A \oplus B\), and ask whether \(C\) and \(D\) are independent given \(\{A,B\}\). Plain d-separation says no, the divergent valve \(V\) on \(C \leftarrow V \to D\) being open since \(V \notin \{A,B\}\). The modified test says yes: \(\mathrm{det}(\{A,B\}) = \{A,B,V\}\), both parents of \(V\) being evidence, and deleting the edges out of \(A\), \(B\), \(V\) isolates \(C\) and \(D\), so \(\mathrm{dsep}_G(C,\{A,B,V\},D)\) holds by Theorem 4.1. The independence is real: \(a,b\) pins \(V = a \oplus b\), and \(C\) and \(D\) are independent given \(V\), while marginally \(V\) is an unobserved common cause of both.
Let \(\Pr\) be a probability distribution over variables \(\mathbf{X}\) and let \(\mathbf{B}\) be a Markov blanket for variable \(X\). Show the correctness of the following procedure for finding a Markov boundary for \(X\).
- Let \(\mathbf{R}\) be \(\mathbf{X} \setminus (\{X\} \cup \mathbf{B})\).
- Repeat until every variable in \(\mathbf{B}\) has been examined or \(\mathbf{B}\) is empty:
- Pick a variable \(Y\) in \(\mathbf{B}\).
- Test whether \(I_{\Pr}(X, \mathbf{B}\setminus\{Y\}, \mathbf{R}\cup\{Y\})\).
- If the test succeeds, remove \(Y\) from \(\mathbf{B}\), add it to \(\mathbf{R}\), and go to Step 1.
- Declare \(\mathbf{B}\) a Markov boundary for \(X\) and exit.
Hint: Appeal to the weak union axiom.
Everything follows from one lemma: if \(\mathbf{S}\) is a Markov blanket for \(X\) and \(\mathbf{S} \subseteq \mathbf{C}\) with \(X \notin \mathbf{C}\), then \(\mathbf{C}\) is a Markov blanket too. For splitting the right-hand argument of \(I_{\Pr}(X,\mathbf{S},\mathbf{X}\setminus\mathbf{S}\setminus\{X\})\) disjointly as \((\mathbf{C}\setminus\mathbf{S}) \cup (\mathbf{X}\setminus\mathbf{C}\setminus\{X\})\) and applying weak union (4.7) yields
\begin{equation*} I_{\Pr}\bigl(X,\ \mathbf{C},\ \mathbf{X}\setminus\mathbf{C}\setminus\{X\}\bigr), \end{equation*}
which with \(X \notin \mathbf{C}\) is Definition 4.3 for \(\mathbf{C}\).
Blanket. Write \(\mathbf{B}_t, \mathbf{R}_t\) for the two sets at the start of iteration \(t\), and take as invariant that \(\mathbf{B}_t \cap \mathbf{R}_t = \emptyset\), \(\mathbf{B}_t \cup \mathbf{R}_t \cup \{X\} = \mathbf{X}\), \(X \notin \mathbf{B}_t\) and \(\mathbf{B}_t\) is a Markov blanket for \(X\). It holds initially, by the choice of \(\mathbf{R}\) and the hypothesis on \(\mathbf{B}\). If the Step 2 test succeeds for the chosen \(Y\), then since \(\mathbf{R}_t\cup\{Y\} = \mathbf{X}\setminus(\mathbf{B}_t\setminus\{Y\})\setminus\{X\}\) by the invariant, the test is exactly Definition 4.3 for \(\mathbf{B}_{t+1} = \mathbf{B}_t\setminus\{Y\}\), \(\mathbf{R}_{t+1} = \mathbf{R}_t\cup\{Y\}\), and the set equations survive; if it fails nothing changes. So the set \(\mathbf{B}^{*}\) returned on exit is a Markov blanket. (If \(\mathbf{B}\) empties, \(\emptyset\) is returned and is trivially a boundary.)
Minimality. Suppose some Markov blanket \(\mathbf{S} \subsetneq \mathbf{B}^{*}\) and pick \(Y \in \mathbf{B}^{*}\setminus\mathbf{S}\). Since the loop runs until every variable of \(\mathbf{B}\) has been examined and \(Y\) survives, some iteration \(t\) picked \(Y\) and failed the test. There \(\mathbf{S} \subseteq \mathbf{B}^{*}\setminus\{Y\} \subseteq \mathbf{B}_t\setminus\{Y\}\), the second inclusion because \(\mathbf{B}\) only shrinks, and \(X \notin \mathbf{B}_t\setminus\{Y\}\); so the lemma with \(\mathbf{C} = \mathbf{B}_t\setminus\{Y\}\) gives
\begin{equation*} I_{\Pr}\bigl(X,\ \mathbf{B}_t\setminus\{Y\},\ \mathbf{X}\setminus(\mathbf{B}_t\setminus\{Y\})\setminus\{X\}\bigr) = I_{\Pr}(X,\ \mathbf{B}_t\setminus\{Y\},\ \mathbf{R}_t\cup\{Y\}), \end{equation*}
the identity again by the invariant. But that is the Step 2 test at iteration \(t\), which failed. Hence no proper subset of \(\mathbf{B}^{*}\) is a blanket, and \(\mathbf{B}^{*}\) is a Markov boundary for \(X\). \(\blacksquare\)
Exercises 4.22–4.25
Show that every probability distribution \(\Pr\) over variables \(X_1, \ldots, X_n\) can be induced by some Bayesian network \((G, \Theta)\) over variables \(X_1, \ldots, X_n\). In particular, show how \((G, \Theta)\) can be constructed from \(\Pr\).
Let \(G\) be the complete DAG on the ordering \(X_1, \ldots, X_n\), with \(X_j \to X_i\) for every \(j < i\), so that \(\mathbf{U}_i = \{X_1,\ldots,X_{i-1}\}\) and \(\mathbf{U}_1 = \emptyset\), and take
\begin{equation*} \theta_{x_i \mid \mathbf{u}_i} \;=\; \begin{cases} \Pr(x_i \mid \mathbf{u}_i), & \text{if } \Pr(\mathbf{u}_i) > 0,\\[2pt] 1/|X_i|, & \text{if } \Pr(\mathbf{u}_i) = 0 . \end{cases} \end{equation*}
Every edge increases the index of its head, so \(G\) is acyclic, and the parametrization is legal in the sense of Definition 4.1, each row summing to \(1\): a conditional distribution over \(X_i\) in the first case, uniform in the second (rows over a zero-probability parent instantiation are unconstrained by \(\Pr\)). The parameters compatible with an instantiation \(x_1,\ldots,x_n\) are \(\theta_{x_i \mid x_1,\ldots,x_{i-1}}\), one per family, so the chain rule for Bayesian networks (4.2) gives
\begin{equation*} \Pr{}^{\prime}(x_1, \ldots, x_n) \;=\; \prod_{i=1}^{n} \theta_{x_i \mid x_1, \ldots, x_{i-1}} , \end{equation*}
with \(\Pr(x_1,\ldots,x_0) = 1\) for the empty prefix.
(i) \(\Pr(x_1,\ldots,x_n) > 0\). The prefix events are nested, so every \(\Pr(x_1,\ldots,x_{i-1}) \ge \Pr(x_1,\ldots,x_n) > 0\) and the first branch applies throughout:
\begin{equation*} \begin{aligned} \prod_{i=1}^{n} \theta_{x_i \mid x_1, \ldots, x_{i-1}} &= \prod_{i=1}^{n} \Pr(x_i \mid x_1, \ldots, x_{i-1})\\ &= \prod_{i=1}^{n} \frac{\Pr(x_1, \ldots, x_i)}{\Pr(x_1, \ldots, x_{i-1})} = \Pr(x_1, \ldots, x_n), \end{aligned} \end{equation*}
the product telescoping; this is the chain rule (3.16).
(ii) \(\Pr(x_1,\ldots,x_n) = 0\). Let \(k\) be least with \(\Pr(x_1,\ldots,x_k) = 0\). Then \(\Pr(x_1,\ldots,x_{k-1}) > 0\), so the first branch applies to the \(k\)-th factor, \(\theta_{x_k \mid x_1,\ldots,x_{k-1}} = \Pr(x_1,\ldots,x_k)/\Pr(x_1,\ldots,x_{k-1}) = 0\), and the whole product vanishes.
Hence \(\Pr{}^{\prime} = \Pr\). \(\blacksquare\)
Let \(G\) be a DAG and let \(G^{\prime}\) be an undirected graph generated from \(G\) as follows:
- For every node in \(G\), every pair of its parents are connected by an undirected edge.
- Every directed edge in \(G\) is converted into an undirected edge.
For every variable \(X\), let \(B_X\) be its neighbors in \(G^{\prime}\) and \(Z_X\) be all variables excluding \(X\) and \(B_X\). Show that \(X\) and \(Z_X\) are d-separated by \(B_X\) in DAG \(G\).
\(G^{\prime}\) is the moral graph of \(G\), so \(B_X\) is the set of parents, children and spouses of \(X\) (a spouse being a node sharing a child with \(X\)):
\begin{equation*} B_X \;=\; \Bigl(\mathrm{pa}(X) \,\cup\, \mathrm{ch}(X) \,\cup \bigcup_{C \in \mathrm{ch}(X)} \mathrm{pa}( C)\Bigr) \setminus \{X\}, \end{equation*}
an edge of \(G^{\prime}\) at \(X\) arising either from step 2, as an edge of \(G\) into or out of \(X\), or from step 1, with \(X\) and the other endpoint distinct parents of a common node. Acyclicity gives \(X \notin B_X\), so \(\{X\}\), \(B_X\), \(Z_X\) are pairwise disjoint and \(\mathrm{dsep}_G(\{X\}, B_X, Z_X)\) is well formed.
Suppose some path \(\alpha : X = W_0 - W_1 - \cdots - W_m = Y\) with \(Y \in Z_X\) is unblocked by \(B_X\), so that every valve on it is open (Definition 4.2).
- \(W_1\) is adjacent to \(X\), hence a parent or a child of \(X\), hence in \(B_X\); as \(Y \notin B_X\) this gives \(W_1 \ne Y\) and \(m \ge 2\), so \(W_1\) is internal and carries a valve. Being open at a node of the conditioning set, that valve is not sequential or divergent, so it is convergent: \(X \to W_1 \leftarrow W_2\).
- Path nodes are distinct, so \(W_2 \ne X\) and \(X, W_2\) are distinct parents of \(W_1\); step 1 of the construction therefore puts the edge \(X - W_2\) into \(G^{\prime}\), giving \(W_2 \in B_X\), hence \(W_2 \ne Y\) and \(W_2\) internal. Its edge to \(W_1\) is \(W_2 \to W_1\), outgoing, so its valve is sequential or divergent, and \(W_2 \in B_X\) closes it.
That contradicts \(\alpha\) being unblocked, so every path from \(X\) to a node of \(Z_X\) is blocked by \(B_X\) and \(\mathrm{dsep}_G(\{X\}, B_X, Z_X)\).
Let \(G\) be a DAG and let \(\mathbf{X}\), \(\mathbf{Y}\), and \(\mathbf{Z}\) be three disjoint sets of nodes in \(G\). Let \(G^{\prime}\) be an undirected graph constructed from \(G\) according to the following steps:
- Every node is removed from \(G\) unless it is in \(\mathbf{X} \cup \mathbf{Y} \cup \mathbf{Z}\) or one of its descendants is in \(\mathbf{X} \cup \mathbf{Y} \cup \mathbf{Z}\).
- For every node in \(G\), every pair of its parents are connected by an undirected edge.
- Every directed edge in \(G\) is converted into an undirected edge.
Show that \(\mathrm{dsep}_G(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) if and only if \(\mathbf{X}\) and \(\mathbf{Y}\) are separated by \(\mathbf{Z}\) in \(G^{\prime}\) (i.e., every path between \(\mathbf{X}\) and \(\mathbf{Y}\) in \(G^{\prime}\) must pass through \(\mathbf{Z}\)).
We prove both directions in contrapositive form. Write \(\mathrm{An}(\mathbf{S})\) for \(\mathbf{S}\) together with all ancestors of its members; step 1 retains exactly \(\mathbf{A} = \mathrm{An}(\mathbf{X} \cup \mathbf{Y} \cup \mathbf{Z})\), which is ancestrally closed, so a retained node keeps all its parents, step 2 marries exactly the pairs of distinct parents in \(G\) of retained nodes, and step 3 keeps every \(G\)-edge with both endpoints retained. By Definition 4.2 a path is active given \(\mathbf{Z}\) when all its valves are open: a sequential or divergent valve at \(W\) iff \(W \notin \mathbf{Z}\), a convergent one iff \(W \in \mathrm{An}(\mathbf{Z})\). So \(\mathrm{dsep}_G(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) fails exactly when some \(\mathbf{X}\)-\(\mathbf{Y}\) path is active.
Lemma 1. Every node of an active \(\mathbf{X}\)-\(\mathbf{Y}\) path \(\alpha\) lies in \(\mathbf{A}\), hence survives step 1. The endpoints do. For internal \(W\): if its valve is convergent it is open, so \(W \in \mathrm{An}(\mathbf{Z})\). Otherwise \(W\) has an edge on \(\alpha\) outgoing from it; walk that way. Each node reached is entered along an edge directed into it, so its valve is sequential (and we leave along its outgoing edge) or convergent. Either we reach an endpoint by a directed path from \(W\), giving \(W \in \mathrm{An}(\mathbf{X}\cup\mathbf{Y})\), or we reach by a directed path the first node \(K\) with a convergent valve, which is open, giving \(K \in \mathrm{An}(\mathbf{Z})\) and so \(W \in \mathrm{An}(\mathbf{Z})\). (This is the argument in the book’s proof of Theorem 4.1.) \(\square\)
Lemma 2. Adjacent internal nodes of a path cannot both carry convergent valves, the edge between them having to be directed into each. \(\square\)
Direction 1: d-separation failing in \(G\) means separation failing in \(G^{\prime}\). Let \(\alpha : X = W_0, \ldots, W_m = Y\) be active with \(X \in \mathbf{X}\), \(Y \in \mathbf{Y}\); by Lemma 1 all its nodes are retained. Delete from \(\alpha\) every internal node with a convergent valve, obtaining \(\sigma\). By Lemma 2 the deleted nodes are pairwise non-adjacent on \(\alpha\), so consecutive nodes \(U, V\) of \(\sigma\) are either adjacent on \(\alpha\), whence \(U - V\) is an edge of \(G^{\prime}\) by step 3, or separated by one deleted \(W\) with \(U \to W \leftarrow V\), whence \(U - V\) is an edge of \(G^{\prime}\) by step 2, \(U\) and \(V\) being distinct parents of the retained \(W\). Its nodes being a sublist of those of \(\alpha\), \(\sigma\) is a path of \(G^{\prime}\) from \(X\) to \(Y\), and it avoids \(\mathbf{Z}\): the endpoints lie in \(\mathbf{X} \cup \mathbf{Y}\) and each surviving internal node carries an open sequential or divergent valve.
Direction 2: separation failing in \(G^{\prime}\) means d-separation failing in \(G\). Work with walks (consecutive nodes adjacent, repetitions allowed), valves being defined at internal positions as for paths. Call a walk \(\pi = W_0,\ldots,W_m\) admissible when (i) one endpoint lies in \(\mathbf{X}\) and the other in \(\mathbf{Y}\); (ii) every node lies in \(\mathbf{A}\); (iii) every sequential or divergent valve on \(\pi\) is open. By (iii) a closed valve on an admissible walk is convergent at some \(U \notin \mathrm{An}(\mathbf{Z})\); call it bad.
Step A: from a \(G^{\prime}\)-path to an admissible walk. Let \(\sigma : V_0, \ldots, V_k\) be a \(G^{\prime}\)-path with \(V_0 \in \mathbf{X}\), \(V_k \in \mathbf{Y}\), no \(V_i \in \mathbf{Z}\). Each edge of \(\sigma\) came from step 3, so is an edge of \(G\), or from step 2, so joins distinct parents of some retained \(C\); replace each edge of the second kind by \(V_i \to C \leftarrow V_{i+1}\). The resulting walk \(\pi\) satisfies (i); its nodes are the \(V_i\), which lie in \(\mathbf{A}\) as nodes of \(G^{\prime}\), and the inserted retained \(C\), giving (ii); and each inserted \(C\) carries a convergent valve, so every sequential or divergent valve sits at some \(V_i \notin \mathbf{Z}\), giving (iii).
Step B: an admissible walk with no bad valve exists. Induct on the number \(b\) of bad valves; for \(b > 0\) let \(U = W_i\) carry the leftmost, so \(W_{i-1} \to W_i \leftarrow W_{i+1}\) and the valves at \(1,\ldots,i-1\) are open. Since \(U \notin \mathrm{An}(\mathbf{Z})\) while \(U \in \mathbf{A}\), take a shortest directed path
\begin{equation*} U \to D_1 \to \cdots \to D_t = D , \qquad t \ge 0, \end{equation*}
to a node \(D \in \mathbf{X} \cup \mathbf{Y} \cup \mathbf{Z}\) (\(t = 0\) meaning \(D = U\)). As \(\mathbf{Z} \subseteq \mathrm{An}(\mathbf{Z})\) we get \(D \in \mathbf{X} \cup \mathbf{Y}\), so \(U, D \notin \mathbf{Z}\) by disjointness, minimality puts \(D_1,\ldots,D_{t-1}\) outside \(\mathbf{X} \cup \mathbf{Y} \cup \mathbf{Z}\), and every \(D_l\), an ancestor of \(D\), lies in \(\mathbf{A}\). Consider
\begin{equation*} \begin{aligned} \pi_1 &= W_0, \ldots, W_i, D_1, \ldots, D_t,\\ \pi_2 &= D_t, \ldots, D_1, W_i, W_{i+1}, \ldots, W_m . \end{aligned} \end{equation*}
In \(\pi_1\) the valves at \(W_1,\ldots,W_{i-1}\) are those of \(\pi\), hence open; the valve at \(W_i\) is \(W_{i-1} \to W_i \to D_1\), sequential with \(W_i \notin \mathbf{Z}\); and those at \(D_1,\ldots,D_{t-1}\) are sequential outside \(\mathbf{Z}\). So \(\pi_1\) satisfies (ii), (iii) and has no bad valve. In \(\pi_2\) the valves at \(D_{t-1},\ldots,D_1\) are sequential outside \(\mathbf{Z}\), that at \(W_i\) is \(W_{i+1} \to W_i \to D_1\), sequential and open, and those at \(W_{i+1},\ldots,W_{m-1}\) are the valves of \(\pi\) there; so \(\pi_2\) satisfies (ii), (iii) with exactly \(b-1\) bad valves. (For \(t = 0\), \(W_i\) becomes an endpoint carrying no valve and the checks at \(W_i\) and the \(D_l\) are simply absent.) If \(D\) lies in whichever of \(\mathbf{X}, \mathbf{Y}\) does not contain \(W_0\), then \(\pi_1\) satisfies (i) and we are done; otherwise \(D\) lies in the set not containing \(W_m\), so \(\pi_2\) satisfies (i) and the induction applies. Call an admissible walk with no bad valve active: all its valves are open.
Step C: an active walk yields an active path. Pick an active walk \(\pi = W_0,\ldots,W_m\) of minimum length with one endpoint in \(\mathbf{X}\) and the other in \(\mathbf{Y}\), and suppose \(W_i = W_j\) with \(i < j\). The shorter walk
\begin{equation*} \pi^{*} = W_0, \ldots, W_i, W_{j+1}, \ldots, W_m \end{equation*}
has the same endpoints, and every valve of it other than the one at position \(i\) is a valve of \(\pi\), hence open. If \(i = 0\) or \(j = m\), position \(i\) is an endpoint and no new valve arises. Otherwise let \(e\) join \(W_{i-1}\) to \(W_i\) and \(f\) join \(W_j\) to \(W_{j+1}\).
- (i) \(e\) outgoing from \(W_i\) (or, symmetrically, \(f\) outgoing from \(W_j = W_i\)): then the valve of \(\pi\) at \(i\) (at \(j\)) shares that outgoing edge, so it is sequential or divergent and, being open, gives \(W_i \notin \mathbf{Z}\); the new valve also has an outgoing edge, so it too is sequential or divergent, hence open.
- (ii) \(e\) and \(f\) both into \(W_i\): the new valve is convergent, open iff \(W_i \in \mathrm{An}(\mathbf{Z})\). If the valve of \(\pi\) at \(i\) or at \(j\) is convergent, it is open and gives exactly that. Otherwise both are sequential, \(W_{i-1} \to W_i \to W_{i+1}\) and \(W_{j+1} \to W_j \to W_{j-1}\). Traverse the closed walk \(W_i, W_{i+1}, \ldots, W_j = W_i\): its first edge runs along the traversal and its last against it, so there is a least \(r\) with \(i < r < j\) and \(W_{r+1} \to W_r\). By minimality \(W_i \to W_{i+1} \to \cdots \to W_r\) is directed and the valve of \(\pi\) at \(W_r\) is convergent, hence open, so \(W_r \in \mathrm{An}(\mathbf{Z})\) and \(W_i\), its ancestor, lies in \(\mathrm{An}(\mathbf{Z})\) too.
Either way \(\pi^{*}\) is a shorter active walk with the same endpoints, contradicting minimality. So the minimal active walk is a path: an unblocked \(\mathbf{X}\)-\(\mathbf{Y}\) path, and \(\mathrm{dsep}_G(\mathbf{X}, \mathbf{Z}, \mathbf{Y})\) fails. Chaining Steps A, B, C gives the contrapositive, and with Direction 1,
\begin{equation*} \mathrm{dsep}_G(\mathbf{X}, \mathbf{Z}, \mathbf{Y}) \iff \mathbf{X} \text{ and } \mathbf{Y} \text{ are separated by } \mathbf{Z} \text{ in } G^{\prime} . \end{equation*}
Let \(X\) and \(Y\) be two nodes in a DAG \(G\) that are not connected by an edge. Let \(\mathbf{Z}\) be a set of nodes defined as follows: \(Z \in \mathbf{Z}\) if and only if \(Z \notin \{X, Y\}\) and \(Z\) is an ancestor of \(X\) or an ancestor of \(Y\). Show that \(\mathrm{dsep}_G(X, \mathbf{Z}, Y)\).
By the definition of \(\mathbf{Z}\),
\begin{equation*} \{X, Y\} \cup \mathbf{Z} \;=\; \mathrm{An}(\{X, Y\}), \qquad \mathbf{Z} \;=\; \mathrm{An}(\{X,Y\}) \setminus \{X, Y\}, \end{equation*}
writing \(\mathrm{An}(\mathbf{S})\) for \(\mathbf{S}\) with all ancestors of its members; the three sets \(\{X\}\), \(\{Y\}\), \(\mathbf{Z}\) are pairwise disjoint, so the statement is well formed, and \(\mathrm{An}(\{X,Y\})\) being ancestrally closed gives \(\mathrm{An}(\mathbf{Z}) \subseteq \{X,Y\} \cup \mathbf{Z}\).
Suppose some path \(\alpha : X = W_0 - W_1 - \cdots - W_m = Y\) is unblocked by \(\mathbf{Z}\). Lemma 1 of Exercise 4.24 places every node of \(\alpha\) in \(\mathrm{An}(\{X,Y\}\cup\mathbf{Z}) = \mathrm{An}(\{X,Y\})\), and path nodes are distinct, so every internal node of \(\alpha\) lies in \(\mathrm{An}(\{X,Y\})\setminus\{X,Y\} = \mathbf{Z}\) and hence carries a convergent valve, a sequential or divergent valve at a node of \(\mathbf{Z}\) being closed. By Lemma 2 of Exercise 4.24 adjacent internal nodes cannot both be convergent, so \(\alpha\) has at most one internal node, and it has at least one since \(X\) and \(Y\) are not joined by an edge. Hence \(m = 2\) and \(\alpha\) is
\begin{equation*} X \to W_1 \leftarrow Y , \end{equation*}
with \(W_1 \in \mathbf{Z}\) an ancestor of \(X\) or of \(Y\); the directed path from \(W_1\) to that node closes a cycle with the edge \(X \to W_1\) or \(Y \to W_1\), against the acyclicity of \(G\). So no path is unblocked and \(\mathrm{dsep}_G(X, \mathbf{Z}, Y)\).
Method (2): in Exercise 4.24 the retained set is \(\mathbf{A} = \{X,Y\}\cup\mathbf{Z}\), so a \(G^{\prime}\)-path from \(X\) to \(Y\) avoiding \(\mathbf{Z}\) has no internal node, i.e. \(X\) and \(Y\) are adjacent in \(G^{\prime}\). That needs \(X\) and \(Y\) adjacent in \(G\), excluded, or both parents of some retained \(C \in \mathbf{Z}\), which is an ancestor of \(X\) or \(Y\) and again closes a directed cycle. So \(\mathbf{Z}\) separates \(X\) from \(Y\) in \(G^{\prime}\), and Exercise 4.24 applies.
Building Bayesian Networks
Exercises 5.1–5.7
Joe’s x-ray test comes back positive for lung cancer. The test’s false negative rate is \(f_n = .40\) and its false positive rate is \(f_p = .02\). We also know that the prior probability of having lung cancer is \(c = .001\). Describe a Bayesian network and a corresponding query for computing the probability that Joe has lung cancer given his positive x-ray. What is the value of this probability? Use sensitivity analysis to identify necessary and sufficient conditions on each of \(f_n\), \(f_p\), and \(c\) that guarantee the probability of cancer to be no less than 10% given a positive x-ray test.
Network. Two binary variables: the query variable \(C\) with values \(\text{yes}\) and \(\text{no}\), and the evidence variable \(T\) with values \(+\) and \(-\). Cancer is the only direct cause named, so the structure is the single edge
\begin{equation*} C \longrightarrow T . \end{equation*}
The CPTs are read off the statement, the prior for \(C\) being the prevalence \(c\):
| \(C\) | \(\theta_C\) |
|---|---|
| yes | \(c = .001\) |
| no | \(.999\) |
The CPT for \(T\) is the test specification, a false negative being a \(-\) on a cancer patient and a false positive a \(+\) on a healthy one:
| \(C\) | \(T\) | \(\theta_{T\mid C}\) |
|---|---|---|
| yes | \(+\) | \(1 - f_n = .60\) |
| yes | \(-\) | \(f_n = .40\) |
| no | \(+\) | \(f_p = .02\) |
| no | \(-\) | \(1 - f_p = .98\) |
Query. The posterior marginal \(\Pr(C = \text{yes} \mid T = +)\), with evidence \(T = +\).
Value. By the chain rule for Bayesian networks \(\Pr(C,T)=\theta_C\,\theta_{T\mid C}\), so
\begin{equation*} \begin{aligned} \Pr(C=\text{yes}\mid T=+) &= \frac{c\,(1-f_n)}{c\,(1-f_n) + (1-c)\,f_p} \\[2pt] &= \frac{(.001)(.60)}{(.001)(.60) + (.999)(.02)} \\[2pt] &= \frac{.0006}{.0006 + .01998} = \frac{.0006}{.02058} = \frac{10}{343} . \end{aligned} \end{equation*}
that is, \(\Pr(C=\text{yes}\mid T=+) \approx 2.92\%\).
Sensitivity analysis. Clearing the denominator, which is positive whenever the evidence has nonzero probability, gives the necessary and sufficient condition
\begin{equation*} \frac{c(1-f_n)}{c(1-f_n)+(1-c)f_p} \ \ge\ \frac{1}{10} \iff 9\,c\,(1-f_n) \ \ge\ (1-c)\,f_p , \end{equation*}
and solving it for one parameter with the other two at their stated values:
- \(f_p\): \(.0054 \ge .999\,f_p\), so \(f_p \le 1/185 \approx .0054\), a fourfold improvement.
- \(c\): \(5.42\,c \ge .02\), so \(c \ge 1/271 \approx .00369\), nearly four times the prevalence.
- \(f_n\): \(.009\,(1-f_n) \ge .01998\), so \(1 - f_n \ge 111/50 = 2.22\), impossible. No value of \(f_n\) works; even \(f_n = 0\) gives only \(.001/(.001+.01998) \approx 4.77\%\).
We have three identical and independent temperature sensors that will trigger in:
- 90% of the cases where the temperature is high
- 5% of the cases where the temperature is nominal
- 1% of the cases where the temperature is low.
The probability of high temperature is 20%, nominal temperature is 70%, and low temperature is 10%. Describe a Bayesian network and corresponding queries for computing the following:
- (a) Probability that the first sensor will trigger given that the other two sensors have also triggered
- (b) Probability that the temperature is high given that all three sensors have triggered
- (c) Probability that the temperature is high given that at least one sensor has triggered
Network. Let \(T\) have values \(\text{high}\), \(\text{nominal}\), \(\text{low}\) and let \(S_1, S_2, S_3\) be binary with values \(\text{on}\) and \(\text{off}\). The temperature is the only direct cause of each reading and the sensors are independent given it, so the structure is the naive Bayes star
\begin{equation*} S_1 \longleftarrow T \longrightarrow S_2, \qquad T \longrightarrow S_3 , \end{equation*}
that is, \(T\) is a root and each \(S_i\) has \(T\) as its only parent. The CPTs are
| \(T\) | \(\theta_T\) |
|---|---|
| high | \(.20\) |
| nominal | \(.70\) |
| low | \(.10\) |
and, identically for \(i = 1,2,3\),
| \(T\) | \(S_i\) | \(\theta_{S_i \mid T}\) |
|---|---|---|
| high | on | \(.90\) |
| nominal | on | \(.05\) |
| low | on | \(.01\) |
(the rows for \(S_i = \text{off}\) are the complements and are omitted as redundant).
For (c) the event “at least one sensor triggered” is a disjunction, the value of no variable of the network, so by the technique of Section 5.3.1 add a binary auxiliary variable \(O\) with parents \(S_1, S_2, S_3\) and the deterministic or-gate CPT
\begin{equation*} \Pr(O=\text{true}\mid s_1,s_2,s_3) = \begin{cases} 1, & \text{if some } s_i = \text{on},\\ 0, & \text{otherwise}, \end{cases} \end{equation*}
turning the disjunctive evidence into the ordinary evidence \(O = \text{true}\).
Write \(\alpha_t = \theta_t\) and \(\sigma_t = \Pr(S_i=\text{on}\mid t)\); the \(S_i\) being independent given \(T\),
\begin{equation*} \Pr(s_1,s_2,s_3) = \sum_{t} \alpha_t \prod_{i} \Pr(s_i \mid t). \end{equation*}
(a) The query is \(\Pr(S_1 = \text{on} \mid S_2=\text{on}, S_3=\text{on})\), and \(S_1\) is not independent of \(S_2, S_3\), the unobserved common parent \(T\) leaving \(S_1 \leftarrow T \rightarrow S_2\) unblocked (Definition 4.2). Two sums are needed:
\begin{equation*} \begin{aligned} \Pr(S_2,S_3 \text{ on}) &= \sum_t \alpha_t \sigma_t^2 \\ &= (.2)(.81) + (.7)(.0025) + (.1)(.0001) \\ &= .162 + .00175 + .00001 \;=\; .16376, \end{aligned} \end{equation*}
\begin{equation*} \begin{aligned} \Pr(S_1,S_2,S_3 \text{ on}) &= \sum_t \alpha_t \sigma_t^3 \\ &= (.2)(.729) + (.7)(.000125) + (.1)(.000001) \\ &= .1458 + .0000875 + .0000001 \;=\; .1458876 . \end{aligned} \end{equation*}
Hence
\begin{equation*} \Pr(S_1=\text{on}\mid S_2,S_3 \text{ on}) = \frac{.1458876}{.16376} = \frac{364719}{409400} \approx .8909 . \end{equation*}
Two triggers raise the chance that the third fires from its prior \(\sum_t \alpha_t \sigma_t = .216\) to about \(89.1\%\).
(b) The query is \(\Pr(T = \text{high} \mid S_1,S_2,S_3 \text{ on})\), and the numerator terms are already computed:
\begin{equation*} \Pr(T=\text{high}\mid S_1,S_2,S_3 \text{ on}) = \frac{.1458}{.1458876} = \frac{121500}{121573} \approx .99940 . \end{equation*}
(c) The query is \(\Pr(T=\text{high}\mid O=\text{true})\), and conditional independence of the sensors gives \(\Pr(O = \text{true} \mid t) = 1 - (1-\sigma_t)^3\):
| \(T\) | \(\alpha_t\) | \(1-(1-\sigma_t)^3\) | \(\alpha_t\,[1-(1-\sigma_t)^3]\) |
|---|---|---|---|
| high | \(.20\) | \(.999\) | \(.1998\) |
| nominal | \(.70\) | \(.142625\) | \(.0998375\) |
| low | \(.10\) | \(.029701\) | \(.0029701\) |
Summing the last column, \(\Pr(O=\text{true}) = .3026076\), so
\begin{equation*} \Pr(T=\text{high}\mid O=\text{true}) = \frac{.1998}{.3026076} = \frac{166500}{252173} \approx .6603 . \end{equation*}
Suppose that we apply three test vectors to the circuit in Figure 5.14, where each gate is initially ok with probability .99. As we change the test vector, a gate that is ok may become faulty with probability .01, and a gate that is faulty may become ok with probability .001.
The circuit of Figure 5.14(a) has primary inputs \(A\) and \(B\) and primary output \(E\). It contains three gates: an inverter \(X\) whose input is \(A\) and whose output is the internal wire \(C\); an and-gate \(Y\) whose inputs are \(A\) and \(B\) and whose output is the internal wire \(D\); and an or-gate \(Z\) whose inputs are \(C\) and \(D\) and whose output is \(E\). The Bayesian network of Figure 5.14(b) accordingly has roots \(A\), \(B\), \(X\), \(Y\), \(Z\) and edges
\begin{equation*} A \to C,\quad X \to C,\quad A \to D,\quad B \to D,\quad Y \to D, \end{equation*}
\begin{equation*} C \to E,\quad D \to E,\quad Z \to E . \end{equation*}
Wires take values \(\text{low}\) / \(\text{high}\) and health variables take values \(\text{ok}\) / \(\text{faulty}\). A gate that is ok computes its logical function; a gate that is faulty outputs \(\text{high}\) with probability \(.5\) regardless of its inputs. The primary inputs are uniform.
- (a) What are the posterior marginals for the health variables given the following test vectors?
- \(A = \text{high}\), \(B = \text{high}\), \(E = \text{low}\)
- \(A = \text{low}\), \(B = \text{low}\), \(E = \text{high}\)
- \(A = \text{low}\), \(B = \text{high}\), \(E = \text{high}\)
- (b) What about the following test vectors?
- \(A = \text{high}\), \(B = \text{high}\), \(E = \text{low}\)
- \(A = \text{low}\), \(B = \text{low}\), \(E = \text{high}\)
- \(A = \text{low}\), \(B = \text{high}\), \(E = \text{low}\)
- (c) What are the MPE and MAP (over health variables) for each of the cases in (a) and (b)?
Assume that the test vectors are applied in the order given.
Network. Faults being intermittent, use the dynamic Bayesian network of Figure 5.15(a) over three time slices; slice \(t \in \{1,2,3\}\) holds a full copy of the circuit network,
\begin{equation*} A_t,\ B_t,\ X_t,\ Y_t,\ Z_t,\ C_t,\ D_t,\ E_t , \end{equation*}
with the intra-slice edges listed in the statement, and consecutive slices are linked by the persistence edges \(X_t \to X_{t+1}\), \(Y_t \to Y_{t+1}\), \(Z_t \to Z_{t+1}\). The health CPTs are the prior in slice \(1\) and the persistence model in slices \(2\) and \(3\) (identically for \(Y\) and \(Z\)):
| \(X_1\) | \(\theta\) |
|---|---|
| ok | \(.99\) |
| faulty | \(.01\) |
| \(X_t\) | \(X_{t+1}\) | \(\theta\) |
|---|---|---|
| ok | ok | \(.99\) |
| ok | faulty | \(.01\) |
| faulty | ok | \(.001\) |
| faulty | faulty | \(.999\) |
The gate CPTs are the two-valued ones of Section 5.3.5, for example
| \(A\) | \(X\) | \(C\) | \(\theta_{c\mid a,x}\) |
|---|---|---|---|
| high | ok | high | \(0\) |
| low | ok | high | \(1\) |
| high | faulty | high | \(.5\) |
| low | faulty | high | \(.5\) |
and analogously \(\Pr(D=\text{high}\mid a,b,Y=\text{ok}) = [\![a \wedge b]\!]\), \(\Pr(D=\text{high}\mid a,b,Y=\text{faulty}) = .5\), and \(\Pr(E=\text{high}\mid c,d,Z=\text{ok}) = [\![c \vee d]\!]\), \(\Pr(E=\text{high}\mid c,d,Z=\text{faulty}) = .5\).
Reduction. Write \(h_t = (x_t,y_t,z_t)\) for the health state in slice \(t\) and \(e_t = (a_t,b_t,\varepsilon_t)\) for the \(t\)-th test vector. The inputs \(A_t, B_t\) are roots d-separated from the health variables, so as in Section 5.3.5 their CPTs cancel and
\begin{equation*} \Pr(h_1,h_2,h_3 \mid e_1,e_2,e_3) \ \propto\ \Pr(h_1)\Pr(h_2\mid h_1)\Pr(h_3\mid h_2)\prod_{t=1}^{3} L_t(h_t), \end{equation*}
where \(L_t(h) = \Pr(\varepsilon_t \mid a_t,b_t,h)\) comes from eliminating \(C_t\) and \(D_t\). Rows below are \((X,Y,Z)\) with \(\text{o} = \text{ok}\), \(\text{f} = \text{faulty}\); columns are the test vectors, \(hhl\) abbreviating \(A = \text{high}, B = \text{high}, E = \text{low}\):
| \((X,Y,Z)\) | \(hhl\) | \(llh\) | \(lhh\) | \(lhl\) |
|---|---|---|---|---|
| o,o,o | \(0\) | \(1\) | \(1\) | \(0\) |
| o,o,f | \(1/2\) | \(1/2\) | \(1/2\) | \(1/2\) |
| o,f,o | \(1/2\) | \(1\) | \(1\) | \(0\) |
| o,f,f | \(1/2\) | \(1/2\) | \(1/2\) | \(1/2\) |
| f,o,o | \(0\) | \(1/2\) | \(1/2\) | \(1/2\) |
| f,o,f | \(1/2\) | \(1/2\) | \(1/2\) | \(1/2\) |
| f,f,o | \(1/4\) | \(3/4\) | \(3/4\) | \(1/4\) |
| f,f,f | \(1/2\) | \(1/2\) | \(1/2\) | \(1/2\) |
The zero entries check out: under \(hhl\), \(Y\) ok forces \(D = \text{high}\) and then \(Z\) ok forces \(E = \text{high}\) whatever \(C\) is, killing rows (o,o,o) and (f,o,o); under \(lhl\), \(X\) ok gives \(C = \text{high}\) and \(Z\) ok forces \(E = \text{high}\), killing every row with \(X\) and \(Z\) both ok. Summing the \(8^3 = 512\) terms gives normalizing constants \(\Pr(\varepsilon_1,\varepsilon_2,\varepsilon_3\mid a,b) \approx 6.0751\times 10^{-3}\) for (a) and \(\approx 1.3097 \times 10^{-3}\) for (b).
(a) Posterior marginals.
| variable | \(\Pr(\cdot=\text{faulty}\mid e)\) |
|---|---|
| \(X_1\) | \(.00433\) |
| \(Y_1\) | \(.79551\) |
| \(Z_1\) | \(.20655\) |
| \(X_2\) | \(.01086\) |
| \(Y_2\) | \(.79677\) |
| \(Z_2\) | \(.20778\) |
| \(X_3\) | \(.01879\) |
| \(Y_3\) | \(.79801\) |
| \(Z_3\) | \(.21137\) |
The inverter \(X\) is cleared and the blame falls on \(Y\) (\(\approx 80\%\)) and \(Z\) (\(\approx 21\%\)): only the first vector is abnormal, and the \(Y\) explanation costs nothing on the other two (\(L = 1\) at (o,f,o)) while the \(Z\) explanation pays \(1/2\) on each, the \(4:1\) odds ratio the marginals reflect.
(b) Posterior marginals.
| variable | \(\Pr(\cdot=\text{faulty}\mid e)\) |
|---|---|
| \(X_1\) | \(.01313\) |
| \(Y_1\) | \(.05691\) |
| \(Z_1\) | \(.95262\) |
| \(X_2\) | \(.02968\) |
| \(Y_2\) | \(.06627\) |
| \(Z_2\) | \(.96195\) |
| \(X_3\) | \(.04840\) |
| \(Y_3\) | \(.07552\) |
| \(Z_3\) | \(.98049\) |
The third vector cannot be explained by a faulty \(Y\) at all, \(X\) ok making \(C\) high and an ok \(Z\) then forcing \(E\) high, so a \(Y\)-based story needs a second fault, whereas one persistent fault in \(Z\) covers both abnormal vectors.
(c) MPE and MAP. MAP is taken over the nine health variables \(X_1,Y_1,Z_1,\dots,X_3,Y_3,Z_3\); MPE is taken over all non-evidence variables, i.e. the health variables together with the internal wires \(C_t, D_t\).
Case (a). The MAP answer is
| slice | \(X\) | \(Y\) | \(Z\) |
|---|---|---|---|
| 1 | ok | faulty | ok |
| 2 | ok | faulty | ok |
| 3 | ok | faulty | ok |
with \(\Pr(\text{MAP}\mid e) \approx 77.33\%\), a persistent and-gate fault; the runner-up, \(X,Y\) ok and \(Z\) faulty throughout, sits at \(\approx 19.33\%\), a factor \(4\) behind through the \((1/2)^2\) penalty the \(Z\) story pays on the two normal vectors.
The MPE is not a completion of the MAP answer and is not unique: its probability is \(\approx 19.33\%\), with five tied instantiations. One extends the \(Z\)-fault hypothesis,
\begin{equation*} \begin{aligned} &X_t = Y_t = \text{ok},\ Z_t = \text{faulty}\ (t=1,2,3),\\ &(C_1,D_1) = (\text{low},\text{high}),\quad (C_2,D_2) = (C_3,D_3) = (\text{high},\text{low}), \end{aligned} \end{equation*}
and the other four extend the \(Y\)-fault hypothesis,
\begin{equation*} \begin{aligned} &X_t = Z_t = \text{ok},\ Y_t = \text{faulty}\ (t=1,2,3),\\ &(C_1,D_1) = (\text{low},\text{low}),\quad C_2 = C_3 = \text{high}, \end{aligned} \end{equation*}
with \(D_2\) and \(D_3\) free, four equally likely combinations, a faulty \(Y\) making \(D\) a coin flip while \(C = \text{high}\) already forces \(E = \text{high}\). The \(Y\) hypothesis wins the MAP by spreading its mass over four wire completions, each only as likely as the single \(Z\)-fault completion, which is why the \(Z\) hypothesis’s MAP and the MPE coincide at \(19.33\%\).
Case (b). MAP and MPE agree. The MAP answer is
| slice | \(X\) | \(Y\) | \(Z\) |
|---|---|---|---|
| 1 | ok | ok | faulty |
| 2 | ok | ok | faulty |
| 3 | ok | ok | faulty |
with \(\Pr(\text{MAP}\mid e) \approx 89.68\%\), and the MPE is its unique completion
\begin{equation*} (C_1,D_1) = (\text{low},\text{high}),\qquad (C_2,D_2) = (C_3,D_3) = (\text{high},\text{low}), \end{equation*}
also at \(\approx 89.68\%\) and with no ties. The runner-up is far behind: \(Y\) faulty throughout with \(Z\) also faulty in slice \(3\), at \(\approx 1.81\%\), the double fault the third test vector forces on any \(Y\)-based explanation.
We have two sensors that are meant to detect extreme temperature, which occurs 20% of the time. The sensors have identical specifications with a false positive rate of 1% and a false negative rate of 3%. If the power is off (dead battery), the sensors will read negative regardless of the temperature. Suppose now that we have two sensor kits: Kit A where both sensors receive power from the same battery and Kit B where they receive power from independent batteries. Assuming that each battery has a .9 probability of power availability, what is the probability of extreme temperature given each of the following scenarios:
- (a) The two sensors read negative
- (b) The two sensors read positive
- (c) One sensor reads positive while the other reads negative.
Answer the previous questions with respect to each of the two kits.
Networks. Let \(T\) have values \(\text{extreme}\) and \(\text{normal}\) with \(\Pr(T=\text{extreme}) = .2\) and let \(S_1, S_2\) be the readings, values \(+\) and \(-\). Each reading has two direct causes, the temperature and the power driving it, and the kits differ only in the number of battery variables.
Kit A (shared battery) has one root \(B\) with \(\Pr(B=\text{on}) = .9\) and structure
\begin{equation*} \begin{aligned} &S_1 \longleftarrow T \longrightarrow S_2,\\ &S_1 \longleftarrow B \longrightarrow S_2 . \end{aligned} \end{equation*}
Kit B (independent batteries) has two roots \(B_1,B_2\), each with \(\Pr(B_i=\text{on}) = .9\), and structure
\begin{equation*} S_1 \longleftarrow T \longrightarrow S_2, \qquad B_1 \to S_1, \qquad B_2 \to S_2 . \end{equation*}
The sensor CPT is the same in both kits, the specifications being identical: a false positive is a \(+\) on a normal temperature, a false negative a \(-\) on an extreme one, and a dead battery forces \(-\):
| \(T\) | battery | \(S_i\) | \(\theta\) |
|---|---|---|---|
| extreme | on | \(+\) | \(.97\) |
| normal | on | \(+\) | \(.01\) |
| extreme | off | \(+\) | \(0\) |
| normal | off | \(+\) | \(0\) |
The queries are the posterior marginals \(\Pr(T=\text{extreme}\mid s_1,s_2)\); for (c) take \(S_1 = +\), \(S_2 = -\), the other ordering giving the same posterior by symmetry.
Kit A. Case on \(B\), the only unobserved root besides \(T\): with \(B\) on the readings are independent given \(T\), with \(B\) off both are \(-\) with probability \(1\).
(a) Both negative. With the battery on a negative costs \(.03\) under an extreme temperature and \(.99\) under a normal one:
\begin{equation*} \begin{aligned} \Pr(-,-,\text{extreme}) &= .2\,[\,.9(.03)^2 + .1\,] = .2(.10081) = .020162,\\ \Pr(-,-,\text{normal}) &= .8\,[\,.9(.99)^2 + .1\,] = .8(.98209) = .785672, \end{aligned} \end{equation*}
so \(\Pr(-,-) = .805834\) and
\begin{equation*} \Pr(T=\text{extreme}\mid -,-) = \frac{.020162}{.805834} = \frac{593}{23701} \approx .0250 . \end{equation*}
(b) Both positive. A \(+\) is impossible with a dead battery, so \(B=\text{off}\) drops out:
\begin{equation*} \begin{aligned} \Pr(+,+,\text{extreme}) &= .2(.9)(.97)^2 = .169362,\\ \Pr(+,+,\text{normal}) &= .8(.9)(.01)^2 = .000072, \end{aligned} \end{equation*}
\begin{equation*} \Pr(T=\text{extreme}\mid +,+) = \frac{.169362}{.169434} = \frac{9409}{9413} \approx .99958 . \end{equation*}
(c) Mixed. The positive reading again forces \(B=\text{on}\):
\begin{equation*} \begin{aligned} \Pr(+,-,\text{extreme}) &= .2(.9)(.97)(.03) = .005238,\\ \Pr(+,-,\text{normal}) &= .8(.9)(.01)(.99) = .007128, \end{aligned} \end{equation*}
\begin{equation*} \Pr(T=\text{extreme}\mid +,-) = \frac{.005238}{.012366} = \frac{97}{229} \approx .4236 . \end{equation*}
Kit B. The roots \(B_1, B_2\) being separate, fold each battery into its own sensor; given \(T\) the readings are independent, with effective per-sensor probabilities
\begin{equation*} \begin{aligned} \Pr(+\mid \text{extreme}) &= .9(.97) = .873, &\Pr(-\mid \text{extreme}) &= .127,\\ \Pr(+\mid \text{normal}) &= .9(.01) = .009, &\Pr(-\mid \text{normal}) &= .991 . \end{aligned} \end{equation*}
(a) Both negative.
\begin{equation*} \begin{aligned} \Pr(-,-,\text{extreme}) &= .2(.127)^2 = .0032258,\\ \Pr(-,-,\text{normal}) &= .8(.991)^2 = .7856648, \end{aligned} \end{equation*}
\begin{equation*} \Pr(T=\text{extreme}\mid -,-) = \frac{.0032258}{.7888906} = \frac{16129}{3944453} \approx .00409 . \end{equation*}
(b) Both positive.
\begin{equation*} \begin{aligned} \Pr(+,+,\text{extreme}) &= .2(.873)^2 = .1524258,\\ \Pr(+,+,\text{normal}) &= .8(.009)^2 = .0000648, \end{aligned} \end{equation*}
\begin{equation*} \Pr(T=\text{extreme}\mid +,+) = \frac{.1524258}{.1524906} = \frac{9409}{9413} \approx .99958 . \end{equation*}
(c) Mixed.
\begin{equation*} \begin{aligned} \Pr(+,-,\text{extreme}) &= .2(.873)(.127) = .0221742,\\ \Pr(+,-,\text{normal}) &= .8(.009)(.991) = .0071352, \end{aligned} \end{equation*}
\begin{equation*} \Pr(T=\text{extreme}\mid +,-) = \frac{.0221742}{.0293094} = \frac{12319}{16283} \approx .7566 . \end{equation*}
Summary.
| scenario | Kit A (shared battery) | Kit B (independent batteries) |
|---|---|---|
| (a) \(-\,-\) | \(.0250\) | \(.00409\) |
| (b) \(+\,+\) | \(.99958\) | \(.99958\) |
| (c) \(+\,-\) | \(.4236\) | \(.7566\) |
Case (b) agrees across kits because a positive reading entails a live battery, so both networks reduce to the same naive Bayes model with sensor probabilities \(.97\) and \(.01\), giving \(.2(.97)^2 / [.2(.97)^2 + .8(.01)^2] = 9409/9413\). Under \(-,-\) Kit A keeps about six times as much belief in an extreme temperature, the shared battery supplying one common-cause explanation of both negatives where Kit B would need two failures at \((.1)^2\); under \(+,-\) the comparison reverses, the positive reading proving Kit A’s shared battery live while saying nothing about Kit B’s other battery.
Jack has three coins \(C_1\), \(C_2\), and \(C_3\) with \(p_1\), \(p_2\), and \(p_3\) as their corresponding probabilities of landing heads. Jack flips coin \(C_1\) twice and then decides, based on the outcome, whether to flip coin \(C_2\) or \(C_3\) next. In particular, if the two \(C_1\) flips come out the same, Jack flips coin \(C_2\) three times next. However, if the \(C_1\) flips come out different, he flips coin \(C_3\) three times next. Given the outcome of Jack’s last three flips, we want to know whether his first two flips came out the same. Describe a Bayesian network and a corresponding query that solves this problem. What is the solution to this problem assuming that \(p_1 = .4\), \(p_2 = .6\), and \(p_3 = .1\) and the last three flips came out as follows:
- (a) tails, heads, tails
- (b) tails, tails, tails
Network. Take five flip variables \(F_1,\dots,F_5\) with values \(h\) and \(t\), where \(F_1,F_2\) are the \(C_1\) flips and \(F_3,F_4,F_5\) the last three, plus an auxiliary variable \(S\) with values \(\text{same}\) and \(\text{different}\) recording the comparison that governs Jack’s decision (the device of Section 5.3.1, turning an event that is the value of no natural variable into one that can be queried). The causal story gives
\begin{equation*} F_1 \to S \leftarrow F_2, \qquad S \to F_3, \quad S \to F_4, \quad S \to F_5 . \end{equation*}
\(F_1\) and \(F_2\) are roots with \(\Pr(F_i = h) = p_1 = .4\); \(S\) is a deterministic child of \(F_1,F_2\) (an equivalence gate),
| \(F_1\) | \(F_2\) | \(S\) | \(\theta\) |
|---|---|---|---|
| h | h | same | \(1\) |
| h | t | same | \(0\) |
| t | h | same | \(0\) |
| t | t | same | \(1\) |
and each of \(F_3,F_4,F_5\) has \(S\) as its only parent, the value of \(S\) selecting which coin is being flipped:
| \(S\) | \(F_j\) | \(\theta\) |
|---|---|---|
| same | h | \(p_2 = .6\) |
| different | h | \(p_3 = .1\) |
Query. The posterior marginal \(\Pr(S = \text{same} \mid F_3,F_4,F_5)\), whose prior is
\begin{equation*} \Pr(S=\text{same}) = p_1^2 + (1-p_1)^2 = .16 + .36 = .52 . \end{equation*}
The flips being independent given \(S\), the likelihoods are products of coin parameters; writing \(L_2, L_3\) for the likelihood of the observed triple under \(C_2\) and under \(C_3\),
\begin{equation*} \Pr(S=\text{same}\mid e) = \frac{.52\,L_2}{.52\,L_2 + .48\,L_3}. \end{equation*}
(a) \(t,h,t\).
\begin{equation*} \begin{aligned} L_2 &= (1-p_2)\,p_2\,(1-p_2) = (.4)(.6)(.4) = .096,\\ L_3 &= (1-p_3)\,p_3\,(1-p_3) = (.9)(.1)(.9) = .081 . \end{aligned} \end{equation*}
Hence \(\Pr(e, \text{same}) = (.52)(.096) = .04992\) and \(\Pr(e, \text{different}) = (.48)(.081) = .03888\), so \(\Pr(e) = .0888\) and
\begin{equation*} \Pr(S=\text{same}\mid e) = \frac{.04992}{.0888} = \frac{104}{185} \approx .5622 . \end{equation*}
The evidence is mild: \(L_2/L_3 = 32/27\), so the posterior barely moves from the prior \(.52\).
(b) \(t,t,t\).
\begin{equation*} L_2 = (.4)^3 = .064, \qquad L_3 = (.9)^3 = .729 . \end{equation*}
Hence \(\Pr(e,\text{same}) = (.52)(.064) = .03328\), \(\Pr(e,\text{different}) = (.48)(.729) = .34992\), so \(\Pr(e) = .3832\) and
\begin{equation*} \Pr(S=\text{same}\mid e) = \frac{.03328}{.3832} = \frac{208}{2395} \approx .0868 . \end{equation*}
Here \(L_3/L_2 \approx 11.4\) favours the tails-biased \(C_3\), flipped only when the first two flips differ, so the posterior on “same” drops from \(52\%\) to under \(9\%\).
Lisa is given a fair coin \(C_1\) and asked to flip it eight times in a row. Lisa also has a biased coin \(C_2\) with a probability .8 of landing heads. All we know is that Lisa flipped the fair coin initially but we believe that she intends to switch to the biased coin and that she tends to be 10% successful in performing the switch. Suppose that we observe the outcome of the eight coin flips and want to find out whether Lisa managed to perform a coin switch and when. Describe a Bayesian network and a corresponding query that solves this problem. What is the solution to this problem assuming that the flips came out as follows:
- (a) tails, tails, tails, heads, heads, heads, heads, heads
- (b) tails, tails, heads, heads, heads, heads, heads, heads
Network. A dynamic Bayesian network with eight slices: \(S_i\) is the coin in Lisa’s hand at flip \(i\), with values \(\text{fair}\) and \(\text{biased}\), and \(F_i\) the outcome, values \(h\) and \(t\). The structure is the chain
\begin{equation*} S_1 \to S_2 \to \cdots \to S_8, \qquad S_i \to F_i \ \ (i = 1,\dots,8), \end{equation*}
a hidden Markov model. The CPTs encode the three stated facts. Lisa flipped the fair coin initially:
| \(S_1\) | \(\theta\) |
|---|---|
| fair | \(1\) |
| biased | \(0\) |
Between consecutive flips she attempts the switch and succeeds \(10\%\) of the time; once the switch has happened it is not undone (she wanted the biased coin):
| \(S_i\) | \(S_{i+1}\) | \(\theta\) |
|---|---|---|
| fair | fair | \(.9\) |
| fair | biased | \(.1\) |
| biased | fair | \(0\) |
| biased | biased | \(1\) |
And the flips are governed by whichever coin is in hand:
| \(S_i\) | \(F_i\) | \(\theta\) |
|---|---|---|
| fair | h | \(.5\) |
| biased | h | \(.8\) |
Query. The MAP over \(S_1,\dots,S_8\) given the evidence \(F_1,\dots,F_8\). The transition CPT being deterministic in the \(\text{biased}\) row, every state sequence of positive probability is fair up to some point and biased thereafter, so the query reduces to a distribution over the nine hypotheses
\begin{equation*} K = \min\{\, i : S_i = \text{biased} \,\} \in \{2,3,\dots,8\} \cup \{\text{never}\}, \end{equation*}
and \(\Pr(S_8 = \text{biased}\mid e)\) is the probability of a switch at all. The unnormalized weight of \(K = k\) is
\begin{equation*} w_k = (.9)^{k-2}(.1)\cdot (.5)^{k-1}\prod_{i \ge k} \Pr(f_i \mid \text{biased}), \end{equation*}
the factor \((.5)^{k-1}\) being the likelihood of the first \(k-1\) flips under the fair coin; for “never”, \(\Pr(K=\text{never}) = (.9)^{7} = .4782969\) and \(w_{\text{never}} = (.9)^{7}(.5)^{8} = .00186835\).
(a) \(t,t,t,h,h,h,h,h\).
| \(k\) | \(\Pr(K=k)\) | \(\Pr(e\mid K=k)\) | \(w_k\) | \(\Pr(K=k\mid e)\) |
|---|---|---|---|---|
| 2 | \(.1\) | \(.0065536\) | \(.00065536\) | \(.0588\) |
| 3 | \(.09\) | \(.016384\) | \(.00147456\) | \(.1322\) |
| 4 | \(.081\) | \(.04096\) | \(.00331776\) | \(.2974\) |
| 5 | \(.0729\) | \(.0256\) | \(.00186624\) | \(.1673\) |
| 6 | \(.06561\) | \(.016\) | \(.00104976\) | \(.0941\) |
| 7 | \(.059049\) | \(.01\) | \(.00059049\) | \(.0529\) |
| 8 | \(.0531441\) | \(.00625\) | \(.00033215\) | \(.0298\) |
| never | \(.4782969\) | \(.00390625\) | \(.00186835\) | \(.1675\) |
The weights sum to \(\Pr(e) = .011154668\). The MAP answer is \(K = 4\), i.e.
\begin{equation*} S_1 = S_2 = S_3 = \text{fair}, \qquad S_4 = \cdots = S_8 = \text{biased}, \end{equation*}
at \(\approx 29.74\%\), with a switch occurring at all with probability \(1 - .1675 \approx 83.25\%\). The switch lands on the tails-to-heads boundary.
(b) \(t,t,h,h,h,h,h,h\).
| \(k\) | \(\Pr(K=k)\) | \(\Pr(e\mid K=k)\) | \(w_k\) | \(\Pr(K=k\mid e)\) |
|---|---|---|---|---|
| 2 | \(.1\) | \(.0262144\) | \(.00262144\) | \(.1494\) |
| 3 | \(.09\) | \(.065536\) | \(.00589824\) | \(.3362\) |
| 4 | \(.081\) | \(.04096\) | \(.00331776\) | \(.1891\) |
| 5 | \(.0729\) | \(.0256\) | \(.00186624\) | \(.1064\) |
| 6 | \(.06561\) | \(.016\) | \(.00104976\) | \(.0598\) |
| 7 | \(.059049\) | \(.01\) | \(.00059049\) | \(.0337\) |
| 8 | \(.0531441\) | \(.00625\) | \(.00033215\) | \(.0189\) |
| never | \(.4782969\) | \(.00390625\) | \(.00186835\) | \(.1065\) |
The weights sum to \(\Pr(e) = .017544428\). The MAP answer is \(K = 3\),
\begin{equation*} S_1 = S_2 = \text{fair}, \qquad S_3 = \cdots = S_8 = \text{biased}, \end{equation*}
at \(\approx 33.62\%\), with a switch occurring at all with probability \(1 - .1065 \approx 89.35\%\). Again the switch sits at the tails-to-heads boundary, the longer run of heads sharpening both its location and its occurrence.
Consider the system reliability problem in Section 5.3.6 and suppose that the two fans depend on a common condition \(C\) that materializes with a probability 99.5%. In particular, as long as the condition is established, each fan will have a reliability of 90%. However, if the condition is not established, both fans will fail. Develop a Bayesian network that corresponds to this scenario and compute the overall system reliability in this case.
For reference, the reliability block diagram of Figure 5.16 runs a power supply into two parallel fans, the fans into two parallel processors, and the processors into a hard drive. The Bayesian network of Figure 5.18 has component roots \(E\) (power supply, reliability \(99\%\)), \(F_1,F_2\) (fans, \(90\%\)), \(P_1,P_2\) (processors, \(96\%\)), and \(D\) (hard drive, \(98\%\)), each with values \(\text{avail}\) / \(\text{un avail}\), together with the gate variables
\begin{equation*} \begin{aligned} A_1 &= E \wedge F_1, & A_2 &= E \wedge F_2, & O_1 &= A_1 \vee A_2,\\ A_3 &= O_1 \wedge P_1, & A_4 &= O_1 \wedge P_2, & O_2 &= A_3 \vee A_4, \end{aligned} \end{equation*}
and \(S = O_2 \wedge D\), where \(S\) is the availability of the whole system. Its reliability \(\Pr(S = \text{avail})\) is \(\approx 95.9\%\).
The system reliability drops to \(\approx 95.42\%\). Network: the only change is to the fans, no longer independent roots. Add a root \(C\) with values \(\text{established}\) and \(\text{not established}\),
| \(C\) | \(\theta_C\) |
|---|---|
| established | \(.995\) |
| not established | \(.005\) |
and make \(C\) a parent of both fans, giving the edges \(C \to F_1\) and \(C \to F_2\). Every other node and edge of Figure 5.18 is unchanged. The fan CPTs become
| \(C\) | \(F_i\) | \(\theta_{F_i \mid C}\) |
|---|---|---|
| established | avail | \(.90\) |
| not established | avail | \(0\) |
which is the statement “given the condition each fan is \(90\%\) reliable; without it, both fans fail”. The fans are now dependent, \(C\) being the only d-separator: \(F_1 \not\perp F_2\) a priori while \(F_1 \perp F_2 \mid C\) (Definition 4.2).
Reliability. The roots \(C, E, P_1, P_2, D\) being independent and all internal nodes deterministic gates, propagate availabilities up the block diagram, eliminating \(C\) before combining the fans:
\begin{equation*} \begin{aligned} \Pr(F_1 \vee F_2) &= \Pr( C)\bigl[1 - (1-.9)^2\bigr] + \Pr(\neg C)\cdot 0 \\ &= (.995)(.99) \;=\; .98505 . \end{aligned} \end{equation*}
Then \(O_1 = E \wedge (F_1 \vee F_2)\), since \(A_1 \vee A_2 = (E \wedge F_1) \vee (E \wedge F_2)\), and \(E\) is independent of \(C, F_1, F_2\):
\begin{equation*} \Pr(O_1 = \text{avail}) = (.99)(.98505) = .9751995 . \end{equation*}
Likewise \(O_2 = O_1 \wedge (P_1 \vee P_2)\) with \(P_1, P_2\) independent roots, so
\begin{equation*} \begin{aligned} \Pr(P_1 \vee P_2) &= 1 - (1-.96)^2 = 1 - .0016 = .9984,\\ \Pr(O_2 = \text{avail}) &= (.9751995)(.9984) = .9736391808 . \end{aligned} \end{equation*}
Finally \(S = O_2 \wedge D\):
\begin{equation*} \Pr(S = \text{avail}) = (.9736391808)(.98) = .954166397184 . \end{equation*}
So the system reliability is \(\approx 95.42\%\), down from the \(\approx 95.90\%\) of Section 5.3.6. The fan block has fallen from \(1 - (.1)^2 = .99\) to \((.995)(.99) = .98505\), and no amount of parallel redundancy recovers it, since \(\Pr(F_1 \vee \cdots \vee F_n) = (.995)[1 - (.1)^n]\) is capped at \(\Pr( C) = .995\).
Exercises 5.8–5.14
Consider the electrical network depicted in Figure 5.33 and assume that electricity can flow in either direction between two adjacent stations \(S_i\) and \(S_j\) (i.e., connected by an edge), and that electricity is flowing into the network from sources \(I_1\) and \(I_2\). For the network to be operational, electricity must also flow out of either outlet \(O_1\) or outlet \(O_2\). Describe a Bayesian network and a corresponding query that allows us to compute the reliability of this network, given the reliability \(r_{ij}\) of each connection between stations \(S_i\) and \(S_j\). What is the reliability of the network if \(r_{ij} = .99\) for all connections?
Figure 5.33 shows five stations \(S_1,\dots,S_5\) wired into a single ring, together with two sources and two outlets tapped onto that ring:
- the connections between stations are \(S_1 - S_2\), \(S_2 - S_3\), \(S_3 - S_4\), \(S_4 - S_5\) and \(S_5 - S_1\) (so the five stations form a cycle);
- source \(I_1\) feeds into the connection \(S_5 - S_1\) (the arrow from \(I_1\) enters the corner joining the wire out of \(S_5\) to the wire into \(S_1\));
- source \(I_2\) feeds into the connection \(S_1 - S_2\) (the arrow from \(I_2\) enters the corner joining the wire out of \(S_2\) to the wire into \(S_1\));
- outlet \(O_1\) is tapped off the connection \(S_4 - S_5\);
- outlet \(O_2\) is tapped off the connection \(S_2 - S_3\).
The only unreliable elements are the five station-to-station connections; the taps themselves and the stations are perfectly reliable, and a connection either conducts over its whole length or not at all.
The network is \(99.96\%\) reliable.
The Bayesian network. The five connections of Figure 5.33 are the only unreliable elements, so introduce one root variable for each,
\begin{equation*} C_{12},\; C_{23},\; C_{34},\; C_{45},\; C_{51}, \end{equation*}
with values \(\mathsf{up}\) and \(\mathsf{down}\) and CPT \(\Pr(C_{ij} = \mathsf{up}) = r_{ij}\); everything else is a deterministic node in the sense of Section 5.4.2, making this a “model from design” as in Section 5.3.6.
Figure 5.33 is cyclic while a Bayesian network must be a DAG, so a single variable “station \(S_i\) is energized” with its neighbours as parents is not available. Unroll the propagation in stages instead, as one unrolls a dynamic system into a DBN (Section 5.3.5); with five stations any station reachable from a source is reachable in at most four hops, so four stages suffice.
For \(k = 0,1,2,3,4\) let \(E_i^k\) be binary, meaning “station \(S_i\) is energized by some conducting route of length at most \(k\)”. Stage \(0\) records the injections, \(I_1\) being tapped onto \(S_5 - S_1\) and \(I_2\) onto \(S_1 - S_2\), so that a conducting tapped connection energizes both its endpoints:
\begin{equation*} \begin{aligned} E_1^0 &\iff C_{51} \vee C_{12}, \\ E_5^0 &\iff C_{51}, \qquad E_2^0 \iff C_{12}, \\ E_3^0 &\iff \bot, \qquad\; E_4^0 \iff \bot . \end{aligned} \end{equation*}
One round of propagation along conducting connections gives the next stage,
\begin{equation*} E_i^{k+1} \iff E_i^{k} \;\vee\; \bigvee_{j \,\sim\, i} \bigl( E_j^{k} \wedge C_{ij} \bigr), \end{equation*}
\(j \sim i\) ranging over the ring neighbours of \(S_i\). So \(E_i^{k+1}\) has parents \(E_i^k\), the two neighbours’ \(E_j^k\) and the two \(C_{ij}\), and every edge runs from stage \(k\) to stage \(k+1\) or from a root into a stage variable: the structure is acyclic. These CPTs are deterministic, written straight from the propositional equivalences in the encoding of Section 5.4.2.
Three more deterministic nodes finish the model. Outlet \(O_1\), tapped onto \(S_4 - S_5\), is fed exactly when that connection conducts and one of its endpoints is energized, and likewise \(O_2\) on \(S_2 - S_3\):
\begin{equation*} \begin{aligned} A_1 &\iff C_{45} \wedge (E_4^4 \vee E_5^4), \\ A_2 &\iff C_{23} \wedge (E_2^4 \vee E_3^4), \\ S &\iff A_1 \vee A_2 . \end{aligned} \end{equation*}
The variable \(S\) says that the network is operational.
The query. The marginal \(\Pr(S = \mathsf{true})\), a probability-of-evidence query with no evidence, exactly as reliability was the marginal of the system node in Section 5.3.6; the MAP over \(C_{12},\dots,C_{51}\) given \(S = \mathsf{false}\) names the connection to blame for an outage.
Reducing the structure function. For this ring \(\Pr(S)\) has a closed form, since
\begin{equation*} S \iff (C_{12} \wedge C_{23}) \;\vee\; (C_{45} \wedge C_{51}), \end{equation*}
making \(S_3 - S_4\) irrelevant. Sufficiency: \(C_{51}\) conducting lets \(I_1\) energize \(S_5\), and then the tap of \(O_1\) on the conducting \(S_4 - S_5\) carries current; symmetrically \(C_{12} \wedge C_{23}\) feeds \(O_2\). Necessity: all electricity originates at the two taps, so the energized stations are those reachable through conducting connections from \(\{S_1,S_5\}\) (available only if \(C_{51}\) conducts) or from \(\{S_1,S_2\}\) (only if \(C_{12}\) conducts). Suppose \(O_1\) is fed, so \(C_{45}\) conducts and one of \(S_4, S_5\) is energized.
- If \(C_{51}\) conducts, \(C_{45} \wedge C_{51}\) holds.
- Otherwise all energy comes through the tap on \(S_1 - S_2\), so \(C_{12}\) conducts and the energized set is what is reachable from \(S_2\) along \(S_2 - S_3 - S_4 - S_5\); reaching \(S_4\) or \(S_5\) then forces \(C_{23}\), giving \(C_{12} \wedge C_{23}\).
The case of \(O_2\) follows by the symmetry of Figure 5.33: \(S_2 \leftrightarrow S_5\), \(S_3 \leftrightarrow S_4\) maps the ring to itself fixing \(S_1\) and \(C_{34}\), exchanges \(I_1\) with \(I_2\) and \(O_1\) with \(O_2\), and swaps \(C_{51}\) with \(C_{12}\) and \(C_{45}\) with \(C_{23}\).
The number. The path sets \(\{C_{12}, C_{23}\}\) and \(\{C_{45}, C_{51}\}\) are disjoint and the connection variables are independent roots, so the two events are independent:
\begin{equation*} \Pr(S) = 1 - (1 - r_{12} r_{23})\,(1 - r_{45} r_{51}). \end{equation*}
With \(r_{ij} = .99\) for every connection, \(r_{12} r_{23} = r_{45} r_{51} = .9801\) and
\begin{equation*} \begin{aligned} \Pr(S) &= 1 - (1 - .9801)^2 = 1 - (.0199)^2 \\ &= 1 - .00039601 = .99960399 . \end{aligned} \end{equation*}
Brute force over the \(2^5\) instantiations of the connection variables in the network above returns exactly \(99960399/100000000\), confirming the reduction.
Consider Section 5.3.6 and suppose we extend the language of RBDs to include \(k\)-out-of-\(n\) blocks. In particular, a block \(C\) is said to be of type \(k\)-out-of-\(n\) if it has \(n\) components pointing to it in the diagram, and at least \(k\) of them must be available for the subsystem represented by \(C\) to be available. Provide a systematic method for converting RBDs with \(k\)-out-of-\(n\) blocks into Bayesian networks.
Recall the semantics of Section 5.3.6: an RBD is a DAG with a single leaf, each node of which is a block. A block \(B\) represents the subsystem consisting of the component \(B\) together with all subsystems feeding into \(B\), and that subsystem is available iff component \(B\) is available and at least one of the subsystems feeding into \(B\) is available. The conversion of Figure 5.17 gives each block a component variable, an or-node over the availabilities of the incoming subsystems, and an and-node combining the two.
Replace the or-gate of Figure 5.17 by a threshold gate firing when at least \(k\) of its \(n\) inputs are available, and implement that gate as a saturating counter chain rather than a single CPT of size \(2^{n+1}\). Figure 5.17 is then the case \(k = 1\) and an and-gate the case \(k = n\).
Variables. Let the RBD have blocks \(B_1, \dots, B_m\), and for a block \(C\) let \(\mathrm{pa}( C) = \{D_1, \dots, D_n\}\) be the blocks pointing to \(C\), with threshold \(k\), \(1 \le k \le n\). Each block \(C\) gets two variables:
- a component variable \(C\) with values \(\mathsf{avail}\) and \(\mathsf{unavail}\);
- a subsystem variable \(S_C\) with values \(\mathsf{true}\) and \(\mathsf{false}\), meaning “the subsystem represented by block \(C\) is available”.
The component variables are roots with CPT \(\Pr(C = \mathsf{avail}) = r_C\), as for the roots \(E, F_1, F_2, P_1, P_2, D\) of Figure 5.18.
Threshold gate as a counter chain. For a block \(C\) with parents \(D_1, \dots, D_n\) and threshold \(k\), introduce counting variables
\begin{equation*} N_1^C, N_2^C, \dots, N_n^C, \qquad N_j^C \in \{0, 1, \dots, k\}, \end{equation*}
whose intended meaning is
\begin{equation*} N_j^C \;=\; \min\Bigl(k,\; \bigl|\{\, i \le j : S_{D_i} = \mathsf{true} \,\}\bigr| \Bigr), \end{equation*}
the number of available incoming subsystems among the first \(j\), saturated at \(k\). They are chained: \(N_1^C\) has the single parent \(S_{D_1}\), and \(N_j^C\) for \(j \ge 2\) has parents \(N_{j-1}^C\) and \(S_{D_j}\), with deterministic CPTs
\begin{equation*} \begin{aligned} N_1^C &= \begin{cases} 1, & S_{D_1} = \mathsf{true} \\ 0, & S_{D_1} = \mathsf{false} \end{cases} \\[4pt] N_j^C &= \begin{cases} \min(k,\, N_{j-1}^C + 1), & S_{D_j} = \mathsf{true} \\ N_{j-1}^C, & S_{D_j} = \mathsf{false}. \end{cases} \end{aligned} \end{equation*}
These realize the intended meaning by induction on \(j\): the case \(j = 1\) is immediate, and \(\min(k, c_{j-1}) + 1\) saturates to \(\min(k, c_j)\) because \(\min(k,\cdot)\) is monotone and idempotent above \(k\), while an unavailable parent leaves the count alone. (Check!) Hence at least \(k\) incoming subsystems are available iff \(N_n^C = k\).
Putting a block together. Define \(S_C\) by the deterministic CPT
\begin{equation*} S_C = \mathsf{true} \iff \bigl( C = \mathsf{avail} \bigr) \wedge \bigl( N_n^C = k \bigr), \end{equation*}
so \(S_C\) has parents \(C\) and \(N_n^C\) and a CPT of eight entries. A source block, one with \(n = 0\), carries no threshold condition and gets
\begin{equation*} S_C = \mathsf{true} \iff C = \mathsf{avail}, \end{equation*}
as Figure 5.18 does for the power supply, the only source block of Figure 5.16. Every CPT here except those of the component roots is deterministic, written in the propositional form of Section 5.4.2.
Acyclicity and query. Every edge runs from a component root into its own \(S_C\), from \(S_{D_i}\) into the counter chain of \(C\), or forward along a counter chain, and the RBD is a DAG with \(D_i\) a parent of \(C\), so the construction is a DAG. Its single leaf block \(L\) represents the whole system (Section 5.3.6), so the reliability is
\begin{equation*} \Pr(S_L = \mathsf{true}), \end{equation*}
and the most likely explanation of a failure is the MAP over \(B_1, \dots, B_m\) given \(S_L = \mathsf{false}\), as in Section 5.3.6.
Cost. A single threshold node with parents \(S_{D_1}, \dots, S_{D_n}\) would need \(2^{n+1}\) entries, the blow-up of Section 5.4; the chain uses \(n\) nodes of at most \(2(k+1)^2\) entries each, so \(O(n k^2)\) numbers in all — the micro-model device that turns the noisy-or CPT of (5.2) into the network of Figure 5.30. The extremes check out: at \(k = 1\) the counters are binary and the chain is a cascaded or-gate, recovering Figure 5.17, and at \(k = n\) it is a cascaded and-gate.
(After Jensen). Consider a cow that may be infected with a disease that can possibly be detected by performing a milk test. The test is performed on five consecutive days, leading to five outcomes. We want to determine the state of the cow’s infection over these days given the test outcomes. The prior probability of an infection on day one is \(1/10{,}000\); the test false positive rate is \(5/1{,}000\); and its false negative rate is \(1/1{,}000\). Moreover, the state of infection at a given day depends only on its state at the previous day. In particular, the probability of a new infection on a given day is \(2/10{,}000\), while the probability that an infection would persist to the next day is \(7/10\).
(a) Describe a Bayesian network and a corresponding query that solves this problem. What is the most likely state of the cow’s infection over the five days given the following test outcomes:
- (1) positive, positive, negative, positive, positive
- (2) positive, negative, negative, positive, positive
- (3) positive, negative, negative, negative, positive
(b) Assume now that the original false negative and false positive rates double on a given day in case the test has failed on the previous day. Describe a Bayesian network that captures this additional information.
(a) The network. A hidden Markov model, the dynamic Bayesian network of Section 5.3.5 with one slice per day. For \(d = 1, \dots, 5\) take
- \(I_d\), with values \(\mathsf{yes}\) and \(\mathsf{no}\): the cow is infected on day \(d\);
- \(T_d\), with values \(+\) and \(-\): the milk test outcome on day \(d\).
The infection state on a day depends only on the previous day’s and the test outcome only on the same day’s, so the edges are
\begin{equation*} I_1 \to I_2 \to I_3 \to I_4 \to I_5, \qquad I_d \to T_d \;\; (d = 1, \dots, 5), \end{equation*}
and nothing else. The CPTs are the same in every slice:
| \(I_1\) | \(\theta_{i_1}\) |
|---|---|
| yes | \(.0001\) |
| no | \(.9999\) |
| \(I_{d-1}\) | \(I_d\) | \(\theta_{i_d \mid i_{d-1}}\) |
|---|---|---|
| yes | yes | \(.7\) |
| yes | no | \(.3\) |
| no | yes | \(.0002\) |
| no | no | \(.9998\) |
| \(I_d\) | \(T_d\) | \(\theta_{t_d \mid i_d}\) |
|---|---|---|
| yes | \(+\) | \(.999\) |
| yes | \(-\) | \(.001\) |
| no | \(+\) | \(.005\) |
| no | \(-\) | \(.995\) |
the last table being fixed by the false negative rate \(\Pr(T_d = - \mid I_d = \mathsf{yes}) = 1/1{,}000\) and the false positive rate \(\Pr(T_d = + \mid I_d = \mathsf{no}) = 5/1{,}000\).
The query. The MAP over \(\mathbf{M} = \{I_1, \dots, I_5\}\) given the evidence \(e : T_1 = t_1, \dots, T_5 = t_5\) (Section 5.2.4). Since \(\mathbf{M}\) and \(\mathbf{E} = \{T_1,\dots,T_5\}\) exhaust the network, the remaining set \(\mathbf{Y}\) is empty and MAP coincides exactly with MPE, the degenerate case of Exercise 5.11. As \(\Pr(\mathbf{i}, e)\) factors along the chain,
\begin{equation*} \Pr(i_1,\dots,i_5, e) \;=\; \theta_{i_1}\theta_{t_1 \mid i_1} \prod_{d=2}^{5} \theta_{i_d \mid i_{d-1}} \theta_{t_d \mid i_d}, \end{equation*}
maximize by the left-to-right dynamic program (Viterbi), or enumerate the \(2^5 = 32\) instantiations.
Test vector (1): \(+,+,-,+,+\). The MPE is infection on all five days,
\begin{equation*} I_1 = I_2 = I_3 = I_4 = I_5 = \mathsf{yes}, \end{equation*}
with
\begin{equation*} \begin{aligned} \Pr(\mathbf{i}, e) &= (10^{-4})(.999)^4(.001)(.7)^4 \\ &= 2.39141 \times 10^{-8}, \end{aligned} \end{equation*}
and \(\Pr(e) = 3.197439 \times 10^{-8}\), so \(\Pr(\mathbf{i} \mid e) \approx 74.79\%\). The day-3 negative costs one false negative at \(.001\), against \((.005)^4\) for the competing all-healthy story.
Test vector (2): \(+,-,-,+,+\). The MPE is
\begin{equation*} I_1 = I_2 = I_3 = \mathsf{no}, \qquad I_4 = I_5 = \mathsf{yes}, \end{equation*}
with \(\Pr(\mathbf{i}, e) = 6.912864 \times 10^{-7}\) and \(\Pr(e) = 8.267956 \times 10^{-7}\), hence \(\Pr(\mathbf{i} \mid e) \approx 83.61\%\): the isolated day-1 positive is a false positive, while the two consecutive positives force a new infection from day 4.
Test vector (3): \(+,-,-,-,+\). The MPE is
\begin{equation*} I_1 = I_2 = I_3 = I_4 = I_5 = \mathsf{no}, \end{equation*}
with \(\Pr(\mathbf{i}, e) = 2.460472 \times 10^{-5}\) and \(\Pr(e) = 2.574235 \times 10^{-5}\), hence \(\Pr(\mathbf{i} \mid e) \approx 95.58\%\): two false positives at \((.005)^2 = 2.5 \times 10^{-5}\) are cheaper than an infection that appears, disappears, and produces three false negatives.
(b) Test failures that degrade the next test. The day-\(d\) error rates now depend on whether the day-\((d-1)\) test failed, i.e. disagreed with the true infection state, so the model needs a variable recording that. For \(d = 1, \dots, 4\) add
\begin{equation*} \begin{aligned} &F_d \in \{\mathsf{true}, \mathsf{false}\}, \quad \text{where} \\ &F_d = \mathsf{true} \iff (I_d = \mathsf{yes} \wedge T_d = -) \vee (I_d = \mathsf{no} \wedge T_d = +). \end{aligned} \end{equation*}
So \(F_d\) has parents \(I_d, T_d\) and a deterministic CPT (Section 5.4.2), the new edges being
\begin{equation*} I_d \to F_d, \qquad T_d \to F_d, \qquad F_d \to T_{d+1}, \end{equation*}
so \(T_{d+1}\) has parents \(I_{d+1}\) and \(F_d\) while the chain \(I_1 \to \cdots \to I_5\) is unchanged. The graph stays acyclic, every edge running within slice \(d\) or into slice \(d+1\). The CPT of \(T_1\) is the original emission table; for \(d = 2, \dots, 5\) it is indexed additionally by \(F_{d-1}\), doubling both error rates after a failure:
| \(I_d\) | \(F_{d-1}\) | \(T_d\) | \(\theta_{t_d \mid i_d, f_{d-1}}\) |
|---|---|---|---|
| yes | false | \(+\) | \(.999\) |
| yes | false | \(-\) | \(.001\) |
| yes | true | \(+\) | \(.998\) |
| yes | true | \(-\) | \(.002\) |
| no | false | \(+\) | \(.005\) |
| no | false | \(-\) | \(.995\) |
| no | true | \(+\) | \(.010\) |
| no | true | \(-\) | \(.990\) |
The query is unchanged, the MAP over \(I_1, \dots, I_5\) given \(T_1, \dots, T_5\), and it can still be read off an MPE: each \(F_d\) is a deterministic function of \(I_d\) and the observed \(T_d\), so every instantiation of the MAP variables and the evidence admits exactly one positive-probability instantiation of \(\mathbf{Y} = \{F_1,\dots,F_4\}\), which is the condition of Exercise 5.11.
Let \(\mathbf{E}\) be the evidence variables in a Bayesian network, \(\mathbf{M}\) be the MAP variables, and let \(\mathbf{Y}\) be all other variables. Suppose that \(\Pr(\mathbf{m}, \mathbf{e}) > 0\) implies that \(\Pr(\mathbf{m}, \mathbf{e}, \mathbf{y}) \ne 0\) for exactly one instantiation \(\mathbf{y}\). Show that the projection of an MPE solution on the MAP variables \(\mathbf{M}\) is also a MAP solution.
The hypothesis makes summing out \(\mathbf{Y}\) the same as maximizing it out: for every \(\mathbf{m}\),
\begin{equation*} \Pr(\mathbf{m}, \mathbf{e}) = \sum_{\mathbf{y}} \Pr(\mathbf{m}, \mathbf{e}, \mathbf{y}) = \max_{\mathbf{y}} \Pr(\mathbf{m}, \mathbf{e}, \mathbf{y}). \tag{\(\ast\)} \end{equation*}
Indeed, if \(\Pr(\mathbf{m}, \mathbf{e}) > 0\) exactly one term of the sum is nonzero, so the sum equals that term, which is the maximum; and if \(\Pr(\mathbf{m}, \mathbf{e}) = 0\) every term vanishes and both sides are \(0\).
Assume \(\Pr(\mathbf{e}) > 0\) (else neither query is defined) and let \(\mathbf{m}^\star \mathbf{y}^\star\) be an MPE given \(\mathbf{e}\), i.e. a maximizer of \(\Pr(\mathbf{m}, \mathbf{y}, \mathbf{e})\) (Section 5.2.3; the conditional and the joint differ by the positive constant \(\Pr(\mathbf{e})\)). For arbitrary \(\mathbf{m}\), apply \((\ast)\), then optimality of the MPE, then \((\ast)\) again:
\begin{equation*} \begin{aligned} \Pr(\mathbf{m}, \mathbf{e}) &= \max_{\mathbf{y}} \Pr(\mathbf{m}, \mathbf{e}, \mathbf{y}) \\ &\le \Pr(\mathbf{m}^\star, \mathbf{e}, \mathbf{y}^\star) \\ &\le \max_{\mathbf{y}} \Pr(\mathbf{m}^\star, \mathbf{e}, \mathbf{y}) = \Pr(\mathbf{m}^\star, \mathbf{e}). \end{aligned} \end{equation*}
So \(\mathbf{m}^\star\) maximizes \(\Pr(\mathbf{m}, \mathbf{e})\), hence also \(\Pr(\mathbf{m} \mid \mathbf{e}) = \Pr(\mathbf{m}, \mathbf{e}) / \Pr(\mathbf{e})\), and is a MAP solution.
Let \(\mathbf{R}\) be some root variables in a Bayesian network and let \(\mathbf{Q}\) be some nonroots. Show that the probability \(\Pr(\mathbf{q} \mid \mathbf{r})\) is independent of the CPTs for roots \(\mathbf{R}\) for all \(\mathbf{q}\) and \(\mathbf{r}\) such that \(\Pr(\mathbf{r}) \ne 0\).
The root parameters factor out of numerator and denominator alike and cancel. Write \(\mathbf{X}\) for all variables, \(\mathbf{Z} = \mathbf{X} \setminus (\mathbf{Q} \cup \mathbf{R})\) (disjoint, as \(\mathbf{Q}\) are nonroots), and split the chain rule for Bayesian networks at \(\mathbf{R}\): each \(R \in \mathbf{R}\) is a root, so its factor is \(\theta_r\), depending on \(\mathbf{r}\) alone. With
\begin{equation*} \kappa(\mathbf{r}) = \prod_{R \in \mathbf{R}} \theta_{r}, \qquad f(\mathbf{w}, \mathbf{r}) = \prod_{X \in \mathbf{X} \setminus \mathbf{R}} \theta_{x \mid \mathbf{u}}, \end{equation*}
the latter evaluated at \(\mathbf{w}\mathbf{r}\) and using no parameter of a CPT of \(\mathbf{R}\), we get \(\Pr(\mathbf{w}, \mathbf{r}) = \kappa(\mathbf{r}) f(\mathbf{w}, \mathbf{r})\) for every instantiation \(\mathbf{w}\) of \(\mathbf{X} \setminus \mathbf{R}\). Summing out,
\begin{equation*} \begin{aligned} \Pr(\mathbf{q}, \mathbf{r}) &= \kappa(\mathbf{r}) \sum_{\mathbf{z}} f(\mathbf{q}\mathbf{z}, \mathbf{r}), \\ \Pr(\mathbf{r}) &= \kappa(\mathbf{r}) \sum_{\mathbf{w}} f(\mathbf{w}, \mathbf{r}). \end{aligned} \end{equation*}
Since \(\Pr(\mathbf{r}) \ne 0\), both \(\kappa(\mathbf{r})\) and \(\sum_{\mathbf{w}} f(\mathbf{w}, \mathbf{r})\) are nonzero, so
\begin{equation*} \Pr(\mathbf{q} \mid \mathbf{r}) = \frac{\Pr(\mathbf{q}, \mathbf{r})}{\Pr(\mathbf{r})} = \frac{\sum_{\mathbf{z}} f(\mathbf{q}\mathbf{z}, \mathbf{r})} {\sum_{\mathbf{w}} f(\mathbf{w}, \mathbf{r})} , \end{equation*}
an expression in the parameters \(\theta_{x \mid \mathbf{u}}\), \(X \notin \mathbf{R}\), only. Replacing the CPTs of \(\mathbf{R}\) by any others leaves this expression unchanged, so \(\Pr(\mathbf{q} \mid \mathbf{r})\) is independent of them.
Consider the two circuit models of Section 5.3.5 corresponding to two different ways of representing health variables. We showed in that section that these two models are equivalent as far as queries involving variables \(A\), \(B\), \(C\), \(D\), and \(E\). Does this equivalence continue to hold if we extend the models to two test vectors as we did in Section 5.3.5? In particular, will the two models be equivalent with respect to queries involving variables \(A, \dots, E, A^{\prime}, \dots, E^{\prime}\)? Explain your answer.
Recall the setting. The circuit of Figure 5.14 has primary inputs \(A\) and \(B\), an inverter \(X\) with input \(A\) and output \(C\), an and-gate \(Y\) with inputs \(A, B\) and output \(D\), and an or-gate \(Z\) with inputs \(C, D\) and output \(E\). The Bayesian network has edges \(A \to C\), \(X \to C\), \(A \to D\), \(B \to D\), \(Y \to D\), \(C \to E\), \(D \to E\), \(Z \to E\). Wires take values low and high. In the first model each health variable has values ok and faulty with \(\theta_{\mathsf{ok}} = .99\), \(\theta_{\mathsf{faulty}} = .01\), and the output CPT is the gate function when the component is ok and uniform (\(.5 / .5\)) when it is faulty. In the second model each health variable has values ok, stuckat0, stuckat1 with probabilities \(.99\), \(.005\), \(.005\), and the output CPT is deterministic throughout: the gate function when ok, low when stuckat0, high when stuckat1. Extending to two test vectors as in Section 5.3.5 means adding a second copy \(A^{\prime}, B^{\prime}, C^{\prime}, D^{\prime}, E^{\prime}\) of the circuit variables while keeping the same health variables \(X, Y, Z\), which now have two children each (Figure 5.15(b)).
No: the equivalence breaks. It rested on each health variable having a single child, so that it could be bypassed by (5.1) of Section 5.3.4; in Figure 5.15(b) the shared health variable \(X\) has the two children \(C\) and \(C^{\prime}\) (likewise \(Y\), \(Z\)), and the models genuinely differ, because a stuck-at mode forces the same wrong output in both tests whereas a faulty gate with a \(.5/.5\) output CPT reflips independently.
Witness: condition on \(A = A^{\prime} = \mathsf{high}\) and query the inverter’s outputs. Under fault modes \(C = C^{\prime} = \mathsf{high}\) holds exactly when \(X = \mathsf{stuckat1}\) (ok or stuckat0 gives low in both tests), while under ok/faulty it needs \(X = \mathsf{faulty}\) and two high flips:
\begin{equation*} \begin{aligned} \Pr(C = \mathsf{high}, C^{\prime} = \mathsf{high} \mid A = A^{\prime} = \mathsf{high}) &= .005 &&\text{(fault modes)}, \\ &= (.01)(.5)(.5) = .0025 &&\text{(ok/faulty)}. \end{aligned} \end{equation*}
This is a query over \(A, C, A^{\prime}, C^{\prime}\) alone, so the two models are not equivalent with respect to queries over \(A, \dots, E, A^{\prime}, \dots, E^{\prime}\).
Consider the two circuit models of Section 5.3.5 corresponding to two different ways of representing health variables. We showed in that section that these two models are equivalent as far as queries involving variables \(A\), \(B\), \(C\), \(D\), and \(E\). Show that this result generalizes to any circuit structure as long as the two models agree on the CPTs for primary inputs and the CPTs corresponding to components satisfy the following conditions:
\begin{equation*} \begin{aligned} \theta_{H = \mathsf{ok}} &= \theta^{\prime}_{H = \mathsf{ok}} \\[4pt] \theta_{O = 0 \mid \mathbf{i},\, H = \mathsf{faulty}} &= \frac{\theta^{\prime}_{H = \mathsf{stuckat0}}} {\theta^{\prime}_{H = \mathsf{stuckat0}} + \theta^{\prime}_{H = \mathsf{stuckat1}}} \\[4pt] \theta_{O = 1 \mid \mathbf{i},\, H = \mathsf{faulty}} &= \frac{\theta^{\prime}_{H = \mathsf{stuckat1}}} {\theta^{\prime}_{H = \mathsf{stuckat0}} + \theta^{\prime}_{H = \mathsf{stuckat1}}} . \end{aligned} \end{equation*}
Here \(H\) is the health of the component, \(O\) is its output, and \(\mathbf{I}\) are its inputs. Moreover, \(\theta\) are the network parameters when health variables have states ok and faulty, and \(\theta^{\prime}\) are the network parameters when health variables have states ok, stuckat0, and stuckat1.
Bypassing every health variable turns the two networks into the same network over the circuit variables \(\mathbf{W}\) (primary inputs and wires), which gives the equivalence for every query over \(\mathbf{W}\). Write \(\Pr\), \(\theta\) for the ok/faulty network and \(\Pr^{\prime}\), \(\theta^{\prime}\) for the fault-mode one; the two share the circuit part of the DAG and the primary-input CPTs.
Let \(f\) be the Boolean function of a given component, so that the CPTs of its output are
\begin{equation*} \begin{aligned} \theta_{O = o \mid \mathbf{i},\, \mathsf{ok}} &= \theta^{\prime}_{O = o \mid \mathbf{i},\, \mathsf{ok}} = [\, o = f(\mathbf{i}) \,], \\ \theta^{\prime}_{O = o \mid \mathbf{i},\, \mathsf{stuckat0}} &= [\, o = 0 \,], \\ \theta^{\prime}_{O = o \mid \mathbf{i},\, \mathsf{stuckat1}} &= [\, o = 1 \,], \end{aligned} \end{equation*}
where \([\,\cdot\,]\) is \(1\) when the enclosed statement holds and \(0\) otherwise; the stuck-at CPTs are deterministic because a stuck-at gate ignores its inputs. The exercise’s conditions do not mention \(\mathbf{i}\), so they force \(\theta_{O = o \mid \mathbf{i}, \mathsf{faulty}}\) to be one number \(\theta_{O = o \mid \mathsf{faulty}}\) for all \(\mathbf{i}\).
Each health variable \(H\) is a root whose only child is its own component’s output \(O\), and \(H\) is neither query nor evidence here, so Section 5.3.4 permits bypassing it: delete \(H\) and reset
\begin{equation*} \theta^{\mathrm{new}}_{o \mid \mathbf{i}} = \sum_{h} \theta_{o \mid \mathbf{i}, h} \, \theta_{h} \end{equation*}
by (5.1). The bypass adds no edges and touches no other CPT, so the remaining health variables still have one child each and all of them may be bypassed in turn, in either network; what is left in both cases is the circuit DAG on \(\mathbf{W}\).
The bypassed wire CPTs then coincide. Abbreviate
\begin{equation*} p = \theta_{H = \mathsf{ok}}, \quad s_0 = \theta^{\prime}_{H = \mathsf{stuckat0}}, \quad s_1 = \theta^{\prime}_{H = \mathsf{stuckat1}} . \end{equation*}
Since \(\theta_{H = \mathsf{faulty}} = 1 - p\), \(\theta^{\prime}_{H = \mathsf{ok}} = 1 - s_0 - s_1\), and the stuck-at CPTs are deterministic,
\begin{equation*} \begin{aligned} \theta^{\mathrm{new}}_{o \mid \mathbf{i}} &= [\, o = f(\mathbf{i}) \,]\, p + \theta_{O = o \mid \mathsf{faulty}} (1 - p), \\ {\theta^{\prime}}^{\mathrm{new}}_{o \mid \mathbf{i}} &= [\, o = f(\mathbf{i}) \,]\,\theta^{\prime}_{H = \mathsf{ok}} + [\, o = 0 \,]\, s_0 + [\, o = 1 \,]\, s_1 . \end{aligned} \end{equation*}
The first condition gives \(\theta^{\prime}_{H = \mathsf{ok}} = p\), hence \(1 - p = s_0 + s_1\); the second and third then give \(\theta_{O = o \mid \mathsf{faulty}}(1 - p) = s_o\) for \(o = 0\) and \(o = 1\). (If \(s_0 + s_1 = 0\) those ratios are undefined, but then the component never fails in either model and that identity reads \(0 = 0\).) Substituting,
\begin{equation*} \theta^{\mathrm{new}}_{o \mid \mathbf{i}} = [\, o = f(\mathbf{i}) \,]\, p + s_o = {\theta^{\prime}}^{\mathrm{new}}_{o \mid \mathbf{i}} \end{equation*}
for every \(\mathbf{i}\) and \(o\). So after the bypasses the two networks have the same DAG, the same primary-input CPTs (assumed) and the same wire CPTs: they are the same network. Since bypassing preserves \(\Pr(\mathbf{q}, \mathbf{e})\) over the surviving variables (Section 5.3.4),
\begin{equation*} \Pr(\mathbf{q}, \mathbf{e}) = \Pr^{\prime}(\mathbf{q}, \mathbf{e}) \qquad \text{for all } \mathbf{Q}, \mathbf{E} \subseteq \mathbf{W}, \end{equation*}
for any feedback-free assembly of components, as required.
Exercises 5.15–5.16
Consider Exercise 5.14. Recall the setting of Section 5.3.5: a combinational digital circuit is modeled by a Bayesian network whose variables are the circuit wires together with one health variable \(H\) per component. The primary inputs and all health variables are roots; the output \(O\) of a component has as parents the component inputs \(I\) and the component health \(H\). Two parametrizations of this same structure are considered. In the first, each health variable has the values \(\text{ok}\) and \(\text{faulty}\); it induces the distribution \(\Pr\) with parameters \(\theta\). In the second, each health variable has the values \(\text{ok}\), \(\text{stuckat0}\), and \(\text{stuckat1}\); it induces the distribution \(\Pr^{\prime}\) with parameters \(\theta^{\prime}\). When a component is healthy its output is given by the gate function in both models, and the two models agree on the CPTs of the primary inputs. When a component is stuck at \(0\) (respectively \(1\)) its output is \(0\) (respectively \(1\)) with probability one, irrespective of its inputs, where the wire values \(0\) and \(1\) are the \(\text{low}\) and \(\text{high}\) of Section 5.3.5. Exercise 5.14 assumes that the remaining component parameters are related by
\begin{equation*} \begin{aligned} \theta_{H=\text{ok}} \;&=\; \theta^{\prime}_{H^{\prime}=\text{ok}}, \\[2pt] \theta_{O=0\mid i,\, H=\text{faulty}} \;&=\; \frac{\theta^{\prime}_{H^{\prime}=\text{stuckat0}}} {\theta^{\prime}_{H^{\prime}=\text{stuckat0}} + \theta^{\prime}_{H^{\prime}=\text{stuckat1}}}, \\[2pt] \theta_{O=1\mid i,\, H=\text{faulty}} \;&=\; \frac{\theta^{\prime}_{H^{\prime}=\text{stuckat1}}} {\theta^{\prime}_{H^{\prime}=\text{stuckat0}} + \theta^{\prime}_{H^{\prime}=\text{stuckat1}}}. \end{aligned} \end{equation*}
Let \(\mathbf{H}\) and \(\mathbf{H}^{\prime}\) be the health variables in the corresponding networks and let \(\mathbf{X}\) be all other variables in either network (that is, the circuit wires, which are common to both networks). Let \(h\) be an instantiation of variables \(\mathbf{H}\), assigning either \(\text{ok}\) or \(\text{faulty}\) to each variable in \(\mathbf{H}\). Let \(h^{\prime}\) be defined as follows:
\begin{equation*} \begin{aligned} h^{\prime} \;\overset{\text{def}}{=}\; &\Big(\textstyle\bigwedge_{h \models H = \text{ok}} (H^{\prime} = \text{ok})\Big) \\ &\wedge\;\Big(\textstyle\bigwedge_{h \models H = \text{faulty}} \big((H^{\prime} = \text{stuckat0}) \vee (H^{\prime} = \text{stuckat1})\big)\Big). \end{aligned} \end{equation*}
Show that \(\Pr(x, h) = \Pr^{\prime}(x, h^{\prime})\) for all \(x\) and \(h\), where \(\Pr\) is the distribution induced by the network with health states \(\text{ok}/\text{faulty}\) and \(\Pr^{\prime}\) is the distribution induced by the network with health states \(\text{ok}/\text{stuckat0}/\text{stuckat1}\).
Both sides factor componentwise, and the identity reduces to one local check per component. Index the components \(c = 1,\dots,n\); component \(c\) has health \(H_c\) (resp. \(H^{\prime}_c\)), inputs \(\mathbf{I}_c\) and output \(O_c\), and \(x\) assigns \(i_c, o_c\) to these wires and \(a\) to each primary input \(A \in \mathbf{R}\). By the chain rule (4.2),
\begin{equation*} \Pr(x, h) \;=\; \pi(x) \prod_{c=1}^{n} \theta_{h_c}\, \theta_{o_c \mid i_c,\, h_c}, \qquad \Pr^{\prime}(x, h^{\prime\prime}) \;=\; \pi(x) \prod_{c=1}^{n} \theta^{\prime}_{h^{\prime\prime}_c}\, \theta^{\prime}_{o_c \mid i_c,\, h^{\prime\prime}_c}, \end{equation*}
with the common primary-input factor \(\pi(x) = \prod_{A \in \mathbf{R}} \theta_a = \prod_{A \in \mathbf{R}} \theta^{\prime}_a\), the two models being assumed to agree there.
Reading off its definition, an instantiation \(h^{\prime\prime}\) of \(\mathbf{H}^{\prime}\) satisfies \(h^{\prime}\) exactly when \(h^{\prime\prime}_c \in \mathcal{V}_c(h)\) for every \(c\), where \(\mathcal{V}_c(h) = \{\text{ok}\}\) if \(h \models H_c = \text{ok}\) and \(\mathcal{V}_c(h) = \{\text{stuckat0}, \text{stuckat1}\}\) if \(h \models H_c = \text{faulty}\). So \(h^{\prime}\) is the disjoint union of the instantiations in the Cartesian product \(\mathcal{V}_1(h) \times \cdots \times \mathcal{V}_n(h)\), and additivity followed by the distributive law gives
\begin{equation*} \Pr^{\prime}(x, h^{\prime}) \;=\; \sum_{h^{\prime\prime} \models h^{\prime}} \Pr^{\prime}(x, h^{\prime\prime}) \;=\; \pi(x) \prod_{c=1}^{n} \Big(\sum_{v \,\in\, \mathcal{V}_c(h)} \theta^{\prime}_{H^{\prime}_c = v}\, \theta^{\prime}_{o_c \mid i_c,\, v}\Big). \end{equation*}
It therefore suffices to prove, componentwise, the local identity
\begin{equation*} \theta_{h_c}\, \theta_{o_c \mid i_c,\, h_c} \;=\; \sum_{v \,\in\, \mathcal{V}_c(h)} \theta^{\prime}_{H^{\prime}_c = v}\, \theta^{\prime}_{o_c \mid i_c,\, v}. \tag{\(\star\)} \end{equation*}
(i) \(h \models H_c = \text{ok}\). The sum is the single term \(\theta^{\prime}_{H^{\prime}_c=\text{ok}}\, \theta^{\prime}_{o_c \mid i_c,\, \text{ok}}\), whose factors are \(\theta_{H_c = \text{ok}}\) by the first condition of Exercise 5.14 and \(\theta_{o_c \mid i_c,\, \text{ok}}\) since both models use the same gate function when healthy.
(ii) \(h \models H_c = \text{faulty}\). Put \(\alpha = \theta^{\prime}_{H^{\prime}_c = \text{stuckat0}}\), \(\beta = \theta^{\prime}_{H^{\prime}_c = \text{stuckat1}}\), so that the first condition gives \(\theta_{H_c = \text{faulty}} = 1 - \theta^{\prime}_{H^{\prime}_c = \text{ok}} = \alpha + \beta\). The stuck-at CPTs are deterministic and input-independent, so exactly one term of the two-term sum survives, namely \(\alpha\) when \(o_c = 0\) and \(\beta\) when \(o_c = 1\); the second and third conditions give the same two values on the left, since \(\theta_{H_c=\text{faulty}}\, \theta_{o_c \mid i_c,\, \text{faulty}}\) is \((\alpha + \beta) \alpha / (\alpha + \beta)\) or \((\alpha + \beta) \beta / (\alpha + \beta)\). (If \(\alpha + \beta = 0\) the ratios are undefined, but then also \(\theta_{H_c=\text{faulty}} = 0\) and both sides of \((\star)\) vanish.) Note this is where the input-independence of \(\theta_{O=0 \mid i, H=\text{faulty}}\) is needed.
Substituting \((\star)\) for every \(c\) yields \(\Pr^{\prime}(x, h^{\prime}) = \Pr(x, h)\) for all \(x\) and \(h\).
Consider a DAG \(G\) with one root node \(S\) and one leaf node \(T\), where every edge \(U \to X\) represents a communication link between \(U\) and \(X\) – a link is up if \(U\) can communicate with \(X\) and down otherwise. In such a model, nodes \(S\) and \(T\) can communicate iff there exists a directed path from \(S\) to \(T\) where all links are up. Suppose that each edge \(U \to X\) is labeled with a probability \(p\) representing the reliability of communication between \(U\) and \(X\). Describe a Bayesian network and a corresponding query that computes the reliability of communication between \(S\) and \(T\). The Bayesian network should have a size that is proportional to the size of the DAG \(G\).
The reliability is the prior marginal \(\Pr(R_T = \text{true})\) in the following network, where \(R_X\) means “some directed \(S\)-to-\(X\) path has all links up.” Write \(G = (V,E)\), let \(p_{UX}\) label the edge \(U \to X\), and take the link states mutually independent, as intended.
- For each edge \(U \to X\), a root \(L_{UX}\) with values \(\text{up}\), \(\text{down}\) and \(\theta_{L_{UX} = \text{up}} = p_{UX}\). These are the only stochastic variables.
- \(R_S\), a root with \(\theta_{R_S = \text{true}} = 1\) (the empty path reaches \(S\)).
- For each non-root \(X\) with parents \(U_1, \dots, U_k\) in \(G\), a cascade of deterministic Boolean variables \(O_{X,1}, \dots, O_{X,k}\), and \(R_X := O_{X,k}\):
\begin{equation*} \begin{aligned} O_{X,1} \;&=\; R_{U_1} \wedge (L_{U_1 X} = \text{up}), \\ O_{X,j} \;&=\; O_{X,j-1} \;\vee\; \big( R_{U_j} \wedge (L_{U_j X} = \text{up}) \big), \qquad j = 2, \dots, k. \end{aligned} \end{equation*}
The cascade is the micro-model device of Section 5.4.1: the direct CPT \(R_X = \bigvee_j (R_{U_j} \wedge (L_{U_j X} = \text{up}))\) would have \(2^{2k+1}\) entries, whereas each \(O_{X,j}\) has at most three parents and so at most \(16\). Every node other than \(S\) has a parent (\(S\) is the only root), so no cascade is empty. The network has \(2|E| + 1\) variables and \(O(|E|)\) entries, proportional to \(G\); it is acyclic, since ordering the link roots and \(R_S\) first and then the \(O\)-blocks by a topological order of \(G\), internally by \(j\), is a topological order of it.
Correctness is by induction along that order: the cascade unwinds to \(R_X(\ell) = \bigvee_j (R_{U_j}(\ell) \wedge (\ell_{U_j X} = \text{up}))\) for each joint link state \(\ell\), and an all-up \(S\)-to-\(X\) path is exactly an all-up \(S\)-to-\(U_j\) path followed by an up edge \(U_j \to X\), which by hypothesis holds iff \(R_{U_j}(\ell) = \text{true}\); the base case \(X = S\) is the empty path. Since the \(L_{UX}\) are independent roots and every other variable is a function of \(\ell\),
\begin{equation*} \Pr(R_T = \text{true}) \;=\; \sum_{\ell} [\, R_T(\ell) = \text{true} \,] \prod_{U \to X \,\in\, E} \Pr(\ell_{UX}) \;=\; \mathrm{rel}(S,T). \end{equation*}
Inference by Variable Elimination
Exercises 6.1–6.7
Consider the Bayesian network in Figure 6.1 on Page 127. Its structure is
\begin{equation*} \begin{aligned} &A \rightarrow B, \quad A \rightarrow C,\\ &B \rightarrow D, \quad C \rightarrow D, \quad C \rightarrow E, \end{aligned} \end{equation*}
where \(A\) is Winter?, \(B\) is Sprinkler?, \(C\) is Rain?, \(D\) is Wet Grass?, and \(E\) is Slippery Road?. All variables are binary with values true/false. The CPTs are:
| \(A\) | \(\Theta_A\) |
|---|---|
| true | .6 |
| false | .4 |
| \(A\) | \(B\) | \(\Theta_{B \mid A}\) |
|---|---|---|
| true | true | .2 |
| true | false | .8 |
| false | true | .75 |
| false | false | .25 |
| \(A\) | \(C\) | \(\Theta_{C \mid A}\) |
|---|---|---|
| true | true | .8 |
| true | false | .2 |
| false | true | .1 |
| false | false | .9 |
| \(B\) | \(C\) | \(D\) | \(\Theta_{D \mid BC}\) |
|---|---|---|---|
| true | true | true | .95 |
| true | true | false | .05 |
| true | false | true | .9 |
| true | false | false | .1 |
| false | true | true | .8 |
| false | true | false | .2 |
| false | false | true | 0 |
| false | false | false | 1 |
| \(C\) | \(E\) | \(\Theta_{E \mid C}\) |
|---|---|---|
| true | true | .7 |
| true | false | .3 |
| false | true | 0 |
| false | false | 1 |
(a) Use variable elimination to compute the marginals \(\Pr(Q, e)\) and \(\Pr(Q \mid e)\) where \(Q = \{E\}\) and \(e : D = \text{false}\). Use the min-degree heuristic for determining the elimination order, breaking ties by choosing variables that come first in the alphabet. Show all steps.
(b) Prune the network given the query \(Q = \{A\}\) and evidence \(e : E = \text{false}\). Show the steps of node and edge pruning separately.
Part (a). \(\Pr(E, D = \text{false}) = (.05957, .24093)\) and \(\Pr(E \mid D = \text{false}) \approx (.1982, .8018)\), obtained as follows.
Pruning (Algorithm 8, VE_PR) does nothing here: \(Q \cup \mathbf{E} = \{E, D\}\) contains both leaves \(D\) and \(E\), and the evidence variable \(D\) is childless.
The interaction graph (Definition 6.4) of the five CPTs is
\begin{equation*} G:\quad A - B,\ \ A - C,\ \ B - C,\ \ B - D,\ \ C - D,\ \ C - E , \end{equation*}
with degrees \(2, 3, 4, 2, 1\) for \(A, \dots, E\). Min-degree over the non-query variables, alphabetical tie-break, gives \(\pi = A, B, D, C\):
- \(A\) and \(D\) tie at degree \(2\), take \(A\); \(B, C\) already adjacent, leaving \(B - C,\ B - D,\ C - D,\ C - E\).
- \(B\) and \(D\) tie at degree \(2\), take \(B\); \(C, D\) already adjacent, leaving \(C - D,\ C - E\).
- \(d(D) = 1 < d( C) = 2\), take \(D\), leaving \(C - E\); then \(C\).
The constructed factors are over \(\{B,C\}, \{C,D\}, \{C\}, \{E\}\), so the width is \(2\). Reducing on \(e : D = \text{false}\) (Definition 6.5) touches only \(\Theta_{D \mid BC}\), whose surviving rows are
| \(B\) | \(C\) | \(D\) | \(\Theta_{D \mid BC}^{\,e}\) |
|---|---|---|---|
| true | true | false | .05 |
| true | false | false | .1 |
| false | true | false | .2 |
| false | false | false | 1 |
Eliminating \(A\) from \(\Theta_A, \Theta_{B \mid A}, \Theta_{C \mid A}\) gives \(f_1(B,C) = \sum_{A} \Theta_A\,\Theta_{B \mid A}\,\Theta_{C \mid A}\), e.g. \(f_1(\text{true},\text{true}) = (.6)(.2)(.8) + (.4)(.75)(.1) = .126\):
| \(B\) | \(C\) | \(f_1\) |
|---|---|---|
| true | true | .126 |
| true | false | .294 |
| false | true | .394 |
| false | false | .186 |
Eliminating \(B\) from \(f_1\) and \(\Theta_{D \mid BC}^{\,e}\), then \(D\) from the result, then \(C\) against \(\Theta_{E \mid C}\):
\begin{equation*} \begin{aligned} f_2(\text{true}, \text{false}) &= (.126)(.05) + (.394)(.2) = .0851,\\ f_2(\text{false}, \text{false}) &= (.294)(.1) + (.186)(1) = .2154, \qquad f_2(C, \text{true}) = 0,\\ f_3( C) &= \textstyle\sum_{D} f_2(C,D) = (.0851, .2154),\\ f_4(\text{true}) &= (.0851)(.7) + (.2154)(0) = .05957,\\ f_4(\text{false}) &= (.0851)(.3) + (.2154)(1) = .24093 . \end{aligned} \end{equation*}
Thus \(f_4 = \Pr(E, D = \text{false})\), and \(\Pr(D = \text{false}) = .05957 + .24093 = .3005\), so dividing gives \(.05957/.3005 \approx .1982\) and \(.24093/.3005 \approx .8018\).
Part (b). \(\text{pruneNetwork}(\mathcal{N}, \{A\}, e) = A \rightarrow C \rightarrow E\), with CPTs \(\Theta_A\), \(\Theta_{C \mid A}\), \(\Theta_{E \mid C}\).
Node pruning (Theorem 6.4). Delete leaves outside \(Q \cup \mathbf{E} = \{A, E\}\): first \(D\) with \(\Theta_{D \mid BC}\), then the newly exposed leaf \(B\) with \(\Theta_{B \mid A}\). The only leaf left is \(E \in Q \cup \mathbf{E}\) (\(C\) is not a leaf, as \(C \rightarrow E\) remains), so this halts.
Edge pruning (Theorem 6.5). No edge leaves an evidence variable, the sole one being the leaf \(E\), so no edge is deleted and no CPT reduced.
Consider the Bayesian network in Figure 6.10. Its structure is the tree
\begin{equation*} A \rightarrow B,\qquad B \rightarrow C,\qquad B \rightarrow D, \end{equation*}
with all variables binary (true/false) and CPTs
| \(A\) | \(\Theta_A\) |
|---|---|
| true | .2 |
| false | .8 |
| \(A\) | \(B\) | \(\Theta_{B \mid A}\) |
|---|---|---|
| true | true | .5 |
| true | false | .5 |
| false | true | .0 |
| false | false | 1.0 |
| \(B\) | \(C\) | \(\Theta_{C \mid B}\) |
|---|---|---|
| true | true | 1.0 |
| true | false | .0 |
| false | true | .5 |
| false | false | .5 |
| \(B\) | \(D\) | \(\Theta_{D \mid B}\) |
|---|---|---|
| true | true | .75 |
| true | false | .25 |
| false | true | .3 |
| false | false | .7 |
Use variable elimination with ordering \(D, C, A\) to compute \(\Pr(B, C = \text{true})\), \(\Pr(C = \text{true})\), and \(\Pr(B \mid C = \text{true})\).
\(\Pr(B, C = \text{true}) = (.1, .45)\), \(\Pr(C = \text{true}) = .55\), and \(\Pr(B \mid C = \text{true}) = (2/11, 9/11) \approx (.1818, .8182)\).
Running VE_PR2 (Algorithm 7), reduction on \(e : C = \text{true}\) (Definition 6.5) touches only \(\Theta_{C \mid B}\), leaving the rows
| \(B\) | \(C\) | \(\Theta_{C \mid B}^{\,e}\) |
|---|---|---|
| true | true | 1.0 |
| false | true | .5 |
Eliminating \(\pi = D, C, A\) in turn:
\begin{equation*} \begin{aligned} f_1(B) &= \textstyle\sum_{D} \Theta_{D \mid B} = 1 &&\text{(a CPT sums to \(1\) over its head)},\\ f_2(B) &= \textstyle\sum_{C} \Theta_{C \mid B}^{\,e} = (1.0,\, .5) &&\text{(the likelihood of \(e\) given \(b\))},\\ f_3(\text{true}) &= (.2)(.5) + (.8)(.0) = .1, \qquad f_3(\text{false}) = (.2)(.5) + (.8)(1.0) = .9 . \end{aligned} \end{equation*}
Line 7 returns the product of the surviving factors, all over \(B\):
\begin{equation*} \begin{aligned} \Pr(B = \text{true},\, C = \text{true}) &= (1)(1.0)(.1) = .1,\\ \Pr(B = \text{false},\, C = \text{true}) &= (1)(.5)(.9) = .45, \end{aligned} \end{equation*}
whence \(\Pr(C = \text{true}) = .1 + .45 = .55\) and, by Bayes conditioning, \(.1/.55 = 2/11\) and \(.45/.55 = 9/11\).
Consider a chain network \(C_0 \rightarrow C_1 \rightarrow \cdots \rightarrow C_n\). Suppose that variable \(C_t\), for \(t \ge 0\), denotes the health state of a component at time \(t\). In particular, let each \(C_t\) take on states ok and faulty. Let \(C_0\) denote component birth where \(\Pr(C_0 = \text{ok}) = 1\) and \(\Pr(C_0 = \text{faulty}) = 0\). For each \(t > 0\), let the CPT of \(C_t\) be
\begin{equation*} \Pr(C_t = \text{ok} \mid C_{t-1} = \text{ok}) = \lambda, \end{equation*}
\begin{equation*} \Pr(C_t = \text{faulty} \mid C_{t-1} = \text{faulty}) = 1 . \end{equation*}
That is, if a component is healthy at time \(t - 1\), then it remains healthy at time \(t\) with probability \(\lambda\). If a component is faulty at time \(t - 1\), then it remains faulty at time \(t\) with probability \(1\).
(a) Using variable elimination with variable ordering \(C_0, C_1\), compute \(\Pr(C_2)\).
(b) Using variable elimination with variable ordering \(C_0, C_1, \ldots, C_{n-1}\), compute \(\Pr(C_n)\).
\(\Pr(C_2) = (\lambda^2,\, 1 - \lambda^2)\) and \(\Pr(C_n) = (\lambda^n,\, 1 - \lambda^n)\) over \((\text{ok}, \text{faulty})\). The CPTs, completed by the requirement that each row sums to \(1\), are
| \(C_0\) | \(\Theta_{C_0}\) |
|---|---|
| ok | 1 |
| faulty | 0 |
and, for every \(t > 0\),
| \(C_{t-1}\) | \(C_t\) | \(\Theta_{C_t \mid C_{t-1}}\) |
|---|---|---|
| ok | ok | \(\lambda\) |
| ok | faulty | \(1 - \lambda\) |
| faulty | ok | 0 |
| faulty | faulty | 1 |
There is no evidence, and the query variable is the chain’s only leaf, so nothing is reduced or pruned.
Part (a). Eliminating \(C_0\), then \(C_1\):
\begin{equation*} \begin{aligned} f_1(\text{ok}) &= (1)(\lambda) + (0)(0) = \lambda, &f_1(\text{faulty}) &= (1)(1-\lambda) + (0)(1) = 1 - \lambda,\\ f_2(\text{ok}) &= \lambda \cdot \lambda + (1-\lambda)\cdot 0 = \lambda^2, &f_2(\text{faulty}) &= \lambda(1-\lambda) + (1-\lambda) = 1 - \lambda^2 . \end{aligned} \end{equation*}
Part (b). By induction, eliminating \(C_0, \dots, C_{t-1}\) leaves the single factor \(f_t(\text{ok}) = \lambda^{t}\), \(f_t(\text{faulty}) = 1 - \lambda^{t}\): the case \(t = 1\) is above, and since \(C_t\) occurs only in \(f_t\) and \(\Theta_{C_{t+1} \mid C_t}\),
\begin{equation*} \begin{aligned} f_{t+1}(\text{ok}) &= \lambda^{t}\cdot\lambda + (1-\lambda^{t})\cdot 0 = \lambda^{t+1},\\ f_{t+1}(\text{faulty}) &= \lambda^{t}(1-\lambda) + (1-\lambda^{t})\cdot 1 = 1 - \lambda^{t+1}. \end{aligned} \end{equation*}
At \(t = n\) the order has covered every non-query variable, so \(f_n\) is the marginal \(\Pr(C_n)\).
Prove the technique of bypassing nodes as given by Equation 5.1 on Page 91. That is, let \(\mathcal{N}\) be a Bayesian network containing a variable \(X\) that is neither a query variable nor an evidence variable, and suppose \(X\) has a single child \(Y\). Let \(\mathbf{U}\) be the parents of \(X\) and let \(\mathbf{V}\) be the parents of \(Y\) other than \(X\) (see Figure 5.13). Bypassing \(X\) means deleting \(X\) from the network, making \(\mathbf{U}\) parents of \(Y\), and replacing the CPT of \(Y\) by the CPT over the new family \(Y\mathbf{U}\mathbf{V}\) defined by
\begin{equation*} \theta^{\prime}_{y \mid \mathbf{u}\mathbf{v}} \;=\; \sum_{x} \theta_{y \mid x\mathbf{v}}\, \theta_{x \mid \mathbf{u}} . \qquad (5.1) \end{equation*}
Show that the resulting network \(\mathcal{N}^{\prime}\) is a well-formed Bayesian network and that its distribution \(\Pr^{\prime}\) satisfies \(\Pr(\mathbf{q}, \mathbf{e}) = \Pr^{\prime}(\mathbf{q}, \mathbf{e})\) for all instantiations of the query variables \(\mathbf{Q}\) and evidence variables \(\mathbf{E}\), neither of which contains \(X\).
Bypassing is one step of variable elimination on \(X\), whose output happens to be a legitimate CPT. Write \(\mathbf{Z}\) for the variables of \(\mathcal{N}\) and \(\mathbf{Z}^{\prime} = \mathbf{Z} \setminus \{X\}\) for those of \(\mathcal{N}^{\prime}\).
Well-formedness. \(\mathcal{N}^{\prime}\) is acyclic: all new edges end at \(Y\), so a cycle in \(\mathcal{N}^{\prime}\) could use only one of them, and replacing that \(U \rightarrow Y\) by the path \(U \rightarrow X \rightarrow Y\) of \(\mathcal{N}\) would produce a cycle in \(\mathcal{N}\). The new table is a CPT: its entries are nonnegative and, for every \(\mathbf{u}\mathbf{v}\),
\begin{equation*} \sum_{y} \theta^{\prime}_{y \mid \mathbf{u}\mathbf{v}} = \sum_{x} \theta_{x \mid \mathbf{u}} \sum_{y} \theta_{y \mid x\mathbf{v}} = \sum_{x} \theta_{x \mid \mathbf{u}} \cdot 1 = 1 . \end{equation*}
\(\Pr^{\prime}\) is \(\Pr\) with \(X\) summed out. Since \(Y\) is \(X\)’s only child, every \(W \notin \{X, Y\}\) keeps its family and CPT. Fix \(\mathbf{z}^{\prime}\) and let \(y, \mathbf{u}, \mathbf{v}, \mathbf{p}_W\) be the values it assigns. By the chain rule in \(\mathcal{N}^{\prime}\), then (5.1), then Theorem 6.1 (the product over \(W \ne X, Y\) does not mention \(X\), so it moves inside the sum), then the chain rule in \(\mathcal{N}\):
\begin{equation*} \begin{aligned} \Pr^{\prime}(\mathbf{z}^{\prime}) &= \theta^{\prime}_{y \mid \mathbf{u}\mathbf{v}} \prod_{W \ne X, Y} \theta_{w \mid \mathbf{p}_W} = \Bigl(\sum_{x} \theta_{y \mid x\mathbf{v}}\,\theta_{x \mid \mathbf{u}}\Bigr) \prod_{W \ne X, Y} \theta_{w \mid \mathbf{p}_W}\\ &= \sum_{x} \Bigl( \theta_{x \mid \mathbf{u}}\,\theta_{y \mid x\mathbf{v}} \prod_{W \ne X, Y} \theta_{w \mid \mathbf{p}_W} \Bigr) = \sum_{x} \Pr(\mathbf{z}^{\prime}, x) = \Pr(\mathbf{z}^{\prime}) . \end{aligned} \end{equation*}
Queries. For \(\mathbf{Q} \cup \mathbf{E} \subseteq \mathbf{Z}^{\prime}\), the instantiations \(\mathbf{z}\) of \(\mathbf{Z}\) compatible with \(\mathbf{q}\mathbf{e}\) are exactly the pairs \((\mathbf{z}^{\prime}, x)\) with \(\mathbf{z}^{\prime}\) compatible, so
\begin{equation*} \Pr^{\prime}(\mathbf{q}, \mathbf{e}) = \sum_{\mathbf{z}^{\prime} \sim \mathbf{q}\mathbf{e}} \sum_{x} \Pr(\mathbf{z}^{\prime}, x) = \sum_{\mathbf{z} \sim \mathbf{q}\mathbf{e}} \Pr(\mathbf{z}) = \Pr(\mathbf{q}, \mathbf{e}). \end{equation*}
Consider a naive Bayes structure with edges \(X \rightarrow Y_1, \ldots, X \rightarrow Y_n\).
(a) What is the width of variable order \(Y_1, \ldots, Y_n, X\)?
(b) What is the width of variable order \(X, Y_1, \ldots, Y_n\)?
(a) Width \(1\). (b) Width \(n\).
The interaction graph (Definition 6.4) of \(\Theta_X\) and the \(\Theta_{Y_i \mid X}\) is the star with centre \(X\):
\begin{equation*} G:\quad X - Y_1,\ \ X - Y_2,\ \ \ldots,\ \ X - Y_n, \end{equation*}
with no edge between any \(Y_i, Y_j\). Eliminating a variable builds a factor over its current neighbours, then connects them pairwise and deletes it (Section 6.6).
(a) Each \(Y_i\) has the single neighbour \(X\), so its elimination builds a factor over \(\{X\}\), adds no fill-in edge, and leaves a smaller star; \(X\) is eliminated last from an isolated node, giving a factor over \(\emptyset\). The sizes are \(1, \dots, 1, 0\).
(b) \(X\) has all \(n\) neighbours \(Y_1, \dots, Y_n\), so eliminating it first builds
\begin{equation*} f_1(Y_1, \ldots, Y_n) \;=\; \sum_{X} \Theta_X \prod_{i=1}^{n} \Theta_{Y_i \mid X} \end{equation*}
over \(n\) variables and fills in every pair \(Y_i Y_j\), leaving the complete graph on \(Y_1, \dots, Y_n\). Eliminating from a complete graph keeps it complete, so \(Y_i\) then yields a factor of size \(n - i\); the maximum is \(n\).
Consider a two-layer Bayesian network \(\mathcal{N}\) with nodes \(\mathbf{X} \cup \mathbf{Y}\), \(\mathbf{X} \cap \mathbf{Y} = \emptyset\), where each \(X \in \mathbf{X}\) is a root node and each \(Y \in \mathbf{Y}\) is a leaf node with at most \(k\) parents. In such a network, all edges in \(\mathcal{N}\) are directed from a node in \(\mathbf{X}\) to a node in \(\mathbf{Y}\). Suppose we are interested in computing \(\Pr(Y)\) for all \(Y \in \mathbf{Y}\). What is the effective treewidth for \(\mathcal{N}\) for each one of these queries?
The effective treewidth for the query \(\Pr(Y)\) is \(|\mathbf{U}_Y| \le k\), the number of parents of \(Y\), whatever the treewidth of \(\mathcal{N}\) itself.
With \(\mathbf{E} = \emptyset\), pruneEdges deletes nothing, and node pruning (Theorem 6.4) first deletes every leaf \(Y^{\prime} \in \mathbf{Y} \setminus \{Y\}\), then every root of \(\mathbf{X} \setminus \mathbf{U}_Y\), which has just become childless. It halts there: each \(U \in \mathbf{U}_Y\) still has the child \(Y\), and \(Y \in Q\). So \(\text{pruneNetwork}(\mathcal{N}, \{Y\}, \emptyset)\) is \(Y\) with its parents \(\mathbf{U}_Y\).
Its factor \(\Theta_{Y \mid \mathbf{U}_Y}\) mentions all \(|\mathbf{U}_Y| + 1\) surviving variables, so the interaction graph is complete on them, and every elimination order of a complete graph on \(m\) nodes has width \(m - 1\) (the first variable eliminated is adjacent to the other \(m - 1\), and eliminating leaves the graph complete). Hence by Definition 6.6 the effective treewidth is \(|\mathbf{U}_Y|\).
Prune the network in Figure 6.11 given the following queries. The network structure of Figure 6.11 has nodes \(A, B, C, D, E, F, G, H\) and edges
\begin{equation*} \begin{aligned} &A \rightarrow B, \quad A \rightarrow C,\\ &B \rightarrow D, \quad C \rightarrow E,\\ &D \rightarrow F, \quad E \rightarrow G,\\ &F \rightarrow H, \quad G \rightarrow H . \end{aligned} \end{equation*}
That is, \(A\) is the unique root, the two chains \(B \rightarrow D \rightarrow F\) and \(C \rightarrow E \rightarrow G\) descend from it, and they meet again at the unique leaf \(H\).
(a) \(Q = \{B, E\}\) and \(e : A = \text{true}\)
(b) \(Q = \{A\}\) and \(e : B = \text{true}, F = \text{true}\)
Show the steps of node and edge pruning separately.
Node pruning iteratively deletes leaves outside \(Q \cup \mathbf{E}\) with their CPTs (Theorem 6.4); edge pruning deletes every edge out of an evidence variable and reduces the child’s CPT at the observed value (Theorem 6.5).
Part (a): \(Q \cup \mathbf{E} = \{A, B, E\}\).
Node pruning.
| iteration | leaf nodes | action |
|---|---|---|
| 1 | \(H\) | \(H \notin \{A,B,E\}\): delete \(H\), \(\Theta_{H \mid FG}\) |
| 2 | \(F\), \(G\) | delete both, with \(\Theta_{F \mid D}\) and \(\Theta_{G \mid E}\) |
| 3 | \(D\), \(E\) | delete \(D\) and \(\Theta_{D \mid B}\); keep \(E\) (it is in \(Q\)) |
| 4 | \(B\), \(E\) | both are in \(Q\): stop |
(\(C\) is never a leaf, as \(C \rightarrow E\) survives.) This leaves \(A \rightarrow B\), \(A \rightarrow C \rightarrow E\) with CPTs \(\Theta_A\), \(\Theta_{B \mid A}\), \(\Theta_{C \mid A}\), \(\Theta_{E \mid C}\).
Edge pruning. The evidence variable \(A\) has the surviving outgoing edges \(A \rightarrow B\) and \(A \rightarrow C\); delete both and set
\begin{equation*} \Theta_B := \Theta_{B \mid A}^{\,A = \text{true}}, \qquad \Theta_C := \Theta_{C \mid A}^{\,A = \text{true}}, \end{equation*}
each a one-variable table. The pruned network is \(A\) and \(B\) isolated together with \(C \rightarrow E\), with CPTs \(\Theta_A\), \(\Theta_B\), \(\Theta_C\), \(\Theta_{E \mid C}\); a further node-pruning round removes nothing.
Part (b): \(Q \cup \mathbf{E} = \{A, B, F\}\).
Node pruning.
| iteration | leaf nodes | action |
|---|---|---|
| 1 | \(H\) | delete \(H\) and \(\Theta_{H \mid FG}\) |
| 2 | \(F\), \(G\) | keep \(F\) (in \(\mathbf{E}\)); delete \(G\), \(\Theta_{G \mid E}\) |
| 3 | \(E\), \(F\) | delete \(E\) and \(\Theta_{E \mid C}\); keep \(F\) |
| 4 | \(C\), \(F\) | delete \(C\) and \(\Theta_{C \mid A}\); keep \(F\) |
| 5 | \(F\) | \(F \in \mathbf{E}\): stop |
This leaves the chain \(A \rightarrow B \rightarrow D \rightarrow F\) with CPTs \(\Theta_A\), \(\Theta_{B \mid A}\), \(\Theta_{D \mid B}\), \(\Theta_{F \mid D}\).
Edge pruning. \(F\) is now childless, so only \(B \rightarrow D\) goes; replace \(\Theta_{D \mid B}\) by \(\Theta_D := \Theta_{D \mid B}^{\,B = \text{true}}\). The pruned network is the two disconnected edges \(A \rightarrow B\) and \(D \rightarrow F\), with CPTs \(\Theta_A\), \(\Theta_{B \mid A}\), \(\Theta_D\), \(\Theta_{F \mid D}\); a further node-pruning round removes nothing, both leaves being in \(\mathbf{E}\).
Exercises 6.8–6.14
What is the width of the order \(A, B, C, D, E, F, G, H\) with respect to the network in Figure 6.11?
Figure 6.11 is the Bayesian network structure on the eight variables \(A, B, C, D, E, F, G, H\) with the following edges:
\begin{equation*} A \to B,\quad A \to C,\quad B \to D,\quad C \to E, \end{equation*}
\begin{equation*} D \to F,\quad E \to G,\quad F \to H,\quad G \to H. \end{equation*}
That is, the DAG splits at the root \(A\) into two chains \(A \to B \to D \to F\) and \(A \to C \to E \to G\), which rejoin at the single sink \(H\), whose parents are \(F\) and \(G\).
Width \(2\). The interaction graph of the CPTs (Definition 6.4) is the moral graph, since the CPT of \(X\) is a factor over \(\{X\} \cup \mathbf{U}\) and a factor’s variables form a clique; only \(H\) has two parents, so moralization adds just \(F - G\):
\begin{equation*} A-B,\ A-C,\ B-D,\ C-E,\ D-F,\ E-G,\ F-H,\ G-H,\ F-G. \end{equation*}
Running OrderWidth (Algorithm 4), recording the degree \(d\) of the eliminated variable and connecting its neighbours pairwise:
| step | eliminated | neighbours in current graph | \(d\) | fill-in edges added |
|---|---|---|---|---|
| 1 | \(A\) | \(B, C\) | 2 | \(B-C\) |
| 2 | \(B\) | \(C, D\) | 2 | \(C-D\) |
| 3 | \(C\) | \(D, E\) | 2 | \(D-E\) |
| 4 | \(D\) | \(E, F\) | 2 | \(E-F\) |
| 5 | \(E\) | \(F, G\) | 2 | none (\(F-G\) present) |
| 6 | \(F\) | \(G, H\) | 2 | none (\(G-H\) present) |
| 7 | \(G\) | \(H\) | 1 | none |
| 8 | \(H\) | none | 0 | none |
The fill-in edge simply walks the cut down the two chains – after step 4 the graph is \(E-F, E-G, F-G, F-H, G-H\), so \(E\) needs no new edge and what is left is the triangle \(F, G, H\). Hence \(\max_i d_i = 2\).
Compute an elimination order for the variables in Figure 6.11 using the min-degree method. In case of a tie, choose variables that come first alphabetically.
Figure 6.11 is the Bayesian network structure on the variables \(A, B, C, D, E, F, G, H\) with edges
\begin{equation*} A \to B,\quad A \to C,\quad B \to D,\quad C \to E, \end{equation*}
\begin{equation*} D \to F,\quad E \to G,\quad F \to H,\quad G \to H, \end{equation*}
that is, two chains \(A \to B \to D \to F\) and \(A \to C \to E \to G\) leaving the root \(A\) and rejoining at the sink \(H\), whose parents are \(F\) and \(G\).
Min-degree with alphabetical tie-breaking returns \(\pi = A, B, C, D, E, F, G, H\), of width \(2\).
Algorithm 5 runs on the moral graph, which adds only \(F - G\) (the sole node with two parents is \(H\)):
\begin{equation*} A-B,\ A-C,\ B-D,\ C-E,\ D-F,\ E-G,\ F-H,\ G-H,\ F-G, \end{equation*}
with degrees
| node | \(A\) | \(B\) | \(C\) | \(D\) | \(E\) | \(F\) | \(G\) | \(H\) |
|---|---|---|---|---|---|---|---|---|
| degree | 2 | 2 | 2 | 2 | 2 | 3 | 3 | 2 |
Every node but \(F, G\) starts at degree \(2\), so the first pick is \(A\); eliminating it (neighbours \(B, C\), fill-in \(B-C\)) leaves \(B\) at degree \(2\), and the same step repeats along the chain: \(B\) (fill-in \(C-D\)), \(C\) (\(D-E\)), \(D\) (\(E-F\)), each time restoring a degree-\(2\) alphabetically-first candidate while \(F, G\) stay at degree \(3\). Then \(E\) has neighbours \(F, G\) with \(F-G\) already present, leaving the triangle \(F, G, H\), from which \(F\), \(G\), \(H\) are eliminated at degrees \(2, 1, 0\). (Check!)
The degrees encountered are \(2,2,2,2,2,2,1,0\).
What is the treewidth of the network in Figure 6.11? Justify your answer.
Figure 6.11 is the Bayesian network structure on the variables \(A, B, C, D, E, F, G, H\) with edges
\begin{equation*} A \to B,\quad A \to C,\quad B \to D,\quad C \to E, \end{equation*}
\begin{equation*} D \to F,\quad E \to G,\quad F \to H,\quad G \to H, \end{equation*}
so the two chains \(A \to B \to D \to F\) and \(A \to C \to E \to G\) leave the root \(A\) and rejoin at the sink \(H\), whose parents are \(F\) and \(G\).
The treewidth is \(2\).
Upper bound. Exercise 6.8 exhibits the complete order \(A, B, C, D, E, F, G, H\) of width \(2\), and treewidth is the minimum width over complete orders.
Lower bound. Widths are measured on the moral graph, in which every family is a clique; here \(H\) has parents \(F, G\), so \(\{F, G, H\}\) is a triangle (\(F-H\), \(G-H\) from the DAG, \(F-G\) from moralization). Elimination never breaks a clique, since its only structural effects are adding fill-in edges and deleting the eliminated variable. So for any complete order \(\pi\), whichever of \(F, G, H\) comes first is still adjacent to the other two when eliminated, giving it degree \(\ge 2\) and \(\pi\) width \(\ge 2\). (This is the case \(k = 2\) of Exercise 6.15.)
Given a Bayesian network that has a tree structure with at least one edge, describe an efficient algorithm for obtaining an elimination order that is guaranteed to have width \(1\).
(Recall the terminology of Section 6.8: a tree network is a polytree in which every node has at most one parent, and such networks are stated there to have treewidth at most \(1\).)
Reverse any topological order \(X_1, \dots, X_n\) of the network: \(\pi = X_n, X_{n-1}, \ldots, X_1\), i.e. peel leaves inward toward the roots. Depth-first search produces a topological order in \(O(n + m)\) time, and \(m \le n\) in a tree network, so this is linear in the network structure.
Its width is \(1\). No node has two parents, so moralization adds nothing and the interaction graph \(G_0\) (Definition 6.4) is the undirected version of the DAG, a forest. When OrderWidth (Algorithm 4) reaches \(X_i\), the current graph is \(G_0\) restricted to \(\{X_1, \dots, X_i\}\) with no fill-in ever added: the neighbours of \(X_i\) in \(G_0\) are its unique parent and its children, and every child follows \(X_i\) topologically, hence precedes it in \(\pi\) and is already gone. So \(X_i\) has at most its parent as a neighbour, connecting a set of size \(\le 1\) adds no edge, and deleting \(X_i\) leaves \(G_0\) on \(\{X_1, \dots, X_{i-1}\}\) – the same statement one step down. Hence \(d \le 1\) at every step, with \(d = 1\) at any node having a parent, one of which exists since the network has at least one edge.
Given an elimination order \(\pi\) that covers all network variables, show how we can use this
particular order and Algorithm 8, VE_PR, to compute the marginal \(Pr(X, \mathbf e)\) for every
network variable \(X\) and some evidence \(\mathbf e\). What is the total complexity of computing
all such marginals?
(Algorithm 8, VE_PR, takes a network \(\mathcal N\), query variables \(\mathbf Q\), and
evidence \(\mathbf e\). It first prunes the network given the query, then chooses an order
\(\sigma\) of the variables not in \(\mathbf Q\), reduces every CPT of the pruned network on
\(\mathbf e\), eliminates the variables of \(\sigma\) in turn by
multiplying all factors that mention the current variable and summing it out, and finally
returns the product of the surviving factors, which equals \(Pr(\mathbf Q, \mathbf e)\).)
Call \(\text{VE\\_PR}(\mathcal N, \{X\}, \mathbf e)\) once per variable \(X = v_k\), supplying on Line 2 the order
\begin{equation*} \pi_X \;=\; v_1, \ldots, v_{k-1}, v_{k+1}, \ldots, v_n \end{equation*}
restricted to the variables surviving the pruning on Line 1; Line 2 admits any order of the variables outside \(\mathbf Q\), so each call is correct and returns \(Pr(X, \mathbf e)\). Total cost \(O(n^2 \exp(w))\) time and \(O(n \exp(w))\) space, where \(w\) is the width of \(\pi\).
The cost follows from two facts about widths, both measured on interaction graphs (Definition 6.4), and both proved by running the elimination twice in parallel on graphs \(G_i\) (for the full order) and \(H_i\) (for the restricted one).
(i) Deleting one variable from an order costs at most \(1\). The runs of \(\pi\) and \(\pi_X\) on the same graph satisfy the invariant that every edge of \(H_i\) avoiding \(X\) is an edge of \(G_i\): the step \(v_i = X\) only adds edges on the \(G\) side, and at a step \(v_i \ne X\) a fill-in edge \(\{Y,Z\}\) of \(H_{i+1}\) has \(Y, Z\) adjacent to \(v_i\) in \(H_i\), hence in \(G_i\) by hypothesis, so the same edge appears in \(G_{i+1}\). Applying the invariant to the pairs \(\{v_i, Y\}\), the neighbours of \(v_i\) in \(H_i\) are among those in \(G_i\) plus possibly \(X\), so \(|N_{H_i}(v_i)| \le |N_{G_i}(v_i)| + 1 \le w + 1\).
(ii) Restricting to a subgraph never hurts. For \(G^{\prime}\) a subgraph of \(G\) on \(S \subseteq V(G)\) and \(\sigma\) the restriction of \(\tau\) to \(S\), the same induction with the invariant \(E(H_i) \subseteq E(G_i)\) shows \(\sigma\) has width at most that of \(\tau\): steps eliminating a variable outside \(S\) only add edges on the \(G\) side, and at a step \(v_i \in S\) the \(H\)-neighbours of \(v_i\) are \(G\)-neighbours, so the recorded degree is no larger and every \(H\)-fill-in is a \(G\)-fill-in.
Since \(\text{pruneNetwork}\) only deletes nodes and edges and shrinks CPTs, the moral graph of the pruned network is such a subgraph, so by (i) and (ii) each call runs on an order of width at most \(w + 1\). With \(|\mathbf Q| = 1\), Theorem 6.2 bounds each call by \(O(n \exp(w+1))\), pruning costing only \(O(n \exp(w))\) more; over \(n\) variables this is \(O(n^2 \exp(w+1)) = O(n^2 \exp(w))\) for bounded variable cardinalities. The \(n\) calls are independent, so they reuse the same \(O(n \exp(w))\) space, retaining only the \(n\) single-variable answers.
Prove the following: for factors \(f_i\), \(f_j\), and evidence \(\mathbf e\),
\begin{equation*} (f_i f_j)^{\mathbf e} \;=\; f_i^{\mathbf e} \, f_j^{\mathbf e} . \end{equation*}
(This is Theorem 6.3. Recall Definition 6.3: the product of factors \(f_1(\mathbf X)\) and \(f_2(\mathbf Y)\) is the factor over \(\mathbf Z = \mathbf X \cup \mathbf Y\) given by \((f_1 f_2)(\mathbf z) = f_1(\mathbf x) f_2(\mathbf y)\), where \(\mathbf x\) and \(\mathbf y\) are the instantiations compatible with \(\mathbf z\); and Definition 6.5: the reduction of a factor \(f(\mathbf X)\) given evidence \(\mathbf e\) is the factor \(f^{\mathbf e}\) over \(\mathbf X\) with \(f^{\mathbf e}(\mathbf x) = f(\mathbf x)\) if \(\mathbf x \sim \mathbf e\) and \(f^{\mathbf e}(\mathbf x) = 0\) otherwise.)
Both sides are factors over \(\mathbf Z = \mathbf X \cup \mathbf Y\) (Definition 6.3 for the product, and reduction preserves a factor’s variables), so it suffices to compare their values at each instantiation \(\mathbf z\). Fix \(\mathbf z\) and let \(\mathbf x, \mathbf y\) be its restrictions to \(\mathbf X, \mathbf Y\), so that Definition 6.3 gives \((f_i f_j)(\mathbf z) = f_i(\mathbf x) f_j(\mathbf y)\) and \((f_i^{\mathbf e} f_j^{\mathbf e})(\mathbf z) = f_i^{\mathbf e}(\mathbf x) f_j^{\mathbf e}(\mathbf y)\).
(i) \(\mathbf z \sim \mathbf e\). Any variable shared by \(\mathbf X\) and \(\mathbf e\) is shared by \(\mathbf Z\) and \(\mathbf e\), where \(\mathbf x\) copies \(\mathbf z\), so \(\mathbf x \sim \mathbf e\), and likewise \(\mathbf y \sim \mathbf e\). Definition 6.5 then leaves all three values unreduced:
\begin{equation*} (f_i f_j)^{\mathbf e}(\mathbf z) = f_i(\mathbf x) f_j(\mathbf y) = f_i^{\mathbf e}(\mathbf x) \, f_j^{\mathbf e}(\mathbf y) . \end{equation*}
(ii) \(\mathbf z \not\sim \mathbf e\). The left side is \(0\). Some variable \(V\) of \(\mathbf Z\) is instantiated differently by \(\mathbf z\) and \(\mathbf e\), and \(V\) lies in \(\mathbf X\) or \(\mathbf Y\); in the first case \(\mathbf x\) inherits that value, so \(\mathbf x \not\sim \mathbf e\) and \(f_i^{\mathbf e}(\mathbf x) = 0\), in the second \(f_j^{\mathbf e}(\mathbf y) = 0\). Either way the right side vanishes too.
Prove the following: if \(\mathcal N^{\prime} = \text{pruneEdges}(\mathcal N, \mathbf e)\), then \(Pr(\mathbf Q, \mathbf e) = Pr^{\prime}(\mathbf Q, \mathbf e)\) for every \(\mathbf Q\), where \(Pr\) and \(Pr^{\prime}\) are the distributions induced by \(\mathcal N\) and \(\mathcal N^{\prime}\). Hint: prove that the joint distributions of \(\mathcal N\) and \(\mathcal N^{\prime}\) agree on rows that are consistent with evidence \(\mathbf e\).
(This is Theorem 6.5. Recall the edge-pruning operation of Section 6.9.2: for each edge \(U \to X\) whose tail \(U\) is a variable of the evidence \(\mathbf e\), we delete the edge from the network and replace the CPT \(\Theta_{X \mid \mathbf U}\) of \(X\) by the smaller table obtained from it by fixing \(U\) to the value \(u\) that \(\mathbf e\) assigns it, namely \(\sum_{U} \Theta_{X \mid \mathbf U}^{u}\).)
Following the hint, \(Pr\) and \(Pr^{\prime}\) agree on every row consistent with \(\mathbf e\), and the two marginals sum over the same such rows.
Write \(\mathbf U_X\) for the parents of \(X\) in \(\mathcal N\), split as \(\mathbf U_X^{\mathbf E} = \mathbf U_X \cap \mathbf E\) and \(\mathbf U_X^{-} = \mathbf U_X \setminus \mathbf E\), and let \(\mathbf e_X\) be the restriction of \(\mathbf e\) to \(\mathbf U_X^{\mathbf E}\). Pruning deletes exactly the edges out of evidence variables, so \(\mathcal N^{\prime}\) has the same nodes, \(X\) has parents \(\mathbf U_X^{-}\), and deleting edges preserves acyclicity. Its new CPT is \(\theta^{\prime}_{x \mid \mathbf u^{-}} = \theta_{x \mid \mathbf u^{-} \mathbf e_X}\), a legitimate CPT since \(\mathbf u^{-} \mathbf e_X\) is a full instantiation of \(\mathbf U_X\) and so \(\sum_{x} \theta_{x \mid \mathbf u^{-} \mathbf e_X} = 1\).
Let \(\mathbf z\) be an instantiation of all variables with \(\mathbf z \sim \mathbf e\), i.e. extending \(\mathbf e\), and let \(x, \mathbf u_X, \mathbf u_X^{-}\) be the values it assigns. It gives the evidence parents exactly \(\mathbf e_X\), so \(\mathbf u_X = \mathbf u_X^{-} \mathbf e_X\) and, by the chain rule in each network,
\begin{equation*} Pr^{\prime}(\mathbf z) = \prod_{X \in \mathbf Z} \theta^{\prime}_{x \mid \mathbf u_X^{-}} = \prod_{X \in \mathbf Z} \theta_{x \mid \mathbf u_X} = Pr(\mathbf z) . \end{equation*}
Now fix \(\mathbf q\). If \(\mathbf q \not\sim \mathbf e\) both marginals are \(0\). Otherwise both are sums over the same instantiations \(\mathbf z\) extending \(\mathbf q \mathbf e\),
\begin{equation*} Pr(\mathbf q, \mathbf e) = \sum_{\mathbf z \,\sim\, \mathbf q \mathbf e} Pr(\mathbf z) = \sum_{\mathbf z \,\sim\, \mathbf q \mathbf e} Pr^{\prime}(\mathbf z) = Pr^{\prime}(\mathbf q, \mathbf e) , \end{equation*}
each such \(\mathbf z\) extending \(\mathbf e\) and so covered by the previous display.
Exercises 6.15–6.18
Suppose we have a Bayesian network containing a node with \(k\) parents. Show that every variable order that contains all network variables must have width at least \(k\).
Let \(X\) have parents \(U_1,\ldots,U_k\), put \(C = \{X, U_1, \ldots, U_k\}\), and let \(\pi\) be any order over all network variables.
\(C\) is a clique of the initial interaction graph \(G_1\): the CPT \(\Theta_{X|U_1\ldots U_k}\) is a factor over exactly \(C\), and by Definition 6.4 variables sharing a factor are pairwise adjacent. Elimination never destroys an edge between two surviving variables, since it only adds fill-in edges and removes edges incident on the eliminated variable (Section 6.6).
Let \(i\) be least with \(\pi(i) \in C\); it exists since \(\pi\) covers every variable. Steps \(1, \dots, i-1\) all eliminate variables outside \(C\), so the other \(k\) members of \(C\) survive into \(G_i\) and remain adjacent to \(\pi(i)\). Hence \(\pi(i)\) has at least \(k\) neighbours when eliminated, so the \(d\) recorded by OrderWidth at iteration \(i\) is at least \(k\) and
\begin{equation*} w \;=\; \max_j d_j \;\ge\; k . \end{equation*}
Consider the naive Bayes structure \(C \to A_1, \ldots, C \to A_m\), where all variables are binary. That is, the network has a single root \(C\) (the class variable) with CPT \(\Theta_C\), and \(m\) leaves \(A_1,\ldots,A_m\) (the attributes), where each \(A_i\) has \(C\) as its only parent and CPT \(\Theta_{A_i|C}\). Show how the algorithm of variable elimination can be used to compute a closed form for the conditional probability \(\Pr(c \mid a_1, \ldots, a_m)\).
\begin{equation*} \Pr(c \mid a_1,\ldots,a_m)
\frac{\theta_c \prod_{i=1}^{m} \theta_{a_i|c}} {\theta_c \prod_{i=1}^{m} \theta_{a_i|c} \;+\; \theta_{\bar c} \prod_{i=1}^{m} \theta_{a_i|\bar c}} , \end{equation*}
where \(c, \bar c\) are the values of \(C\). Run VE_PR with \(Q = \{C\}\), \(e : A_1 = a_1, \ldots, A_m = a_m\) and order \(\pi = A_1, \ldots, A_m\). Line 3 reduces each CPT (Definition 6.5), leaving \(\Theta_C\) untouched and giving
\begin{equation*} \Theta^{e}_{A_i \mid C}(\alpha, \gamma) = \begin{cases} \theta_{a_i \mid \gamma}, & \alpha = a_i, \\ 0, & \alpha \neq a_i, \end{cases} \qquad \gamma \in \{c, \bar c\}, \end{equation*}
which is legitimate because reduction distributes over the product of CPTs (Theorem 6.3). Each \(A_i\) occurs in the single factor \(\Theta^{e}_{A_i \mid C}\), so its elimination needs no multiplication and yields \(f_i(\gamma) = \theta_{a_i \mid \gamma}\), a factor over \(C\) alone (width \(1\), so the run costs \(O(m)\)). Line 9 multiplies the survivors \(\Theta_C, f_1, \ldots, f_m\):
\begin{equation*} \Pr(C, e)( c) \;=\; \theta_c \prod_{i=1}^{m} \theta_{a_i|c}, \qquad \Pr(C, e)(\bar c) \;=\; \theta_{\bar c} \prod_{i=1}^{m} \theta_{a_i|\bar c}, \end{equation*}
and dividing by \(\Pr(e) = \Pr(C,e)( c) + \Pr(C,e)(\bar c)\) gives the displayed form.
Suppose we have a Bayesian network \(\mathcal{N}\) and evidence \(e\) with some node \(X\) having parents \(U_1, \ldots, U_n\) (all binary).
- (a) Show that if \(X\) is a logical OR node that is set to false in \(e\), we can prune all edges incoming into \(X\) and assert hard evidence on each parent.
- (b) Show that if \(X\) is a noisy OR node that is set to false in \(e\), we can prune all edges incoming into \(X\) and assert soft evidence on each parent.
In particular, for each case identify a network \(\mathcal{N}^{\prime}\) and evidence \(e^{\prime}\) where all edges incoming into \(X\) have been pruned from \(\mathcal{N}\) and where \(\Pr(\mathbf{x}, e) = \Pr^{\prime}(\mathbf{x}, e^{\prime})\) for every network instantiation \(\mathbf{x}\).
Here a logical OR node is one whose CPT satisfies \(\theta_{x \mid \mathbf{u}} = 1\) iff at least one \(U_i\) is true in \(\mathbf{u}\), and a noisy OR node is one whose CPT is generated by the noisy-or model of Section 5.4.1, so that with suppressor probabilities \(\theta_{q_1}, \ldots, \theta_{q_n}\) and leak probability \(\theta_l\),
\begin{equation*} \theta_{\bar x \mid \mathbf{u}} \;=\; (1-\theta_l) \prod_{i \,:\, U_i = \text{true in } \mathbf{u}} \theta_{q_i}. \end{equation*}
Both parts turn on one fact: with \(X\) set to false, the row \(\theta_{\bar x \mid \mathbf{u}}\) of an OR-like CPT factorizes into unary functions of the parents, and a unary factor on \(U_i\) is exactly what evidence on \(U_i\) contributes. Write \(\mathbf{z}\) for an instantiation of \(\mathcal{N}\)’s variables (the exercise’s \(\mathbf{x}\)), \(\mathbf{u}\) for its restriction to the parents, \(\bar x\) for \(X = \text{false}\), and \(R(\mathbf{z}) = \prod_{V \neq X} \theta_{z_V \mid \mathbf{z}_{\mathrm{Pa}(V)}}\) for the chain-rule product over the other CPTs, which nothing below touches.
(a) Logical OR. Take \(\mathcal{N}^{\prime}\) with the edges \(U_i \to X\) deleted and \(\Theta_{X \mid U_1 \ldots U_n}\) replaced by the root CPT \(\theta^{\prime}_{\bar x} = 1\), \(\theta^{\prime}_{x} = 0\), and take \(e^{\prime} = e \cup \{U_1 = \text{false}, \ldots, U_n = \text{false}\}\); deleting edges preserves acyclicity. Since \(X\) is false iff every parent is,
\begin{equation*} \theta_{\bar x \mid \mathbf{u}} = \prod_{i=1}^{n} \big[\, U_i = \text{false in } \mathbf{u} \,\big], \end{equation*}
with \([\cdot]\) the \(0/1\) indicator. If \(\mathbf{z}\) is inconsistent with \(e\) both sides vanish, \(e^{\prime}\) extending \(e\); otherwise \(z_X = \bar x\) and
\begin{equation*} \Pr(\mathbf{z}, e) = \theta_{\bar x \mid \mathbf{u}} \, R(\mathbf{z}) = R(\mathbf{z}) \prod_{i=1}^{n} \big[\, z_{U_i} = \text{false} \,\big] = \Pr^{\prime}(\mathbf{z}, e^{\prime}), \end{equation*}
since \(\Pr^{\prime}(\mathbf{z}) = R(\mathbf{z})\) and \(\mathbf{z} \sim e^{\prime}\) iff every \(z_{U_i}\) is false. (If \(e\) already sets some \(U_i\) true then \(\Pr(e) = 0\) and the claim is trivial.)
(b) Noisy OR. By (5.2) of Section 5.4.1,
\begin{equation*} \theta_{\bar x \mid \mathbf{u}} = (1-\theta_l) \prod_{i=1}^{n} g_i(z_{U_i}), \qquad g_i(\text{true}) = \theta_{q_i}, \quad g_i(\text{false}) = 1 , \end{equation*}
and the \(g_i\) are no longer \(0/1\), so they are likelihoods rather than hard evidence; realize them as virtual evidence (Section 3.6.4). Let \(\mathcal{N}^{\prime}\) delete the edges \(U_i \to X\), give the now-root \(X\) the CPT \(\theta^{\prime}_{\bar x} = 1 - \theta_l\), \(\theta^{\prime}_{x} = \theta_l\), and attach to each \(U_i\) a fresh binary child \(V_i\) with
\begin{equation*} \theta^{\prime}_{v_i \mid u_i} = \theta_{q_i}, \qquad \theta^{\prime}_{v_i \mid \bar u_i} = 1 , \end{equation*}
the complementary rows being \(1-\theta_{q_i}\) and \(0\); set \(e^{\prime} = e \cup \{V_1 = v_1, \ldots, V_n = v_n\}\). Both new tables are CPTs (rows nonnegative and summing to \(1\)). Since \(e^{\prime}\) fixes every \(V_i\), each \(\mathbf{z}\) extends to exactly one instantiation of \(\mathcal{N}^{\prime}\) consistent with \(e^{\prime}\). For \(\mathbf{z}\) consistent with \(e\), so that \(z_X = \bar x\), the chain rule over the enlarged variable set gives
\begin{equation*} \begin{aligned} \Pr^{\prime}(\mathbf{z}, e^{\prime}) &= \theta^{\prime}_{\bar x} \cdot R(\mathbf{z}) \cdot \prod_{i=1}^{n} \theta^{\prime}_{v_i \mid z_{U_i}} = (1-\theta_l) \, R(\mathbf{z}) \prod_{i=1}^{n} g_i(z_{U_i}) = \Pr(\mathbf{z}, e), \end{aligned} \end{equation*}
because \(\theta^{\prime}_{v_i \mid z_{U_i}}\) is \(\theta_{q_i}\) when \(z_{U_i}\) is true and \(1\) when it is false, i.e. \(g_i(z_{U_i})\); and both sides are \(0\) when \(\mathbf{z} \not\sim e\).
Suppose that \(f_1\) is a factor over variables \(XY\) and \(f_2\) is a factor over variables \(XZ\). Show that \(\left(\sum_X f_1\right)\left(\sum_X f_2\right)\) is an upper bound on \(\sum_X f_1 f_2\) in the following sense:
\begin{equation*} \left(\left(\sum_X f_1\right)\left(\sum_X f_2\right)\right)(\mathbf{u}) \;\ge\; \left(\sum_X f_1 f_2\right)(\mathbf{u}), \end{equation*}
for all instantiations \(\mathbf{u}\) of \(\mathbf{U} = \mathbf{Y} \cup \mathbf{Z}\). Show
how this property can be used to produce an approximate version of VE_PR that can have
a lower complexity yet is guaranteed to produce an upper bound on the true marginals.
The gap is the off-diagonal mass, which is nonnegative because factors are nonnegative (Definition 6.1). Fix \(\mathbf{u}\) with restrictions \(\mathbf{y}, \mathbf{z}\) to \(\mathbf{Y}, \mathbf{Z}\). By Definitions 6.2 and 6.3 the left side decouples the two sums,
\begin{equation*} \left(\left(\sum_X f_1\right)\left(\sum_X f_2\right)\right)(\mathbf{u}) = \sum_{x} \sum_{x^{\prime}} f_1(x, \mathbf{y}) \, f_2(x^{\prime}, \mathbf{z}), \end{equation*}
whereas \(\left(\sum_X f_1 f_2\right)(\mathbf{u}) = \sum_{x} f_1(x, \mathbf{y}) f_2(x, \mathbf{z})\) is its diagonal, so the difference is \(\sum_{x \neq x^{\prime}} f_1(x, \mathbf{y}) f_2(x^{\prime}, \mathbf{z}) \ge 0\).
Mini-buckets. For nonnegative factors, \(f \ge \hat f\) pointwise implies \(fg \ge \hat f g\)
and \(\sum_W f \ge \sum_W \hat f\), so replacing a factor set by one whose product dominates
pointwise makes the final result of VE_PR dominate, by induction on the remaining
eliminations. Fix a bound \(b\) on the variables allowed in a constructed factor. At
iteration \(i\), partition the factors mentioning \(\pi(i)\) into groups \(P_1, \ldots, P_r\)
with
\begin{equation*} \Big| \bigcup_{f \in P_j} \mathrm{vars}(f) \Big| \;\le\; b+1 , \end{equation*}
and replace them all by the \(r\) factors \(\hat f_{i,j} = \sum_{\pi(i)} \prod_{f \in P_j} f\) rather than by the exact \(f_i\). Applying the inequality \(r - 1\) times, each application decoupling one more copy of the summation variable,
\begin{equation*} \prod_{j=1}^{r} \hat f_{i,j} \;\ge\; \sum_{\pi(i)} \ \prod_{j=1}^{r} \prod_{f \in P_j} f \;=\; f_i , \end{equation*}
so by monotonicity Line 9 returns \(\widehat{\Pr}(\mathbf{q}, e) \ge \Pr(\mathbf{q}, e)\) for
every \(\mathbf{q}\), and \(\mathbf{Q} = \emptyset\) bounds \(\Pr(e)\). Every factor built has
at most \(b\) variables, so the cost is \(O(n \exp(b))\) rather than \(O(n \exp(w))\), with
\(b \ge w\) recovering exact VE_PR. The guarantee is on the joint \(\Pr(\mathbf{Q}, e)\),
not on the conditional: normalizing divides two upper bounds.
A worked instance. Take \(X, Y, Z\) binary with
| \(x\) | \(y\) | \(f_1(x,y)\) |
|---|---|---|
| 0 | 0 | 0.2 |
| 0 | 1 | 0.5 |
| 1 | 0 | 0.4 |
| 1 | 1 | 0.3 |
| \(x\) | \(z\) | \(f_2(x,z)\) |
|---|---|---|
| 0 | 0 | 0.3 |
| 0 | 1 | 0.6 |
| 1 | 0 | 0.6 |
| 1 | 1 | 0.2 |
Summing out \(X\) gives \((\sum_X f_1) = (0.6, 0.8)\) and \((\sum_X f_2) = (0.9, 0.8)\), so
| \(y\) | \(z\) | \((\sum_X f_1)(\sum_X f_2)\) | \(\sum_X f_1 f_2\) | gap |
|---|---|---|---|---|
| 0 | 0 | 0.54 | 0.30 | 0.24 |
| 0 | 1 | 0.48 | 0.20 | 0.28 |
| 1 | 0 | 0.72 | 0.33 | 0.39 |
| 1 | 1 | 0.64 | 0.36 | 0.28 |
and each gap is the off-diagonal sum, e.g. \(0.2 \cdot 0.6 + 0.4 \cdot 0.3 = 0.24\) at \(y = z = 0\).
Inference by Factor Elimination
Exercises 7.1–7.7
Answer the following queries with respect to the Bayesian network in Figure 7.18:
- \(\Pr(B, C)\).
- \(\Pr(C, D = \text{true})\).
- \(\Pr(A \mid D = \text{true}, E = \text{true})\).
You may prune the network before attempting each computation and use any inference method you find most appropriate.
The network of Figure 7.18 has seven binary variables \(A, B, C, D, E, F, G\) and edges
\begin{equation*} A \to C,\quad B \to C,\quad C \to D,\quad C \to E,\quad D \to F,\quad E \to G . \end{equation*}
Its CPTs are the following.
| \(A\) | \(f_A\) |
|---|---|
| true | .6 |
| false | .4 |
| \(B\) | \(f_B\) |
|---|---|
| true | .5 |
| false | .5 |
| \(A\) | \(B\) | \(C\) | \(f_C\) |
|---|---|---|---|
| true | true | true | .9 |
| true | true | false | .1 |
| true | false | true | .1 |
| true | false | false | .9 |
| false | true | true | .5 |
| false | true | false | .5 |
| false | false | true | .3 |
| false | false | false | .7 |
| \(C\) | \(D\) | \(f_D\) |
|---|---|---|
| true | true | .2 |
| true | false | .8 |
| false | true | .7 |
| false | false | .3 |
| \(C\) | \(E\) | \(f_E\) |
|---|---|---|
| true | true | .1 |
| true | false | .9 |
| false | true | .2 |
| false | false | .8 |
| \(D\) | \(F\) | \(f_F\) |
|---|---|---|
| true | true | .7 |
| true | false | .3 |
| false | true | .6 |
| false | false | .4 |
| \(E\) | \(G\) | \(f_G\) |
|---|---|---|
| true | true | .2 |
| true | false | .8 |
| false | true | .8 |
| false | false | .2 |
Write \(f_A = \Theta_A\), \(f_B = \Theta_B\), \(f_C = \Theta_{C \mid AB}\), \(f_D = \Theta_{D \mid C}\), \(f_E = \Theta_{E \mid C}\), \(f_F = \Theta_{F \mid D}\), \(f_G = \Theta_{G \mid E}\). Summing \(f_A f_B f_C\) over \(B\) once gives the joint over \(A, C\) that all three parts use:
\begin{equation*} \begin{aligned} \Pr(A=t, C=t) &= .6\,(.5\cdot .9 + .5\cdot .1) = .30,\\ \Pr(A=t, C=f) &= .6\,(.5\cdot .1 + .5\cdot .9) = .30,\\ \Pr(A=f, C=t) &= .4\,(.5\cdot .5 + .5\cdot .3) = .16,\\ \Pr(A=f, C=f) &= .4\,(.5\cdot .5 + .5\cdot .7) = .24 , \end{aligned} \end{equation*}
so \(\Pr(C=t) = .46\) and \(\Pr(C=f) = .54\).
Part 1. With \(\mathbf{Q} = \{B, C\}\) and no evidence, node pruning deletes the leaves \(F, G\) and then \(D, E\), leaving \(A \to C \leftarrow B\), so \(\Pr(B, C) = \sum_{A} f_A f_B f_C\):
\begin{equation*} \begin{aligned} \Pr(B=t, C=t) &= .5\,(.6 \cdot .9 + .4 \cdot .5) = .37,\\ \Pr(B=t, C=f) &= .5\,(.6 \cdot .1 + .4 \cdot .5) = .13,\\ \Pr(B=f, C=t) &= .5\,(.6 \cdot .1 + .4 \cdot .3) = .09,\\ \Pr(B=f, C=f) &= .5\,(.6 \cdot .9 + .4 \cdot .7) = .41 . \end{aligned} \end{equation*}
| \(B\) | \(C\) | \(\Pr(B,C)\) |
|---|---|---|
| true | true | .37 |
| true | false | .13 |
| false | true | .09 |
| false | false | .41 |
Part 2. With \(\mathbf{Q} = \{C\}\), \(\mathbf{e} : D = \text{true}\), node pruning deletes \(F, G\) and then \(E\), and edge pruning removes nothing (\(D\) is childless), leaving \(A \to C \leftarrow B\) with \(C \to D\). Hence \(\Pr(C, D=t) = \Pr( C)\,\Theta_{D=t \mid C}\):
\begin{equation*} \Pr(C=t, D=t) = .46 \cdot .2 = .092, \qquad \Pr(C=f, D=t) = .54 \cdot .7 = .378 . \end{equation*}
| \(C\) | \(\Pr(C, D=\text{true})\) |
|---|---|
| true | .092 |
| false | .378 |
Part 3. With \(\mathbf{Q} = \{A\}\), \(\mathbf{e} : D = E = \text{true}\), pruning deletes only \(F, G\). Put \(g( C) = \Theta_{D=t \mid C}\,\Theta_{E=t \mid C}\), so \(g(t) = .02\) and \(g(f) = .14\); summing out \(C\) against the joint above,
\begin{equation*} \begin{aligned} \Pr(A=t, D=t, E=t) &= .30 \cdot .02 + .30 \cdot .14 = .048,\\ \Pr(A=f, D=t, E=t) &= .16 \cdot .02 + .24 \cdot .14 = .0368 , \end{aligned} \end{equation*}
so \(\Pr(D=t, E=t) = .0848\) and dividing gives \(.048/.0848 = 30/53\), \(.0368/.0848 = 23/53\).
| \(A\) | \(\Pr(A \mid D=\text{true}, E=\text{true})\) |
|---|---|
| true | \(30/53 \approx .5660\) |
| false | \(23/53 \approx .4340\) |
Consider the Bayesian network in Figure 7.19. Construct an elimination tree for the Bayesian network CPTs that has the smallest width possible and assigns at most one CPT to each tree node. Compute the separators, clusters, and width of the elimination tree. It may be useful to know that this network has the following jointree:
\begin{equation*} ABC - BCE - BDE - DEF - EFG - FGH . \end{equation*}
The DAG of Figure 7.19 has eight binary variables and the edges
\begin{equation*} \begin{aligned} &A \to B, \quad A \to C, \quad B \to D, \quad B \to E, \quad C \to E,\\ &D \to F, \quad E \to F, \quad E \to G, \quad F \to H, \quad G \to H . \end{aligned} \end{equation*}
Its CPTs are therefore \(\Theta_A\), \(\Theta_{B \mid A}\), \(\Theta_{C \mid A}\), \(\Theta_{D \mid B}\), \(\Theta_{E \mid BC}\), \(\Theta_{F \mid DE}\), \(\Theta_{G \mid E}\), and \(\Theta_{H \mid FG}\).
Take \(T\) to be the path
\begin{equation*} 3 - 2 - 1 - 4 - 5 - 6 - 7 - 8 \end{equation*}
with the one-to-one assignment of CPTs to nodes tabulated below; its width is \(2\), the smallest attainable, since \(\Theta_{E \mid BC}\) must sit alone at some node \(i\), forcing \(\{B,C,E\} = \text{vars}(i) \subseteq \mathbf{C}_i\).
| node | factor \(\phi_i\) | \(\text{vars}(i)\) |
|---|---|---|
| 3 | \(\Theta_A\) | \(A\) |
| 2 | \(\Theta_{B \mid A}\) | \(AB\) |
| 1 | \(\Theta_{C \mid A}\) | \(AC\) |
| 4 | \(\Theta_{E \mid BC}\) | \(BCE\) |
| 5 | \(\Theta_{D \mid B}\) | \(BD\) |
| 6 | \(\Theta_{F \mid DE}\) | \(DEF\) |
| 7 | \(\Theta_{G \mid E}\) | \(EG\) |
| 8 | \(\Theta_{H \mid FG}\) | \(FGH\) |
This is an elimination tree by Definition 7.2 (\(T\) is a tree and each of the eight CPTs is assigned to exactly one node). Since \(T\) is a path, each edge splits it into an initial and a final segment, so Definition 7.3 gives
\begin{equation*} \begin{aligned} \mathbf{S}_{32} &= \{A\} \cap \{A,B,C,D,E,F,G,H\} = \{A\},\\ \mathbf{S}_{21} &= \{A,B\} \cap \{A,B,C,D,E,F,G,H\} = \{A,B\},\\ \mathbf{S}_{14} &= \{A,B,C\} \cap \{B,C,D,E,F,G,H\} = \{B,C\},\\ \mathbf{S}_{45} &= \{A,B,C,E\} \cap \{B,D,E,F,G,H\} = \{B,E\},\\ \mathbf{S}_{56} &= \{A,B,C,D,E\} \cap \{D,E,F,G,H\} = \{D,E\},\\ \mathbf{S}_{67} &= \{A,B,C,D,E,F\} \cap \{E,F,G,H\} = \{E,F\},\\ \mathbf{S}_{78} &= \{A,B,C,D,E,F,G\} \cap \{F,G,H\} = \{F,G\}. \end{aligned} \end{equation*}
and Definition 7.4, \(\mathbf{C}_i = \text{vars}(i) \cup \bigcup_j \mathbf{S}_{ij}\), gives
\begin{equation*} \begin{aligned} \mathbf{C}_3 &= \{A\} \cup \{A\} = \{A\},\\ \mathbf{C}_2 &= \{A,B\} \cup \{A\} \cup \{A,B\} = \{A,B\},\\ \mathbf{C}_1 &= \{A,C\} \cup \{A,B\} \cup \{B,C\} = \{A,B,C\},\\ \mathbf{C}_4 &= \{B,C,E\} \cup \{B,C\} \cup \{B,E\} = \{B,C,E\},\\ \mathbf{C}_5 &= \{B,D\} \cup \{B,E\} \cup \{D,E\} = \{B,D,E\},\\ \mathbf{C}_6 &= \{D,E,F\} \cup \{D,E\} \cup \{E,F\} = \{D,E,F\},\\ \mathbf{C}_7 &= \{E,G\} \cup \{E,F\} \cup \{F,G\} = \{E,F,G\},\\ \mathbf{C}_8 &= \{F,G,H\} \cup \{F,G\} = \{F,G,H\}. \end{aligned} \end{equation*}
The largest cluster has three variables, so the width is \(3 - 1 = 2\), matching the lower bound above.
Consider the Bayesian network in Figure 7.18 and the corresponding elimination tree in Figure 7.20, and suppose that the evidence indicator for each variable is assigned to the node corresponding to that variable (e.g., \(\lambda_C\) is assigned to node \(3\)). Suppose we are answering the following queries according to the given order:
\begin{equation*} \Pr(G = \text{true}), \quad \Pr(G, F = \text{true}), \quad \Pr(F, A = \text{true}, F = \text{true}), \end{equation*}
using Algorithm 12, FE.
- Compute the separators, clusters, and width of the given elimination tree.
- What messages are computed while answering each query according to the previous sequence? State the origin, destination, and value of each message. Use node \(7\) as the root to answer the first two queries, and node \(6\) as the root to answer the last query. For each query, compute only the messages directed toward the corresponding root.
- What messages are invalidated due to new evidence as we attempt each new query?
- What is the answer to each of the previous queries?
The Bayesian network of Figure 7.18 is the one described in Exercise 7.1: variables \(A, B, C, D, E, F, G\), edges \(A \to C\), \(B \to C\), \(C \to D\), \(C \to E\), \(D \to F\), \(E \to G\), and CPTs \(f_A = \Theta_A = (.6, .4)\), \(f_B = \Theta_B = (.5,.5)\), \(f_C = \Theta_{C \mid AB}\) with \(\Theta_{C=t \mid A=t,B=t} = .9\), \(\Theta_{C=t \mid A=t,B=f} = .1\), \(\Theta_{C=t \mid A=f,B=t} = .5\), \(\Theta_{C=t \mid A=f,B=f} = .3\), and
\begin{equation*} \begin{aligned} \Theta_{D=t \mid C=t} &= .2, & \Theta_{D=t \mid C=f} &= .7,\\ \Theta_{E=t \mid C=t} &= .1, & \Theta_{E=t \mid C=f} &= .2,\\ \Theta_{F=t \mid D=t} &= .7, & \Theta_{F=t \mid D=f} &= .6,\\ \Theta_{G=t \mid E=t} &= .2, & \Theta_{G=t \mid E=f} &= .8 . \end{aligned} \end{equation*}
The elimination tree of Figure 7.20 has seven nodes, one per CPT, namely \(\phi_1 = f_A\), \(\phi_2 = f_B\), \(\phi_3 = f_C\), \(\phi_4 = f_D\), \(\phi_5 = f_E\), \(\phi_6 = f_F\), \(\phi_7 = f_G\), and the edges
\begin{equation*} 1-3, \quad 2-3, \quad 3-4, \quad 3-5, \quad 4-6, \quad 5-7 . \end{equation*}
(So node \(3\) has neighbours \(1, 2, 4, 5\); node \(4\) has neighbours \(3, 6\); node \(5\) has neighbours \(3, 7\); nodes \(1, 2, 6, 7\) are leaves.) The evidence indicators are assigned as \(\lambda_A\) to node \(1\), \(\lambda_B\) to node \(2\), \(\lambda_C\) to node \(3\), \(\lambda_D\) to node \(4\), \(\lambda_E\) to node \(5\), \(\lambda_F\) to node \(6\), \(\lambda_G\) to node \(7\).
Part 1. Width \(2\). With \(\text{vars}(1) = \{A\}\), \(\text{vars}(2) = \{B\}\), \(\text{vars}(3) = \{A,B,C\}\), \(\text{vars}(4) = \{C,D\}\), \(\text{vars}(5) = \{C,E\}\), \(\text{vars}(6) = \{D,F\}\), \(\text{vars}(7) = \{E,G\}\) (each indicator \(\lambda_X\) sits at a node already containing \(X\), so it adds no variable), Definition 7.3 gives
\begin{equation*} \begin{aligned} \mathbf{S}_{13} &= \{A\} \cap \{A,B,C,D,E,F,G\} = \{A\},\\ \mathbf{S}_{23} &= \{B\} \cap \{A,B,C,D,E,F,G\} = \{B\},\\ \mathbf{S}_{34} &= \{A,B,C,E,G\} \cap \{C,D,F\} = \{C\},\\ \mathbf{S}_{35} &= \{A,B,C,D,F\} \cap \{C,E,G\} = \{C\},\\ \mathbf{S}_{46} &= \{A,B,C,D,E,G\} \cap \{D,F\} = \{D\},\\ \mathbf{S}_{57} &= \{A,B,C,D,E,F\} \cap \{E,G\} = \{E\}. \end{aligned} \end{equation*}
and Definition 7.4, \(\mathbf{C}_i = \text{vars}(i) \cup \bigcup_j \mathbf{S}_{ij}\), gives
\begin{equation*} \begin{aligned} \mathbf{C}_1 &= \{A\}, & \mathbf{C}_2 &= \{B\}, & \mathbf{C}_3 &= \{A,B,C\},\\ \mathbf{C}_4 &= \{C,D\}, & \mathbf{C}_5 &= \{C,E\}, & \mathbf{C}_6 &= \{D,F\},\\ \mathbf{C}_7 &= \{E,G\}. & & & & \end{aligned} \end{equation*}
The largest cluster is \(\mathbf{C}_3\), of size three, so the width is \(3 - 1 = 2\).
Part 2. Messages come from Equation 7.2, \(M_{ij} = \text{project}(\phi_i \prod_{k \ne j} M_{ki}, \mathbf{S}_{ij})\), with \(\phi_i\) including node \(i\)’s indicators (a \(\lambda_X\) for \(X\) outside the current evidence is the constant \(1\)).
Query 1: \(\Pr(G = \text{true})\), evidence \(G = \text{true}\), root \(7\). The messages toward \(7\) are
\begin{equation*} \begin{aligned} M_{13}(A) &= f_A \lambda_A = (.6, .4),\\ M_{23}(B) &= f_B \lambda_B = (.5, .5),\\ M_{64}(D) &= \textstyle\sum_F f_F \lambda_F = (1, 1),\\ M_{43}( C) &= \textstyle\sum_D f_D \lambda_D M_{64} = (1,1),\\ M_{35}( C) &= \textstyle\sum_{A,B} f_C \lambda_C M_{13} M_{23} M_{43},\\ M_{57}(E) &= \textstyle\sum_C f_E \lambda_E M_{35}, \end{aligned} \end{equation*}
over \(A\), \(B\), \(D\), \(C\), \(C\), \(E\) respectively, matching the separators of Part 1. Numerically \(M_{35} = \Pr( C)\):
\begin{equation*} \begin{aligned} M_{35}(C=t) &= .6 (.5 \cdot .9 + .5 \cdot .1) + .4 (.5 \cdot .5 + .5 \cdot .3)\\ &= .30 + .16 = .46,\\ M_{35}(C=f) &= .6 (.5 \cdot .1 + .5 \cdot .9) + .4 (.5 \cdot .5 + .5 \cdot .7)\\ &= .30 + .24 = .54, \end{aligned} \end{equation*}
and then
\begin{equation*} \begin{aligned} M_{57}(E=t) &= .46 \cdot .1 + .54 \cdot .2 = .154,\\ M_{57}(E=f) &= .46 \cdot .9 + .54 \cdot .8 = .846 . \end{aligned} \end{equation*}
Query 2: \(\Pr(G, F = \text{true})\), evidence \(F = \text{true}\), root \(7\). The same six messages serve; \(M_{13}, M_{23}\) are reused (Part 3) and the other four recomputed with \(\lambda_F\) the \(F = \text{true}\) indicator and \(\lambda_G \equiv 1\):
\begin{equation*} \begin{aligned} M_{64}(D) &= \Theta_{F=t \mid D} = (.7,\ .6),\\ M_{43}(C=t) &= .2 \cdot .7 + .8 \cdot .6 = .62,\\ M_{43}(C=f) &= .7 \cdot .7 + .3 \cdot .6 = .67,\\ M_{35}(C=t) &= .46 \cdot .62 = .2852,\\ M_{35}(C=f) &= .54 \cdot .67 = .3618,\\ M_{57}(E=t) &= .1 \cdot .2852 + .2 \cdot .3618 = .10088,\\ M_{57}(E=f) &= .9 \cdot .2852 + .8 \cdot .3618 = .54612 . \end{aligned} \end{equation*}
Query 3: evidence \(A = \text{true}, F = \text{true}\), root \(6\). Only \(M_{23}\) survives (Part 3), so the messages toward \(6\) are
\begin{equation*} \begin{aligned} M_{13}(A) &= f_A \lambda_A = (.6,\ 0),\\ M_{75}(E) &= \textstyle\sum_G f_G \lambda_G = (1, 1),\\ M_{53}( C) &= \textstyle\sum_E f_E \lambda_E M_{75} = (1, 1),\\ M_{34}( C) &= \textstyle\sum_{A,B} f_C \lambda_C M_{13} M_{23} M_{53} = \Pr(C, A = t),\\ M_{46}(D) &= \textstyle\sum_C f_D \lambda_D M_{34} . \end{aligned} \end{equation*}
Numerically,
\begin{equation*} \begin{aligned} M_{34}(C=t) &= .6\,(.5 \cdot .9 + .5 \cdot .1) = .30,\\ M_{34}(C=f) &= .6\,(.5 \cdot .1 + .5 \cdot .9) = .30,\\ M_{46}(D=t) &= .2 \cdot .30 + .7 \cdot .30 = .27,\\ M_{46}(D=f) &= .8 \cdot .30 + .3 \cdot .30 = .33 . \end{aligned} \end{equation*}
Part 3. A change of evidence at a node invalidates every message directed away from it (the invalidation rule of Algorithm 12, Figure 7.10).
(i) Query 1 to Query 2: evidence changes at node \(6\) (\(\lambda_F\)) and node \(7\) (\(\lambda_G\)). Away from \(6\) lie \(M_{64}, M_{43}, M_{35}, M_{57}\) (plus \(M_{31}, M_{32}, M_{34}\), never computed); away from \(7\) lie \(M_{75}, M_{53}, M_{31}, M_{32}, M_{34}, M_{46}\), none computed. So exactly \(M_{13}, M_{23}\) survive.
(ii) Query 2 to Query 3: only \(\lambda_A\) changes, at node \(1\). Away from \(1\) lie \(M_{13}, M_{32}, M_{34}, M_{35}, M_{46}, M_{57}\), which invalidates the stored \(M_{13}, M_{35}, M_{57}\). \(M_{23}, M_{64}, M_{43}\) stay valid, but with root \(6\) only \(M_{23}\) points the right way; \(M_{64}\) and \(M_{43}\) point at node \(3\), while Query 3 needs their reverses \(M_{34}, M_{46}\).
Part 4. Line 9 of Algorithm 12 returns \(\Pr(\mathbf{C}_i, \mathbf{e}) = \phi_i \prod_k M_{ki}\) at the root, where all incoming messages are available.
Query 1. At node \(7\), \(f_G \lambda_G M_{57}\) vanishes for \(G = \text{false}\) and otherwise
\begin{equation*} \begin{aligned} \Pr(E=t, G=t) &= .2 \cdot .154 = .0308,\\ \Pr(E=f, G=t) &= .8 \cdot .846 = .6768 . \end{aligned} \end{equation*}
Summing out \(E\),
\begin{equation*} \Pr(G = \text{true}) = .0308 + .6768 = .7076 . \end{equation*}
Query 2. At node \(7\), \(f_G M_{57}\) gives
\begin{equation*} \begin{aligned} \Pr(E=t, G=t, F=t) &= .2 \cdot .10088 = .020176,\\ \Pr(E=f, G=t, F=t) &= .8 \cdot .54612 = .436896,\\ \Pr(E=t, G=f, F=t) &= .8 \cdot .10088 = .080704,\\ \Pr(E=f, G=f, F=t) &= .2 \cdot .54612 = .109224 . \end{aligned} \end{equation*}
Summing out \(E\),
\begin{equation*} \Pr(G = \text{true}, F = \text{true}) = .457072, \qquad \Pr(G = \text{false}, F = \text{true}) = .189928 . \end{equation*}
Query 3. At node \(6\), \(f_F \lambda_F M_{46}\) vanishes for \(F = \text{false}\) and otherwise
\begin{equation*} \begin{aligned} \Pr(D=t, F=t, A=t) &= .7 \cdot .27 = .189,\\ \Pr(D=f, F=t, A=t) &= .6 \cdot .33 = .198 . \end{aligned} \end{equation*}
Summing out \(D\),
\begin{equation*} \Pr(F = \text{true}, A = \text{true}, F = \text{true}) = .387, \qquad \Pr(F = \text{false}, A = \text{true}, F = \text{true}) = 0 . \end{equation*}
The printed third query lists \(F\) both as query variable and as evidence, so its literal answer is degenerate; on the intended reading \(\Pr(F, A = \text{true})\) the same messages apply with \(\lambda_F \equiv 1\) at node \(6\), giving
\begin{equation*} \begin{aligned} \Pr(F = \text{true}, A = \text{true}) &= .7 \cdot .27 + .6 \cdot .33 = .387,\\ \Pr(F = \text{false}, A = \text{true}) &= .3 \cdot .27 + .4 \cdot .33 = .213 . \end{aligned} \end{equation*}
Prove Equation 7.1. Hint: Prove by induction, assuming first that node \(i\) has only a single neighbor and then prove for an arbitrary node \(i\).
Equation 7.1 refers to Line 4 of Algorithm 10, FE2. There, a node \(i \ne r\) with a single remaining neighbor \(j\) is removed from the current tree, \(\mathbf{V}\) is the set of variables appearing in the current factor \(\phi_i\) but not in the remaining tree, and the equation asserts
\begin{equation*} \sum_{\mathbf{V}} \phi_i = \text{project}(\phi_i, \mathbf{S}_{ij}), \end{equation*}
that is, the factor obtained by summing out \(\mathbf{V}\) from \(\phi_i\) is a factor over the separator \(\mathbf{S}_{ij}\) of Definition 7.3.
It suffices to prove that at each elimination step \(\text{vars}(\phi^{\ast}_i) = \mathbf{C}_i\) and \(\mathbf{V} = \mathbf{C}_i \setminus \mathbf{S}_{ij}\), since then summing out \(\mathbf{V}\) is summing out \(\text{vars}(\phi^{\ast}_i) \setminus \mathbf{S}_{ij}\), which is Equation 7.1.
Write \(T^{\prime}\) for the current tree and \(\phi^{\ast}_k\) for the current factor at node \(k\), and let \(D_k\) be the neighbors of \(k\) in \(T\) already eliminated; separators, clusters and the sets \(\text{vars}(i,j)\) always refer to the original \(T\). Line 3 defines \(\mathbf{V} = \text{vars}(\phi^{\ast}_i) \setminus \text{vars}(T^{\prime} - i)\). Induct on the number of steps, carrying the invariant
(a) \(\text{vars}(\phi^{\ast}_k) = \text{vars}(k) \cup \bigcup_{m \in D_k} \mathbf{S}_{km}\) for every \(k \in T^{\prime}\),
true initially since \(D_k = \emptyset\) and \(\text{vars}(\phi_k) = \text{vars}(k)\) (Definition 7.2). Let FE2 remove \(i\) with single remaining neighbor \(j\). Since Line 2 removes only leaves of \(T^{\prime}\), \(T^{\prime}\) is always a connected subtree of \(T\), so every neighbor of \(i\) other than \(j\) has been eliminated, i.e. \(D_i\) is all of them; (a) and Exercise 7.5 then give
\begin{equation*} \text{vars}(\phi^{\ast}_i) = \text{vars}(i) \cup \bigcup_{m \ne j} \mathbf{S}_{im} = \mathbf{C}_i . \end{equation*}
It remains to show \(\mathbf{C}_i \cap \text{vars}(T^{\prime} - i) = \mathbf{S}_{ij}\). Note first that \(T^{\prime} - i\) is connected, avoids \(i\), and contains \(j\), so it lies on the \(j\)-side of the edge \(i-j\).
(i) Left to right. Let \(X \in \mathbf{C}_i \cap \text{vars}(T^{\prime}-i)\); then \(X \in \text{vars}(i,j)\) by Exercise 7.7. Also \(X \in \text{vars}(\phi^{\ast}_k)\) for some remaining \(k \ne i\), so by (a) either \(X \in \text{vars}(k)\) or \(X \in \mathbf{S}_{km} \subseteq \text{vars}(m,k)\) for some \(m \in D_k\). Both \(k\) and \(m\) lie on the \(j\)-side (\(m\) is a neighbor of \(k\) other than the uneliminated \(i\)), hence so does the whole \(m\)-side of \(k-m\); thus \(X \in \text{vars}(j,i)\) and \(X \in \mathbf{S}_{ij}\).
(ii) Right to left. Let \(X \in \mathbf{S}_{ij}\), so \(X \in \mathbf{C}_i\) by Definition 7.4 and \(X \in \text{vars}(p)\) for some \(p\) on the \(j\)-side. If \(p \in T^{\prime}\) then \(X \in \text{vars}(\phi^{\ast}_p)\) by (a) and we are done. Otherwise let \(k\) be the first node of \(T^{\prime}\) on the path from \(p\) to \(i\) (it exists as \(j \in T^{\prime}\), and \(k \ne i\) as \(j\) precedes \(i\)), and let \(m\) be its predecessor, so \(m \in D_k\) and \(X \in \text{vars}(p) \subseteq \text{vars}(m,k)\). Since \(X \in \text{vars}(i,j)\) there is \(s\) on the \(i\)-side with \(X \in \text{vars}(s)\), and the path \(s, \dots, i, j, \dots, k, m\) places \(s\) on the \(k\)-side of \(k-m\), so \(X \in \text{vars}(k,m)\). Hence \(X \in \mathbf{S}_{km} \subseteq \text{vars}(\phi^{\ast}_k) \subseteq \text{vars}(T^{\prime}-i)\).
Therefore \(\mathbf{V} = \mathbf{C}_i \setminus \mathbf{S}_{ij}\) and
\begin{equation*} \sum_{\mathbf{V}} \phi^{\ast}_i = \sum_{\text{vars}(\phi^{\ast}_i) \setminus \mathbf{S}_{ij}} \phi^{\ast}_i = \text{project}(\phi^{\ast}_i, \mathbf{S}_{ij}), \end{equation*}
which is Equation 7.1. Line 4 then multiplies this factor over \(\mathbf{S}_{ij} = \mathbf{S}_{ji}\) into \(\phi^{\ast}_j\) and changes nothing else, so (a) holds for \(j\) with the enlarged set \(D_j \cup \{i\}\) and the induction closes.
Let \(i\) be a node in an elimination tree. Show that for any particular neighbor \(k\) of \(i\), we have
\begin{equation*} \mathbf{S}_{ik} \subseteq \text{vars}(i) \cup \bigcup_{j \ne k} \mathbf{S}_{ij} \end{equation*}
and hence
\begin{equation*} \mathbf{C}_i = \text{vars}(i) \cup \bigcup_{j \ne k} \mathbf{S}_{ij}, \end{equation*}
where the unions range over the neighbors \(j \ne k\) of node \(i\).
Both claims follow from two facts about the tree, with \(j\) ranging over the neighbors of \(i\) other than \(k\) and \(\mathbf{S}_{ij} = \text{vars}(i,j) \cap \text{vars}(j,i)\) as in Definition 7.3.
Fact 1. Deleting \(i-k\) leaves the component of \(i\), which is \(\{i\}\) together with the subtrees hanging off \(i\) through its other neighbors, so
\begin{equation*} \text{vars}(i,k) = \text{vars}(i) \cup \bigcup_{j \ne k} \text{vars}(j,i). \end{equation*}
Fact 2. Every node on the \(k\)-side of \(i-k\) reaches \(j\) by a path through \(k\) and then \(i\), so deleting \(i-j\) leaves it in the component of \(i\); hence \(\text{vars}(k,i) \subseteq \text{vars}(i,j)\).
Let \(X \in \mathbf{S}_{ik}\), so \(X \in \text{vars}(i,k)\) and \(X \in \text{vars}(k,i)\). By Fact 1 either \(X \in \text{vars}(i)\), or \(X \in \text{vars}(j,i)\) for some \(j \ne k\), in which case Fact 2 gives \(X \in \text{vars}(k,i) \subseteq \text{vars}(i,j)\) and hence \(X \in \mathbf{S}_{ij}\). Either way \(X\) lies in \(\text{vars}(i) \cup \bigcup_{j \ne k} \mathbf{S}_{ij}\), which is the first claim. (If \(k\) is the only neighbor of \(i\), the second alternative cannot arise and \(\mathbf{S}_{ik} \subseteq \text{vars}(i,k) = \text{vars}(i)\).)
Definition 7.4 then gives
\begin{equation*} \mathbf{C}_i = \Big( \text{vars}(i) \cup \bigcup_{j \ne k} \mathbf{S}_{ij} \Big) \cup \mathbf{S}_{ik} = \text{vars}(i) \cup \bigcup_{j \ne k} \mathbf{S}_{ij}, \end{equation*}
the trailing term being absorbed by the first claim.
Prove the following statement with respect to Algorithm 12, FE:
\begin{equation*} M_{ij} = \text{project}(\phi_{ij}, \mathbf{S}_{ij}), \end{equation*}
where \(\phi_{ij}\) is the product of all factors assigned to nodes on the \(i\)-side of edge \(i-j\) in the elimination tree. Use this result to show that
\begin{equation*} M_{ij} M_{ji} = \Pr(\mathbf{S}_{ij}, \mathbf{e}) \end{equation*}
for every edge \(i-j\) in the elimination tree.
Part 1 is an induction on the number of nodes on the \(i\)-side of \(i-j\), with \(\phi_{ij}\) the product of all factors (CPTs and indicators, by Lines 1 to 5 of Algorithm 12) assigned there, so that \(\text{vars}(\phi_{ij}) = \text{vars}(i,j)\). Throughout, a factor pulls out of any summation over variables it does not mention, and summations over distinct variables commute.
Base case: the \(i\)-side is \(\{i\}\), so \(i\) is a leaf, the product in Equation 7.2 is empty and \(\phi_{ij} = \phi_i\).
Inductive step: let \(k_1, \dots, k_n\) be the neighbors of \(i\) other than \(j\). Deleting \(i\) splits the \(i\)-side into \(\{i\}\) and the pairwise disjoint \(k_t\)-sides of the edges \(k_t - i\) (Fact 1 of Exercise 7.5), so
\begin{equation*} \phi_{ij} = \phi_i \prod_{t=1}^{n} \phi_{k_t i}, \qquad \text{vars}(\phi_{ij}) = \text{vars}(i) \cup \bigcup_{t} \text{vars}(k_t, i), \end{equation*}
and each \(k_t\)-side is smaller, so \(M_{k_t i} = \text{project}(\phi_{k_t i}, \mathbf{S}_{k_t i})\) by hypothesis. Put \(\mathbf{U}_t = \text{vars}(k_t, i) \setminus \mathbf{S}_{k_t i}\). A variable of \(\mathbf{U}_t\) lies in \(\text{vars}(k_t,i)\) but not \(\text{vars}(i,k_t)\), hence occurs in no factor outside the \(k_t\)-side; so the \(\mathbf{U}_t\) are pairwise disjoint and disjoint from \(\text{vars}(i)\), from every \(\mathbf{S}_{k_s i}\), and from \(\mathbf{S}_{ij} \subseteq \text{vars}(j,i)\). They are therefore among the variables that \(\text{project}(\phi_{ij}, \mathbf{S}_{ij})\) sums out, and may be summed out first:
\begin{equation*} \begin{aligned} \sum_{\mathbf{U}_1 \cup \cdots \cup \mathbf{U}_n} \phi_i \prod_t \phi_{k_t i} &= \phi_i \prod_t \Big( \sum_{\mathbf{U}_t} \phi_{k_t i} \Big)\\ &= \phi_i \prod_t \text{project}(\phi_{k_t i}, \mathbf{S}_{k_t i}) = \phi_i \prod_t M_{k_t i}, \end{aligned} \end{equation*}
the second equality using \(\text{vars}(\phi_{k_t i}) \setminus \mathbf{S}_{k_t i} = \mathbf{U}_t\). The variables so removed are exactly \(\bigcup_t \mathbf{U}_t\), and by the disjointness above
\begin{equation*} \text{vars}(\phi_{ij}) \setminus \bigcup_t \mathbf{U}_t = \text{vars}(i) \cup \bigcup_t \mathbf{S}_{k_t i} = \text{vars}\Big(\phi_i \prod_t M_{k_t i}\Big), \end{equation*}
which is the cluster \(\mathbf{C}_i \supseteq \mathbf{S}_{ij}\) by Exercise 7.5. Summing out what remains, \(\mathbf{C}_i \setminus \mathbf{S}_{ij}\), and applying Equation 7.2,
\begin{equation*} \text{project}(\phi_{ij}, \mathbf{S}_{ij}) = \text{project}\Big(\phi_i \prod_t M_{k_t i}, \mathbf{S}_{ij}\Big) = M_{ij}. \end{equation*}
Part 2. By Part 1 and \(\mathbf{S}_{ji} = \mathbf{S}_{ij}\), both \(M_{ij}\) and \(M_{ji}\) are factors over \(\mathbf{S}_{ij}\). Write \(\mathbf{A} = \text{vars}(i,j) \setminus \mathbf{S}_{ij}\) and \(\mathbf{B} = \text{vars}(j,i) \setminus \mathbf{S}_{ij}\); Definition 7.3 makes \(\mathbf{A}, \mathbf{B}\) disjoint, with no variable of \(\mathbf{B}\) in \(\phi_{ij}\) and none of \(\mathbf{A}\) in \(\phi_{ji}\), so
\begin{equation*} \begin{aligned} \text{project}(\phi_{ij}\phi_{ji}, \mathbf{S}_{ij}) &= \sum_{\mathbf{A}} \sum_{\mathbf{B}} \phi_{ij}\phi_{ji} = \sum_{\mathbf{A}} \phi_{ij} \sum_{\mathbf{B}} \phi_{ji}\\ &= \Big( \sum_{\mathbf{A}} \phi_{ij} \Big) \Big( \sum_{\mathbf{B}} \phi_{ji} \Big) = M_{ij} M_{ji}. \end{aligned} \end{equation*}
Every node lies on exactly one side of \(i-j\) and every CPT and indicator is assigned to exactly one node (Definition 7.2, Lines 1 to 5 of Algorithm 12), so \(\phi_{ij}\phi_{ji}\) is the product of all factors,
\begin{equation*} \phi_{ij}\phi_{ji} = \prod_{X} \Theta_{X \mid \mathbf{P}_X} \prod_{E \in \mathbf{e}} \lambda_E , \end{equation*}
with \(\mathbf{P}_X\) the parents of \(X\). By the chain rule (Equation 4.2) the first product evaluates at an instantiation \(\mathbf{z}\) of all network variables to \(\Pr(\mathbf{z})\), while the second is \(1\) if \(\mathbf{z} \sim \mathbf{e}\) and \(0\) otherwise. Hence for each instantiation \(\mathbf{s}\) of \(\mathbf{S}_{ij}\),
\begin{equation*} \text{project}(\phi_{ij}\phi_{ji}, \mathbf{S}_{ij})(\mathbf{s}) = \sum_{\mathbf{z} \sim \mathbf{s}} \Pr(\mathbf{z}) \prod_{E} \lambda_E(\mathbf{z}) = \sum_{\mathbf{z} \sim \mathbf{s}, \ \mathbf{z} \sim \mathbf{e}} \Pr(\mathbf{z}) = \Pr(\mathbf{s}, \mathbf{e}). \end{equation*}
Combining the last two displays, \(M_{ij} M_{ji} = \Pr(\mathbf{S}_{ij}, \mathbf{e})\).
Prove that for every edge \(i-j\) in an elimination tree, \(\mathbf{S}_{ij} = \mathbf{C}_i \cap \mathbf{C}_j\).
One inclusion is immediate from Definition 7.4: the union defining \(\mathbf{C}_i\) has \(j\) among its neighbors and so contains the term \(\mathbf{S}_{ij}\), while the union defining \(\mathbf{C}_j\) contains \(\mathbf{S}_{ji} = \mathbf{S}_{ij}\) (the expression of Definition 7.3 is symmetric). Hence \(\mathbf{S}_{ij} \subseteq \mathbf{C}_i \cap \mathbf{C}_j\).
The reverse inclusion follows from the claim that \(\mathbf{C}_i \subseteq \text{vars}(i,j)\) for every edge \(i-j\). Since \(\mathbf{C}_i = \text{vars}(i) \cup \bigcup_m \mathbf{S}_{im}\), check the three kinds of piece: \(\text{vars}(i) \subseteq \text{vars}(i,j)\) as \(i\) sits on the \(i\)-side; \(\mathbf{S}_{ij} \subseteq \text{vars}(i,j)\) by Definition 7.3; and for a neighbor \(m \ne j\), every node on the \(m\)-side of \(i-m\) reaches \(j\) through \(m\) and then \(i\), so deleting \(i-j\) leaves it in the component of \(i\), giving \(\mathbf{S}_{im} \subseteq \text{vars}(m,i) \subseteq \text{vars}(i,j)\).
Applying the claim at both ends of the edge,
\begin{equation*} \mathbf{C}_i \cap \mathbf{C}_j \subseteq \text{vars}(i,j) \cap \text{vars}(j,i) = \mathbf{S}_{ij}. \end{equation*}
Exercises 7.8–7.14
Let \(N\) be a Bayesian network and let \((T,\phi)\) be an elimination tree of width \(w\) for the CPTs of network \(N\). Show how to construct an elimination order for network \(N\) of width \(\le w\).
Hint: Consider the order in which variables are eliminated in the context of factor elimination.
Run FE3 (Algorithm 11) on \((T,\phi)\) from any root \(r\), let \(i_1,\ldots,i_{m-1}\) be the nodes it removes and \(j_k\) the unique remaining neighbour of \(i_k\) at step \(k\), and take
\begin{equation*} \pi \;=\; V_1,\; \ldots,\; V_{m-1},\; C_r, \qquad V_k \;=\; C_{i_k}\setminus S_{i_k j_k}, \end{equation*}
the variables inside each block in arbitrary order. This is well defined: \(i_k\) is eliminated only once all its neighbours but \(j_k\) are gone, so by Exercise 7.5 its current factor is over exactly \(C_{i_k}\), and projecting on \(S_{i_k j_k}\) sums out \(V_k\).
\(\pi\) is a legal order. By Line 3 of FE2 a variable \(X\in V_k\) appears in \(\phi_{i_k}\) but in no factor of the tree remaining after step \(k\), so it lies in no later block and not in \(C_r\); conversely every network variable occurs in some CPT, hence is either summed out at a unique step or survives into \(\phi_r\), i.e. into \(C_r\). So \(\pi\) lists every variable exactly once.
Write \(T_k\) for the tree remaining just before step \(k\). Two observations:
(1) A variable \(X\in V_k\) occurs only in the factor \(\phi_{i_k}\) of \(T_k\), hence in no separator of \(T_k\) (a separator needs factors on both sides of its edge) and, since \(C_l=\mathrm{vars}(l)\cup\bigcup_m S_{lm}\), in no cluster of \(T_k\) other than \(C_{i_k}\).
(2) The clusters and separators of \(T_k\) are the original ones throughout. Passing to \(T_{k+1}\) deletes exactly \(V_k\) from one side of each edge, and by (1) those variables occur nowhere else, so no separator changes; the factor at \(j_k\) gains \(S_{i_k j_k}\), exactly the separator term its cluster loses with the deleted edge, and no other factor changes.
Width. On the interaction graph, eliminating \(X\) connects its current neighbours pairwise and deletes \(X\), and the width is the largest \(\{X\}\) together with those neighbours, minus one. Let \(G_k\) be the interaction graph just before block \(V_k\), and \(H_k\) the graph whose edges are the pairs lying together in some cluster \(C_l\), \(l\in T_k\). Then \(G_k\subseteq H_k\): for \(k=1\) each CPT sits at a node \(i\) with its variables inside \(\mathrm{vars}(i)\subseteq C_i\); and given \(G_k\subseteq H_k\), each \(X\in V_k\) lies by (1) in the single cluster \(C_{i_k}\), so its \(G_k\)-neighbours lie in \(C_{i_k}\setminus\{X\}\), its cluster is contained in \(C_{i_k}\), and the fill-in edges it creates join variables already adjacent in \(H_k\). After the block the surviving cliques are the \(C_l\), \(l\neq i_k\), together with \(C_{i_k}\setminus V_k=S_{i_k j_k}\subseteq C_{j_k}\), which by (2) are the cliques of \(H_{k+1}\).
After step \(m-1\) only \(r\) survives, the remaining variables are \(C_r\), and the graph is a subgraph of that clique. Every variable of \(\pi\) therefore has its cluster inside some \(C_i\), so
\begin{equation*} \mathrm{width}(\pi)\;\le\;\max_i |C_i| - 1 \;=\; w . \end{equation*}
Consider the following set of factors: \(f(ABE)\), \(f(ACD)\), and \(f(DEF)\). Show that the optimal elimination tree (the one with smallest width) for this set of factors must have more than three nodes (hence, the set of nodes in the elimination tree cannot be in one-to-one correspondence with the factors).
The optimal width is \(2\), attained by the four-node star below and by no tree with three or fewer nodes.
Lower bound \(2\): each factor sits at some node \(i\) with \(\mathrm{vars}(i)\subseteq C_i\), and each has three variables, so some cluster has size \(\ge 3\).
Width \(2\) with four nodes. Take the star \(T\) with a fourth node \(4\) carrying no factor, adjacent to the three factor nodes \(1,2,3\):
\begin{equation*} \phi_1=f(ABE),\quad \phi_2=f(ACD),\quad \phi_3=f(DEF),\quad \phi_4=1, \end{equation*}
with edges \(1\!-\!4\), \(2\!-\!4\), \(3\!-\!4\) (Definition 7.2 requires only that each factor sit at exactly one node, so node \(4\) may carry the empty product, \(\mathrm{vars}(4)=\emptyset\)). The separators are
\begin{equation*} \begin{aligned} S_{14}&=\{A,B,E\}\cap\{A,C,D,E,F\}=\{A,E\},\\ S_{24}&=\{A,C,D\}\cap\{A,B,D,E,F\}=\{A,D\},\\ S_{34}&=\{D,E,F\}\cap\{A,B,C,D,E\}=\{D,E\}, \end{aligned} \end{equation*}
and therefore the clusters are
\begin{equation*} \begin{aligned} C_1&=\{A,B,E\},& C_2&=\{A,C,D\},\\ C_3&=\{D,E,F\},& C_4&=\{A,D,E\}. \end{aligned} \end{equation*}
All four clusters have size \(3\), so the width is \(2\), optimal by the lower bound.
At most three nodes. Two cases.
(i) Some node carries two factors. Its cluster contains the union of their variables, and
\begin{equation*} ABE\cup ACD=ABCDE,\quad ABE\cup DEF=ABDEF,\quad ACD\cup DEF=ACDEF \end{equation*}
each have size \(5\), so the width is at least \(4\).
(ii) Exactly three nodes, one factor each — the one-to-one case. A tree on three nodes is a path, and in each of the three arrangements the middle node absorbs both separators into a cluster of size \(4\), giving width \(3\). Writing \(1,2,3\) for the nodes of \(f(ABE)\), \(f(ACD)\), \(f(DEF)\):
- \(1\!-\!2\!-\!3\): \(S_{12}=\{A,E\}\), \(S_{23}=\{D,E\}\), so \(C_2=\{A,C,D,E\}\).
- \(2\!-\!1\!-\!3\): \(S_{12}=\{A,D\}\), \(S_{13}=\{D,E\}\), so \(C_1=\{A,B,D,E\}\).
- \(1\!-\!3\!-\!2\): \(S_{13}=\{A,E\}\), \(S_{23}=\{A,D\}\), so \(C_3=\{A,D,E,F\}\).
So no elimination tree with three or fewer nodes attains width \(2\), and the optimal tree has more than three nodes.
A cutset \(\mathbf{C}\) for a DAG \(G\) is a set of nodes that renders \(G\) a polytree when all edges outgoing from nodes \(\mathbf{C}\) are removed. Let \(k\) be the maximum number of parents per node in the DAG \(G\). Show how to construct an elimination tree for \(G\) whose width is \(\le k+|\mathbf{C}|\).
Let \(G^{\prime}\) be \(G\) with every edge leaving \(\mathbf{C}\) deleted, a polytree by hypothesis, and take \(T\) with one node per variable of \(G\), edges those of the skeleton of \(G^{\prime}\) plus any set joining its components into a single tree, and node \(X\) carrying the original CPT \(\Theta_{X|\mathbf{U}_X}\), where \(\mathbf{U}_X\) are the parents of \(X\) in \(G\). By Definition 7.2 this is an elimination tree (each CPT sits at exactly one node), \(\mathrm{vars}(X)=\{X\}\cup\mathbf{U}_X\) has at most \(k+1\) variables, and its width is at most \(k+|\mathbf{C}|\).
Key observation: an edge \(Y\to Z\) of \(G\) survives in \(G^{\prime}\) unless \(Y\in\mathbf{C}\), so every parent of \(Z\) is either in \(\mathbf{C}\) or a skeleton neighbour of \(Z\), hence a neighbour of \(Z\) in \(T\).
Separators. Let \(X\!-\!Y\) be an edge of \(T\), splitting it into \(T_X\ni X\) and \(T_Y\ni Y\), and take \(Z\in T_X\) with a parent \(W\in\mathbf{U}_Z\setminus\mathbf{C}\). By the observation \(Z\!-\!W\) is an edge of \(T\), and the only edge crossing the cut is \(X\!-\!Y\), so either \(W\in T_X\) or \(Z=X\) and \(W=Y\); hence \(\mathrm{vars}(X,Y)\subseteq T_X\cup\mathbf{C}\cup\{Y\}\), and symmetrically \(\mathrm{vars}(Y,X)\subseteq T_Y\cup\mathbf{C}\cup\{X\}\). If \(X\!-\!Y\) comes from the polytree edge \(X\to Y\) the exception cannot arise, since it would put \(Y\in\mathbf{U}_X\) against the acyclicity of \(G^{\prime}\); then \(\mathrm{vars}(X,Y)\subseteq T_X\cup\mathbf{C}\) and, as \(T_X\cap T_Y=\emptyset\),
\begin{equation*} S_{XY}\;\subseteq\;\bigl(T_X\cup\mathbf{C}\bigr) \cap\bigl(T_Y\cup\mathbf{C}\cup\{X\}\bigr)\;=\;\{X\}\cup\mathbf{C}. \end{equation*}
If \(X\!-\!Y\) is one of the added edges, no skeleton edge crosses the cut and the same computation gives \(S_{XY}\subseteq\mathbf{C}\).
Clusters. A neighbour \(Y\) of \(X\) in \(T\) is of one of three kinds: \(X\to Y\) in \(G^{\prime}\), giving \(S_{XY}\subseteq\{X\}\cup\mathbf{C}\); \(Y\to X\) in \(G^{\prime}\), giving \(S_{XY}\subseteq\{Y\}\cup\mathbf{C}\) by the same argument with the roles swapped, and \(Y\in\mathbf{U}_X\) since \(Y\) is then a parent of \(X\) in \(G^{\prime}\) hence in \(G\); or joined by an added edge, giving \(S_{XY}\subseteq\mathbf{C}\). In every case \(S_{XY}\subseteq\{X\}\cup\mathbf{U}_X\cup\mathbf{C}\), so
\begin{equation*} C_X\;\subseteq\;\{X\}\cup\mathbf{U}_X\cup\mathbf{C}, \qquad \max_X |C_X| - 1 \;\le\; k+|\mathbf{C}| . \end{equation*}
Show that the message defined by Equation 7.4,
\begin{equation*} M_{ij} \;=\; \sum_{C_i\setminus S_{ij}} \Phi_i \prod_{k\neq j} M_{ki}, \end{equation*}
can be computed in space that is exponential only in the size of separator \(S_{ij}\), given messages \(M_{ki}\), \(k\neq j\), and the factors assigned to node \(i\) (here \(\Phi_i\) is the product of the factors, including evidence indicators, assigned to node \(i\)).
Accumulate the sum one cluster instantiation at a time, so that \(F=\Phi_i\prod_{k\neq j}M_{ki}\) — the factor over \(C_i\) that a naive reading of Equation 7.4 would build first — is never materialised. Let \(f_1,\ldots,f_p\) be the factors at node \(i\) (CPTs and indicators) and \(M_{k_1i},\ldots,M_{k_qi}\) the incoming messages, \(k_s\neq j\); all are already-stored inputs.
- Allocate \(M_{ij}\) over \(S_{ij}\) and set \(M_{ij}(\mathbf{s})\leftarrow 0\) for every instantiation \(\mathbf{s}\).
- Enumerate the instantiations \(\mathbf{c}\) of \(C_i\) one at a time, by an odometer over its variables. For each, compute the single number \(v = \prod_{t} f_t(\mathbf{c}_{\mathrm{vars}(f_t)}) \prod_{s} M_{k_si}(\mathbf{c}_{S_{k_si}})\), writing \(\mathbf{c}_{\mathbf{X}}\) for the restriction of \(\mathbf{c}\) to \(\mathbf{X}\), and update \(M_{ij}(\mathbf{s})\leftarrow M_{ij}(\mathbf{s})+v\) at \(\mathbf{s}=\mathbf{c}_{S_{ij}}\).
- Return \(M_{ij}\).
Correctness: every factor in the product is over a subset of \(C_i\), since \(\mathrm{vars}(f_t)\subseteq\mathrm{vars}(i)\subseteq C_i\) and \(S_{k_si}\subseteq C_i\) by Definition 7.4, so \(\mathbf{c}\) determines each of their values and \(v=F(\mathbf{c})\). Grouping the \(\mathbf{c}\) by their restriction to \(S_{ij}\), the accumulator holds
\begin{equation*} M_{ij}(\mathbf{s})\;=\;\sum_{\mathbf{c}\sim\mathbf{s}} F(\mathbf{c}) \;=\;\Bigl(\sum_{C_i\setminus S_{ij}} F\Bigr)(\mathbf{s}), \end{equation*}
which is Equation 7.4.
Space: beyond its inputs the procedure allocates only the output table, of \(\prod_{X\in S_{ij}}|X|\) entries, and the odometer, running product and indices, \(O(|C_i|)\) numbers — in total \(O(\exp(|S_{ij}|)+|C_i|)\), exponential in the separator alone. Nor are the inputs exponential in \(|C_i|\): each \(f_t\) is a CPT or an evidence indicator, and each \(M_{k_si}\) is stored over a separator.
Consider the elimination tree on the left of Figure 7.13. The underlying network is the DAG of Figure 7.12(a), with edges
\begin{equation*} \begin{aligned} &A\to B,\quad A\to C,\quad A\to D,\quad A\to E,\quad A\to F,\\ &B\to D,\quad C\to E,\quad D\to G,\quad F\to G,\quad E\to H,\quad F\to H, \end{aligned} \end{equation*}
so that its CPTs are \(\Theta_A\), \(\Theta_{B|A}\), \(\Theta_{C|A}\), \(\Theta_{D|AB}\), \(\Theta_{E|AC}\), \(\Theta_{F|A}\), \(\Theta_{G|DF}\), \(\Theta_{H|EF}\). The elimination tree in question has six nodes with edges
\begin{equation*} 1-3,\qquad 3-4,\qquad 3-5,\qquad 2-4,\qquad 4-6, \end{equation*}
and factor assignment
| node | assigned factors | vars |
|---|---|---|
| 1 | \(\Theta_{G\mid DF}\) | \(DFG\) |
| 2 | \(\Theta_{C\mid A}\Theta_{E\mid AC}\) | \(ACE\) |
| 3 | none (trivial factor) | \(\emptyset\) |
| 4 | \(\Theta_A\Theta_{F\mid A}\) | \(AF\) |
| 5 | \(\Theta_{B\mid A}\Theta_{D\mid AB}\) | \(ABD\) |
| 6 | \(\Theta_{H\mid EF}\) | \(EFH\) |
Its separators are \(S_{13}=DF\), \(S_{34}=AF\), \(S_{35}=AD\), \(S_{24}=AE\), \(S_{46}=EF\), and its clusters are those of the minimal jointree of Figure 7.12(b):
\begin{equation*} C_1=DFG,\; C_2=ACE,\; C_3=ADF,\; C_4=AEF,\; C_5=ABD,\; C_6=EFH, \end{equation*}
so the tree has width \(2\).
Using factor elimination on this tree, one cannot compute the marginal over \(AEFH\) as these variables are not contained in any cluster. Construct an elimination tree with width \(3\) that allows us to compute the marginal over these variables. Construct another elimination tree with width \(3\) that allows us to compute the marginal over variables \(GH\).
Note: You may need to introduce auxiliary factors.
Part 1. Add the auxiliary factor \(f(H)\equiv 1\) at node \(4\), keeping the printed structure and all other assignments; a factor identically one changes no marginal and only enlarges \(\mathrm{vars}(4)\) to \(\{A,F,H\}\), which is the elimination-tree form of the nonminimal-jointree trick of Section 7.7.2. Since FE3 (Algorithm 11) needs a root \(r\) with \(\mathbf{Q}\subseteq C_r\), it is enough to drive \(H\) into \(C_4\); the separators carry \(A\), \(E\), \(F\) there already.
Only \(S_{46}\) changes: the \(6\)-side of \(4\!-\!6\) has variables \(\{E,F,H\}\) and the \(4\)-side now has \(\{D,F,G\}\cup\{A,C,E\}\cup\{A,F,H\}\cup\{A,B,D\}\), all eight, so
\begin{equation*} S_{46}=\{E,F,H\}. \end{equation*}
The rest are as before: on \(3\!-\!4\) the two sides are \(\{A,C,E,F,H\}\) and \(\{A,B,D,F,G\}\), giving \(S_{34}=AF\); likewise \(S_{13}=DF\), \(S_{35}=AD\), \(S_{24}=AE\). Hence
\begin{equation*} \begin{aligned} C_1&=DFG, & C_2&=ACE, & C_3&=ADF,\\ C_4&=AEFH, & C_5&=ABD, & C_6&=EFH. \end{aligned} \end{equation*}
since \(C_4=\{A,F,H\}\cup\{A,F\}\cup\{A,E\}\cup\{E,F,H\}\). The largest cluster has four variables, so the width is \(3\), and with root \(4\), FE3 returns \(\Pr(AEFH)\).
Part 2. Add \(f(GH)\equiv 1\) at node \(1\), so \(\mathrm{vars}(1)=\{D,F,G,H\}\), all other assignments unchanged. A one-variable factor will not do here: \(G\) occurs only at node \(1\) and \(H\) only at node \(6\), three edges away, so \(H\) has to be carried along the path \(6-4-3-1\). Along it \(H\) now appears on both sides of every edge:
\begin{equation*} \begin{aligned} S_{46}&=\{E,F,H\}\cap\{A,B,C,D,E,F,G,H\}=\{E,F,H\},\\ S_{34}&=\{A,B,D,F,G,H\}\cap\{A,C,E,F,H\}=\{A,F,H\},\\ S_{13}&=\{D,F,G,H\}\cap\{A,B,C,D,E,F,H\}=\{D,F,H\}, \end{aligned} \end{equation*}
while \(S_{35}=AD\) and \(S_{24}=AE\) are untouched. The clusters are
\begin{equation*} \begin{aligned} C_1&=DFGH, & C_2&=ACE, & C_3&=ADFH,\\ C_4&=AEFH, & C_5&=ABD, & C_6&=EFH. \end{aligned} \end{equation*}
for instance \(C_3=S_{13}\cup S_{34}\cup S_{35}=\{D,F,H\}\cup\{A,F,H\}\cup\{A,D\}\). The largest clusters have size \(4\), so the width is again \(3\); with root \(1\), FE3 returns \(\Pr(C_1)=\Pr(DFGH)\), whose projection on \(GH\) is \(\Pr(GH)\).
Consider the polytree algorithm as discussed in Section 7.5.4. Here the Bayesian network has a polytree structure, and the elimination tree used is the one of Figure 7.11: it has one node per network variable \(X\), its edges are the edges of the polytree (with directions dropped), and the CPT \(\Theta_{X|\mathbf{U}_X}\) together with the evidence indicator \(\lambda_X\) of variable \(X\) are assigned to the corresponding node.
Let \(X\to Y\) be an edge in the polytree. Show that the messages \(M_{XY}\) and \(M_{YX}\) sent across this edge must be over variable \(X\).
Both messages are factors over the separator \(S_{XY}\), since Equation 7.2 projects onto it and \(S_{ij}=S_{ji}\); so it is enough to show \(S_{XY}=\{X\}\).
Node \(Z\) carries \(\Theta_{Z|\mathbf{U}_Z}\) and \(\lambda_Z\), so \(\mathrm{vars}(Z)=\{Z\}\cup\mathbf{U}_Z\) is the family of \(Z\). Removing \(X\!-\!Y\) splits the tree into the disjoint \(T_X\ni X\) and \(T_Y\ni Y\), and by Definition 7.3, \(\mathrm{vars}(X,Y)=\bigcup_{Z\in T_X}(\{Z\}\cup\mathbf{U}_Z)\).
The \(X\)-side. Let \(Z\in T_X\) and \(W\in\mathbf{U}_Z\), so that \(W\!-\!Z\) is an edge of the elimination tree. The only edge joining \(T_X\) to \(T_Y\) is \(X\!-\!Y\), so \(W\in T_X\) unless \(Z=X\) and \(W=Y\) — and that exception would give \(Y\to X\), impossible alongside \(X\to Y\) in an acyclic polytree. Hence \(\mathrm{vars}(X,Y)=T_X\), the reverse inclusion holding since \(Z\in\mathrm{vars}(Z)\).
The \(Y\)-side. The same argument permits exactly one exception, \(Z=Y\) with \(W=X\), and it does occur since \(X\to Y\) means \(X\in\mathbf{U}_Y\). Hence \(\mathrm{vars}(Y,X)=T_Y\cup\{X\}\), and
\begin{equation*} S_{XY}\;=\;T_X\cap\bigl(T_Y\cup\{X\}\bigr)\;=\;\{X\}. \end{equation*}
Consider the polytree algorithm as discussed in Section 7.5.4 — the elimination tree has one node per network variable \(X\), its edges are those of the polytree, and node \(X\) carries \(\Theta_{X|\mathbf{U}_X}\) and the evidence indicator \(\lambda_X\) — and let \(\mathbf{e}\) be some given evidence. Let \(X\to Y\) be an edge in the polytree, let \(\mathbf{e}^{+}_{XY}\) be the evidence assigned to nodes on the \(X\)-side of this edge, and let \(\mathbf{e}^{-}_{XY}\) be the evidence assigned to nodes on the \(Y\)-side of the edge (hence \(\mathbf{e}=\mathbf{e}^{+}_{XY},\mathbf{e}^{-}_{XY}\)). Show that the messages passed by Algorithm 12, FE, across edges \(X\to Y\) have the following meaning:
\begin{equation*} M_{XY}=\Pr(X,\mathbf{e}^{+}_{XY}) \qquad\text{and}\qquad M_{YX}=\Pr(\mathbf{e}^{-}_{XY}\mid X). \end{equation*}
Moreover, show that \(M_{XY}M_{YX}=\Pr(X,\mathbf{e})\).
Write \(T_X\ni X\) and \(T_Y\ni Y\) for the two sides of the edge \(X\!-\!Y\), and \(\phi_Z=\Theta_{Z|\mathbf{U}_Z}\lambda_Z\) for the node factors, so that \(\mathbf{e}^{+}_{XY}\) is the part of \(\mathbf{e}\) on \(T_X\) and \(\mathbf{e}^{-}_{XY}\) the part on \(T_Y\). By Exercise 7.13,
\begin{equation*} S_{XY}=\{X\},\qquad \mathrm{vars}(X,Y)=T_X,\qquad \mathrm{vars}(Y,X)=T_Y\cup\{X\}, \end{equation*}
and by Exercise 7.6, \(M_{ij}=\mathrm{project}(\phi_{ij},S_{ij})\) with \(\phi_{ij}=\prod_{Z\in T_i}\phi_Z\). Hence
\begin{equation*} M_{XY}\;=\;\sum_{T_X\setminus\{X\}}\;\prod_{Z\in T_X}\Theta_{Z|\mathbf{U}_Z}\lambda_Z , \end{equation*}
a factor over \(X\). Exercise 7.13 also shows every parent of a node of \(T_X\) lies in \(T_X\), so \(T_X\) is ancestrally closed and
\begin{equation*} \prod_{Z\in T_X}\Theta_{Z|\mathbf{U}_Z}\;=\;\Pr(T_X) : \end{equation*}
sum the chain-rule product \(\prod_{Z}\Theta_{Z|\mathbf{U}_Z}=\Pr\) (Equation 4.2) over the complement in reverse topological order, where each variable summed has no child left in the product, so occurs only in its own CPT, which sums to \(1\). The remaining factor \(\prod_{Z\in T_X}\lambda_Z\) is the indicator of \(\mathbf{e}^{+}_{XY}\), so for each value \(x\) of \(X\),
\begin{equation*} M_{XY}(x)\;=\;\sum_{\substack{\mathbf{t}\sim x\\ \mathbf{t}\sim\mathbf{e}^{+}_{XY}}}\Pr(\mathbf{t}) \;=\;\Pr(x,\mathbf{e}^{+}_{XY}), \end{equation*}
the sum ranging over instantiations \(\mathbf{t}\) of \(T_X\). That is, \(M_{XY}=\Pr(X,\mathbf{e}^{+}_{XY})\).
Backward, Exercise 7.6 with \(i=Y\) gives \(M_{YX}=\sum_{T_Y}\prod_{Z\in T_Y}\Theta_{Z|\mathbf{U}_Z}\lambda_Z\), again a factor over \(X\). Every parent of a node of \(T_Y\) lies in \(T_Y\cup\{X\}\), so \(\prod_{Z\in T_Y}\Theta_{Z|\mathbf{U}_Z}\) is a function of \(T_Y\cup\{X\}\) alone, and multiplying it by \(\Pr(T_X)\) recovers the full chain-rule product:
\begin{equation*} \Pr(T_X,T_Y)\;=\;\Pr(T_X)\prod_{Z\in T_Y}\Theta_{Z|\mathbf{U}_Z}. \end{equation*}
So wherever \(\Pr(\mathbf{t}_X)>0\) that product equals \(\Pr(\mathbf{t}_Y\mid \mathbf{t}_X)\), and as it depends on \(\mathbf{t}_X\) only through \(x\), the common value is \(\Pr(\mathbf{t}_Y\mid x)\) for every \(x\) with \(\Pr(x)>0\). (Where \(\Pr(x)=0\) the conditional is undefined and the product stands in for it; nothing is affected, since then \(M_{XY}(x)=\Pr(x,\mathbf{e}^{+}_{XY})=0=\Pr(x,\mathbf{e})\).) Consequently
\begin{equation*} M_{YX}(x)\;=\;\sum_{\mathbf{t}_Y\sim\mathbf{e}^{-}_{XY}}\Pr(\mathbf{t}_Y\mid x) \;=\;\Pr(\mathbf{e}^{-}_{XY}\mid x), \end{equation*}
i.e. \(M_{YX}=\Pr(\mathbf{e}^{-}_{XY}\mid X)\).
Finally, that same factorisation, with \(\mathbf{e}^{+}_{XY}\) constraining only \(T_X\) and \(\mathbf{e}^{-}_{XY}\) only \(T_Y\), gives for each \(x\)
\begin{equation*} \begin{aligned} \Pr(x,\mathbf{e}) &=\sum_{\substack{\mathbf{t}_X\sim x,\;\mathbf{t}_X\sim\mathbf{e}^{+}_{XY}\\ \mathbf{t}_Y\sim\mathbf{e}^{-}_{XY}}}\Pr(\mathbf{t}_X)\Pr(\mathbf{t}_Y\mid x)\\ &=\Bigl(\sum_{\mathbf{t}_X\sim x,\,\mathbf{e}^{+}_{XY}}\Pr(\mathbf{t}_X)\Bigr) \Bigl(\sum_{\mathbf{t}_Y\sim\mathbf{e}^{-}_{XY}}\Pr(\mathbf{t}_Y\mid x)\Bigr)\\ &=\Pr(x,\mathbf{e}^{+}_{XY})\,\Pr(\mathbf{e}^{-}_{XY}\mid x)\\ &=M_{XY}(x)\,M_{YX}(x). \end{aligned} \end{equation*}
Hence \(M_{XY}M_{YX}=\Pr(X,\mathbf{e})\), which is also the second half of Exercise 7.6 at the separator \(S_{XY}=\{X\}\).
Exercises 7.15–7.15
Definition 7.7 showed how we can divide two factors \(f_1\) and \(f_2\) when each is over the same set of variables \(\mathbf{X}\): the quotient \(f_1/f_2\) is the factor over \(\mathbf{X}\) given by \(f(\mathbf{x}) = f_1(\mathbf{x})/f_2(\mathbf{x})\) if \(f_2(\mathbf{x}) \neq 0\), and \(f(\mathbf{x}) = 0\) otherwise. Let us define division more generally while assuming that factor \(f_2\) is over variables \(\mathbf{Y} \subseteq \mathbf{X}\). The result is a factor \(f\) over variables \(\mathbf{X}\) defined as follows:
\begin{equation*} f(\mathbf{x}) \;\overset{\text{def}}{=}\; \begin{cases} f_1(\mathbf{x})/f_2(\mathbf{y}) & \text{if } f_2(\mathbf{y}) \neq 0, \text{ for } \mathbf{y} \sim \mathbf{x}\\ 0 & \text{otherwise.} \end{cases} \end{equation*}
Show that
\begin{equation*} \sum_{\mathbf{X} \setminus \mathbf{Y}} f_1/f_2 \;=\; \left( \sum_{\mathbf{X} \setminus \mathbf{Y}} f_1 \right) \Big/ f_2 . \end{equation*}
Use this fact to provide a different definition for the messages passed by the Hugin architecture. Recall that Hugin propagation maintains over each separator \(S_{ij}\) a single factor \(\Phi_{ij}\), each entry of which is initialized to \(1\), and over each cluster \(\mathbf{C}_i\) a factor \(\Phi_i\), initialized to \(\Psi_i \prod_j \Phi_{ij}\) where \(\Psi_i\) is the product of the factors (including evidence indicators) assigned to node \(i\) and \(j\) ranges over the neighbors of \(i\). When node \(i\) is ready to send a message to neighbor \(j\) it saves \(\Phi_{ij}\) into \(\Phi_{ij}^{old}\), computes the new separator factor \(\Phi_{ij} \leftarrow \sum_{\mathbf{C}_i \setminus S_{ij}} \Phi_i\), computes the message \(M_{ij} = \Phi_{ij}/\Phi_{ij}^{old}\), and multiplies it into the receiving cluster, \(\Phi_j \leftarrow \Phi_j M_{ij}\).
Part 1. Both sides are factors over \(\mathbf{Y}\) — on the left, \(f_1/f_2\) is over \(\mathbf{X}\) by the generalized definition and \(\mathbf{Z} = \mathbf{X}\setminus\mathbf{Y}\) is summed out; on the right, \(\sum_{\mathbf{Z}} f_1\) and \(f_2\) are both over \(\mathbf{Y}\), so their quotient is the ordinary one of Definition 7.7. Fix an instantiation \(\mathbf{y}\). The instantiations summed on the left are exactly the \(\mathbf{x} = \mathbf{y}\mathbf{z}\), all with the same compatible \(\mathbf{y}\), so both the divisor \(f_2(\mathbf{y})\) and the applicable case of the definition are constant across the sum.
(i) \(f_2(\mathbf{y}) \neq 0\). The first case applies at every \(\mathbf{y}\mathbf{z}\), so
\begin{equation*} \begin{aligned} \left( \sum_{\mathbf{Z}} f_1/f_2 \right)(\mathbf{y}) &= \sum_{\mathbf{z}} (f_1/f_2)(\mathbf{y}\mathbf{z}) = \sum_{\mathbf{z}} \frac{f_1(\mathbf{y}\mathbf{z})}{f_2(\mathbf{y})}\\ &= \frac{1}{f_2(\mathbf{y})} \sum_{\mathbf{z}} f_1(\mathbf{y}\mathbf{z}) = \frac{\left( \sum_{\mathbf{Z}} f_1 \right)(\mathbf{y})}{f_2(\mathbf{y})} . \end{aligned} \end{equation*}
the pull-out being legitimate exactly because \(f_2\) mentions no variable of \(\mathbf{Z}\); and since \(f_2(\mathbf{y}) \neq 0\) this is the value of \(( \sum_{\mathbf{Z}} f_1 )/f_2\) at \(\mathbf{y}\) under Definition 7.7.
(ii) \(f_2(\mathbf{y}) = 0\). The second case applies at every \(\mathbf{y}\mathbf{z}\), so
\begin{equation*} \left( \sum_{\mathbf{Z}} f_1/f_2 \right)(\mathbf{y}) = \sum_{\mathbf{z}} 0 = 0 . \end{equation*}
On the other side, the divisor \(f_2\) vanishes at \(\mathbf{y}\), so Definition 7.7 gives \(\left( \left( \sum_{\mathbf{Z}} f_1 \right)/f_2 \right)(\mathbf{y}) = 0\) as well.
The two sides agree at every \(\mathbf{y}\), hence
\begin{equation*} \sum_{\mathbf{X} \setminus \mathbf{Y}} f_1/f_2 = \left( \sum_{\mathbf{X} \setminus \mathbf{Y}} f_1 \right) \Big/ f_2 , \end{equation*}
Part 2. At the moment node \(i\) is ready to send to \(j\), the identity applies with \(\mathbf{X} = \mathbf{C}_i\), \(\mathbf{Y} = S_{ij}\), \(f_1 = \Phi_i\) and \(f_2 = \Phi_{ij}^{old}\), since \(S_{ij} = \mathbf{C}_i \cap \mathbf{C}_j \subseteq \mathbf{C}_i\). Both \(\Phi_{ij}^{new} = \sum_{\mathbf{C}_i \setminus S_{ij}} \Phi_i\) and \(\Phi_{ij}^{old}\) are factors over \(S_{ij}\), so their quotient is the ordinary division of Definition 7.7 and
\begin{equation*} M_{ij} = \left( \sum_{\mathbf{C}_i \setminus S_{ij}} \Phi_i \right) \Big/ \Phi_{ij}^{old} = \sum_{\mathbf{C}_i \setminus S_{ij}} \Phi_i / \Phi_{ij}^{old}, \end{equation*}
the right-hand quotient being the generalized division of this exercise. Writing \(\Phi_{ij}\) for the separator factor before the update, the Hugin step at node \(i\) becomes
\begin{equation*} \begin{aligned} M_{ij} &= \sum_{\mathbf{C}_i \setminus S_{ij}} \frac{\Phi_i}{\Phi_{ij}},\\ \Phi_{ij} &\leftarrow \Phi_{ij} M_{ij},\\ \Phi_j &\leftarrow \Phi_j M_{ij}. \end{aligned} \end{equation*}
that is, divide first and marginalize afterwards in place of the book’s marginalize first and divide afterwards, with the separator now updated by multiplying the message in exactly as the receiving cluster is, so that the auxiliary copy \(\Phi_{ij}^{old}\) disappears.
It is the same algorithm, by the following invariant of the two-pass schedule. Put \(G_{ij} = \Psi_i \prod_{k \neq j} M_{ki}\). Then \(\Phi_{ij}\) is the product of the messages \(j\) has so far sent to \(i\), and
\begin{equation*} \Phi_i = \Phi_{ij} \, G_{ij} . \end{equation*}
Indeed \(\Phi_i\) changes only by \(\Phi_i \leftarrow \Phi_i M_{ki}\) and \(\Phi_{ij}\) only when a message crosses \(i - j\); under the inward/outward schedule exactly one message crosses each edge in each direction and \(i\) has not yet sent to \(j\), so the only change so far is from \(j\)’s message to \(i\), if sent. On the inward pass \(j\) has not sent, so \(\Phi_{ij} = 1\) while \(i\) has heard from all \(k \neq j\), giving \(\Phi_i = G_{ij}\); on the outward pass \(j\) has sent, its message computed against \(\Phi_{ij} = 1\), so \(\Phi_{ij} = M_{ji}\) and \(\Phi_i = \Psi_i \prod_k M_{ki} = M_{ji} G_{ij}\).
Given the invariant the separator update is exact: at \(\mathbf{s}\) with \(\Phi_{ij}(\mathbf{s}) \neq 0\) the division and multiplication cancel, and at \(\Phi_{ij}(\mathbf{s}) = 0\) the left side is \(0\) while the right is \(\sum_{\mathbf{c}_i \sim \mathbf{s}} \Phi_{ij}(\mathbf{s}) G_{ij}(\mathbf{c}_i) = 0\). So \(\Phi_{ij} M_{ij} = \sum_{\mathbf{C}_i \setminus S_{ij}} \Phi_i\) identically, the reformulated step leaves the jointree exactly where the book’s step would, and the guarantees \(\Pr(\mathbf{C}_i, e) = \Phi_i\) and \(\Pr(S_{ij}, e) = \Phi_{ij}\) at the end of the outward pass are untouched.
Inference by Conditioning
Exercises 8.1–8.7
Consider the Bayesian network and corresponding dtree given in Figure 8.13.
The Bayesian network has seven variables \(A,B,C,D,E,F,G\) with edges
\begin{equation*} \begin{aligned} &A \to D,\quad B \to D,\quad B \to E,\quad C \to E,\\ &C \to F,\quad D \to F,\quad E \to G,\quad F \to G . \end{aligned} \end{equation*}
Hence \(A\), \(B\), and \(C\) are roots and the seven families (CPTs) are \(\{A\}\), \(\{B\}\), \(\{C\}\), \(\{A,B,D\}\), \(\{B,C,E\}\), \(\{C,D,F\}\), \(\{E,F,G\}\).
The dtree has thirteen nodes, numbered \(1\) through \(13\), with node \(1\) the root:
- node 1 has children 2 and 3
- node 2 has children 4 and 5
- node 3 is a leaf carrying the CPT of \(C\) (family \(C\))
- node 4 has children 6 and 7
- node 5 is a leaf carrying the CPT of \(G\) (family \(EFG\))
- node 6 is a leaf carrying the CPT of \(F\) (family \(CDF\))
- node 7 has children 8 and 9
- node 8 is a leaf carrying the CPT of \(E\) (family \(BCE\))
- node 9 has children 10 and 11
- node 10 is a leaf carrying the CPT of \(B\) (family \(B\))
- node 11 has children 12 and 13
- node 12 is a leaf carrying the CPT of \(D\) (family \(ABD\))
- node 13 is a leaf carrying the CPT of \(A\) (family \(A\))
(a) Find \(\mathrm{vars}(T)\), \(\mathrm{cutset}(T)\), \(\mathrm{acutset}(T)\), and \(\mathrm{context}(T)\) for each node \(T\) in the dtree.
(b) What is the dtree width?
Part (a) is the table below and the width in part (b) is \(3\).
Compute \(\mathrm{vars}\) bottom-up from the leaf CPTs by \(\mathrm{vars}(T) = \mathrm{vars}(T^l) \cup \mathrm{vars}(T^r)\):
\begin{equation*} \begin{aligned} \mathrm{vars}(13) &= \{A\}, & \mathrm{vars}(12) &= \{A,B,D\},\\ \mathrm{vars}(11) &= \{A,B,D\}, & \mathrm{vars}(10) &= \{B\},\\ \mathrm{vars}(9) &= \{A,B,D\}, & \mathrm{vars}(8) &= \{B,C,E\},\\ \mathrm{vars}(7) &= \{A,B,C,D,E\}, & \mathrm{vars}(6) &= \{C,D,F\},\\ \mathrm{vars}(5) &= \{E,F,G\}, & \mathrm{vars}(4) &= \{A,B,C,D,E,F\},\\ \mathrm{vars}(3) &= \{C\}, & \mathrm{vars}(2) &= \{A,\dots,G\},\\ \mathrm{vars}(1) &= \{A,\dots,G\}. & & \end{aligned} \end{equation*}
Then cutsets top-down by Definition 8.3, \(\mathrm{cutset}(T) = (\mathrm{vars}(T^l) \cap \mathrm{vars}(T^r)) \setminus \mathrm{acutset}(T)\), each node’s a-cutset being the union of its ancestors’ cutsets and empty at the root:
\begin{equation*} \begin{aligned} \mathrm{cutset}(1) &= ABCDEFG \cap C = \{C\},\\ \mathrm{cutset}(2) &= (ABCDEF \cap EFG) \setminus \{C\} = \{E,F\},\\ \mathrm{cutset}(4) &= (CDF \cap ABCDE) \setminus \{C,E,F\} = \{D\},\\ \mathrm{cutset}(7) &= (BCE \cap ABD) \setminus \{C,D,E,F\} = \{B\},\\ \mathrm{cutset}(9) &= (B \cap ABD) \setminus \{B,C,D,E,F\} = \emptyset,\\ \mathrm{cutset}(11) &= (ABD \cap A) \setminus \{B,C,D,E,F\} = \{A\}. \end{aligned} \end{equation*}
Contexts are \(\mathrm{vars}(T) \cap \mathrm{acutset}(T)\) (Definition 8.5), and clusters are \(\mathrm{vars}(T)\) at a leaf and \(\mathrm{cutset}(T) \cup \mathrm{context}(T)\) otherwise (Definition 8.6):
| \(T\) | \(\mathrm{vars}(T)\) | \(\mathrm{cutset}(T)\) | \(\mathrm{acutset}(T)\) | \(\mathrm{context}(T)\) | \(\mathrm{cluster}(T)\) |
|---|---|---|---|---|---|
| 1 | \(ABCDEFG\) | \(C\) | \(\emptyset\) | \(\emptyset\) | \(C\) |
| 2 | \(ABCDEFG\) | \(EF\) | \(C\) | \(C\) | \(CEF\) |
| 3 | \(C\) | – | \(C\) | \(C\) | \(C\) |
| 4 | \(ABCDEF\) | \(D\) | \(CEF\) | \(CEF\) | \(CDEF\) |
| 5 | \(EFG\) | – | \(CEF\) | \(EF\) | \(EFG\) |
| 6 | \(CDF\) | – | \(CDEF\) | \(CDF\) | \(CDF\) |
| 7 | \(ABCDE\) | \(B\) | \(CDEF\) | \(CDE\) | \(BCDE\) |
| 8 | \(BCE\) | – | \(BCDEF\) | \(BCE\) | \(BCE\) |
| 9 | \(ABD\) | \(\emptyset\) | \(BCDEF\) | \(BD\) | \(BD\) |
| 10 | \(B\) | – | \(BCDEF\) | \(B\) | \(B\) |
| 11 | \(ABD\) | \(A\) | \(BCDEF\) | \(BD\) | \(ABD\) |
| 12 | \(ABD\) | – | \(ABCDEF\) | \(ABD\) | \(ABD\) |
| 13 | \(A\) | – | \(ABCDEF\) | \(A\) | \(A\) |
A dash means the node is a leaf and so carries no cutset.
Part (b). The largest clusters are \(\mathrm{cluster}(4) = CDEF\) and \(\mathrm{cluster}(7) = BCDE\), of size \(4\), so the width is \(4 - 1 = 3\). This is optimal: eliminating \(A, G, B, C, D, E, F\) from the moral graph gives clusters \(ABD\), \(EFG\), \(BCDE\), \(CDEF\), \(DEF\), \(EF\), \(F\), so the treewidth is \(3\).
Consider the dtree in Figure 8.13 (the network has variables \(A,\dots,G\) with edges \(A \to D\), \(B \to D\), \(B \to E\), \(C \to E\), \(C \to F\), \(D \to F\), \(E \to G\), \(F \to G\); the thirteen-node dtree has root \(1\) with children \(2,3\); node \(2\) with children \(4,5\); node \(4\) with children \(6,7\); node \(7\) with children \(8,9\); node \(9\) with children \(10,11\); node \(11\) with children \(12,13\); and leaves \(3 = C\), \(5 = EFG\), \(6 = CDF\), \(8 = BCE\), \(10 = B\), \(12 = ABD\), \(13 = A\)). Assuming that all variables are binary:
(a) How many recursive calls will RC1 make when run on this dtree with no evidence?
(b) How many recursive calls will RC2 make when run on this dtree with no evidence?
(c) How many cache hits will occur at node \(9\) when RC2 is run with no evidence?
(d) Which of the dtree nodes have dead caches, if any?
All of these questions can be answered without tracing the recursive conditioning algorithm.
(a) \(309\) calls, (b) \(109\), (c) \(12\) hits, (d) the nonleaf nodes \(2\), \(4\), \(11\) (and the root). Throughout, the cutsets, a-cutsets, contexts and clusters are those of Exercise 8.1, and \(\mathbf{X}^{\#} = 2^{|\mathbf{X}|}\) counts instantiations.
Part (a). Lines 6–7 of RC1 loop over the instantiations of \(\mathrm{cutset}(T)\) compatible with the evidence, one call to each child per instantiation; with empty evidence none is excluded, so
\begin{equation*} \mathrm{calls}(T^l) = \mathrm{calls}(T^r) = \mathrm{calls}(T)\cdot \mathrm{cutset}(T)^{\#}, \end{equation*}
with \(\mathrm{calls}(\text{root}) = 1\), whose solution is \(\mathrm{calls}(T) = \mathrm{acutset}(T)^{\#}\) — the bound of Theorem 8.1, met with equality since the evidence is empty:
| node | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| a-cutset size | 0 | 1 | 1 | 3 | 3 | 4 | 4 | 5 | 5 | 5 | 5 | 6 | 6 |
| calls | 1 | 2 | 2 | 8 | 8 | 16 | 16 | 32 | 32 | 32 | 32 | 64 | 64 |
Summing,
\begin{equation*} \begin{aligned} 1 + 2\cdot 2 + 2\cdot 8 + 2\cdot 16 + 4\cdot 32 + 2\cdot 64 &= 1 + 4 + 16 + 32 + 128 + 128\\ &= 309 . \end{aligned} \end{equation*}
that is, \(308\) recursive calls beyond the top-level call on the root.
Part (b). RC2 caches at every nonleaf node, so \(T\) executes its loop once per instantiation of \(\mathrm{context}(T)\) and answers all later calls from the cache; with empty evidence every such instantiation is generated, so the loop runs \(\min(\mathrm{calls}(T), \mathrm{context}(T)^{\#})\) times and each child of \(T\) receives
\begin{equation*} \mathrm{cutset}(T)^{\#}\,\mathrm{context}(T)^{\#} = \mathrm{cluster}(T)^{\#} \end{equation*}
calls, the bound of Theorem 8.3 attained everywhere. Reading the parents’ clusters off Exercise 8.1:
| node | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| calls | 1 | 2 | 2 | 8 | 8 | 16 | 16 | 16 | 16 | 4 | 4 | 8 | 8 |
summing to
\begin{equation*} 1 + 2(2 + 8 + 16 + 16 + 4 + 8) = 1 + 2\cdot 54 = 109 , \end{equation*}
against \(309\) for RC1.
Part (c). Node \(9\) receives \(16\) calls, and \(\mathrm{context}(9) = \{B,D\}\) has \(4\) instantiations, all occurring under empty evidence. The first call carrying a given instantiation misses and fills that entry, so there are \(4\) misses and
\begin{equation*} 16 - 4 = 12 \end{equation*}
cache hits at node \(9\).
Part (d). By Equation 8.4 the cache at \(T\) is dead when \(\mathrm{context}(T) = \mathrm{cluster}(T^p)\), since then the \(\mathrm{cluster}(T^p)^{\#}\) calls \(T\) receives all carry distinct instantiations of \(\mathrm{context}(T)\) and no entry is looked up after being filled. Checking each nonroot node against its parent’s cluster:
| \(T\) | \(\mathrm{context}(T)\) | \(\mathrm{cluster}(T^p)\) | dead? |
|---|---|---|---|
| 2 | \(C\) | \(C\) | yes |
| 3 | \(C\) | \(C\) | yes (leaf) |
| 4 | \(CEF\) | \(CEF\) | yes |
| 5 | \(EF\) | \(CEF\) | no |
| 6 | \(CDF\) | \(CDEF\) | no |
| 7 | \(CDE\) | \(CDEF\) | no |
| 8 | \(BCE\) | \(BCDE\) | no |
| 9 | \(BD\) | \(BCDE\) | no |
| 10 | \(B\) | \(BD\) | no |
| 11 | \(BD\) | \(BD\) | yes |
| 12 | \(ABD\) | \(ABD\) | yes (leaf) |
| 13 | \(A\) | \(ABD\) | no |
RC2 does not cache at leaves (they are answered by LOOKUP, a tabular CPT serving as its own cache), so the dead caches are those of the nonleaf nodes \(2\), \(4\), \(11\), together with the root, which is called exactly once and so never retrieves its single entry.
Figure 8.13 depicts a Bayesian network and a corresponding dtree with height \(6\). The network has variables \(A,\dots,G\) with edges
\begin{equation*} \begin{aligned} &A \to D,\quad B \to D,\quad B \to E,\quad C \to E,\\ &C \to F,\quad D \to F,\quad E \to G,\quad F \to G, \end{aligned} \end{equation*}
so its seven CPTs have families \(\{A\}\), \(\{B\}\), \(\{C\}\), \(\{A,B,D\}\), \(\{B,C,E\}\), \(\{C,D,F\}\), \(\{E,F,G\}\). The dtree of Figure 8.13 is the right-deep tree with root \(1\) (children \(2,3\)), node \(2\) (children \(4,5\)), node \(4\) (children \(6,7\)), node \(7\) (children \(8,9\)), node \(9\) (children \(10,11\)), node \(11\) (children \(12,13\)), and leaves \(3 = C\), \(5 = EFG\), \(6 = CDF\), \(8 = BCE\), \(10 = B\), \(12 = ABD\), \(13 = A\); its width is \(3\) (Exercise 8.1).
Find a dtree for this network whose height is \(3\) and whose width is no worse than the width of the original dtree.
Take the dtree with root \(R\) and internal nodes \(L\), \(M\), \(L_1\), \(L_2\), \(M_1\):
- \(R\) has children \(L\) and \(M\)
- \(L\) has children \(L_1\) and \(L_2\)
- \(L_1\) has children the leaves \(A\) and \(ABD\)
- \(L_2\) has children the leaves \(B\) and \(BCE\)
- \(M\) has children the leaf \(EFG\) and the node \(M_1\)
- \(M_1\) has children the leaves \(C\) and \(CDF\)
Every node has \(0\) or \(2\) children and the seven leaves are exactly the seven CPTs, so this is a dtree (Definition 8.2); the leaf \(EFG\) sits at depth \(2\) and the other six at depth \(3\), so the height is \(3\), and the computation below gives width \(3\).
The variable sets are
\begin{equation*} \begin{aligned} \mathrm{vars}(L_1) &= \{A,B,D\}, & \mathrm{vars}(L_2) &= \{B,C,E\},\\ \mathrm{vars}(L) &= \{A,B,C,D,E\}, & \mathrm{vars}(M_1) &= \{C,D,F\},\\ \mathrm{vars}(M) &= \{C,D,E,F,G\}, & \mathrm{vars}( R) &= \{A,\dots,G\}. \end{aligned} \end{equation*}
At the root, \(\mathrm{acutset}( R) = \emptyset\) and
\begin{equation*} \mathrm{cutset}( R) = \mathrm{vars}(L) \cap \mathrm{vars}(M) = \{A,B,C,D,E\} \cap \{C,D,E,F,G\} = \{C,D,E\}, \end{equation*}
so \(\mathrm{cluster}( R) = CDE\) and \(\mathrm{acutset}(L) = \mathrm{acutset}(M) = \{C,D,E\}\). Then
\begin{equation*} \begin{aligned} \mathrm{cutset}(L) &= \bigl(\{A,B,D\} \cap \{B,C,E\}\bigr) \setminus \{C,D,E\} = \{B\},\\ \mathrm{context}(L) &= \{A,B,C,D,E\} \cap \{C,D,E\} = \{C,D,E\}, \end{aligned} \end{equation*}
giving \(\mathrm{cluster}(L) = \{B,C,D,E\}\), and
\begin{equation*} \begin{aligned} \mathrm{cutset}(M) &= \bigl(\{E,F,G\} \cap \{C,D,F\}\bigr) \setminus \{C,D,E\} = \{F\},\\ \mathrm{context}(M) &= \{C,D,E,F,G\} \cap \{C,D,E\} = \{C,D,E\}, \end{aligned} \end{equation*}
giving \(\mathrm{cluster}(M) = \{C,D,E,F\}\). Descending once more, \(\mathrm{acutset}(L_1) = \mathrm{acutset}(L_2) = \{B,C,D,E\}\) and \(\mathrm{acutset}(M_1) = \{C,D,E,F\}\), so
\begin{equation*} \begin{aligned} \mathrm{cutset}(L_1) &= \bigl(\{A\} \cap \{A,B,D\}\bigr) \setminus \{B,C,D,E\} = \{A\},\\ \mathrm{context}(L_1) &= \{A,B,D\} \cap \{B,C,D,E\} = \{B,D\},\\ \mathrm{cutset}(L_2) &= \bigl(\{B\} \cap \{B,C,E\}\bigr) \setminus \{B,C,D,E\} = \emptyset,\\ \mathrm{context}(L_2) &= \{B,C,E\} \cap \{B,C,D,E\} = \{B,C,E\},\\ \mathrm{cutset}(M_1) &= \bigl(\{C\} \cap \{C,D,F\}\bigr) \setminus \{C,D,E,F\} = \emptyset,\\ \mathrm{context}(M_1) &= \{C,D,F\} \cap \{C,D,E,F\} = \{C,D,F\}. \end{aligned} \end{equation*}
In full:
| \(T\) | \(\mathrm{cutset}(T)\) | \(\mathrm{acutset}(T)\) | \(\mathrm{context}(T)\) | \(\mathrm{cluster}(T)\) | size |
|---|---|---|---|---|---|
| \(R\) | \(CDE\) | \(\emptyset\) | \(\emptyset\) | \(CDE\) | 3 |
| \(L\) | \(B\) | \(CDE\) | \(CDE\) | \(BCDE\) | 4 |
| \(M\) | \(F\) | \(CDE\) | \(CDE\) | \(CDEF\) | 4 |
| \(L_1\) | \(A\) | \(BCDE\) | \(BD\) | \(ABD\) | 3 |
| \(L_2\) | \(\emptyset\) | \(BCDE\) | \(BCE\) | \(BCE\) | 3 |
| \(M_1\) | \(\emptyset\) | \(CDEF\) | \(CDF\) | \(CDF\) | 3 |
| leaf \(EFG\) | – | \(CDEF\) | \(EF\) | \(EFG\) | 3 |
| leaf \(A\) | – | \(ABCDE\) | \(A\) | \(A\) | 1 |
| leaf \(ABD\) | – | \(ABCDE\) | \(ABD\) | \(ABD\) | 3 |
| leaf \(B\) | – | \(BCDE\) | \(B\) | \(B\) | 1 |
| leaf \(BCE\) | – | \(BCDE\) | \(BCE\) | \(BCE\) | 3 |
| leaf \(C\) | – | \(CDEF\) | \(C\) | \(C\) | 1 |
| leaf \(CDF\) | – | \(CDEF\) | \(CDF\) | \(CDF\) | 3 |
The largest clusters are \(\mathrm{cluster}(L) = BCDE\) and \(\mathrm{cluster}(M) = CDEF\), of size \(4\), so by Definition 8.6 the width is \(4 - 1 = 3\): no worse than the original, and optimal, the treewidth being \(3\) (Exercise 8.1).
Show a class of networks on which the time complexity of Algorithm RC1 is worse than the time complexity of cutset conditioning. Show also a class of networks on which the time complexity of cutset conditioning is worse than RC1.
RC1 is worse on polytrees; cutset conditioning is worse on chains of diamonds.
The two complexities: with \(n\) nodes, a loop-cutset of size \(s\) (Definition 8.1) and at most \(k\) parents per node, cutset conditioning makes \(O(\exp(s))\) calls to the polytree algorithm at \(O(n\exp(k))\) each, hence \(O(n \exp(k+s))\) time; while RC1 on a balanced dtree of cutset width \(w\) takes \(O(n \exp(w \log n)) = n^{O(w)}\) by Theorem 8.2. Neither dominates: either of \(s\), \(w\) can be small while the other is large.
Class 1: RC1 worse. Take the chain
\begin{equation*} X_1 \to X_2 \to \cdots \to X_n , \end{equation*}
a polytree, so \(s = 0\), with \(k = 1\); cutset conditioning is then a single run of the polytree algorithm, \(\Theta(n)\) time.
RC1 costs \(\Theta(n^2)\). The \(n\) CPTs are \(\{X_1\}\) and \(\{X_{i-1},X_i\}\), and the balanced dtree of Figure 8.7 (right) splits each subchain at a midpoint variable, so every internal cutset is a single variable; a node at depth \(d\) then has \(|\mathrm{acutset}| = d\) and receives \(2^d\) calls (Theorem 8.1), and there are \(2^d\) such nodes. With depth \(\log_2 n\),
\begin{equation*} \sum_{d=0}^{\log_2 n} 2^d \cdot 2^d = \sum_{d=0}^{\log_2 n} 4^d = \Theta(4^{\log_2 n}) = \Theta(n^2). \end{equation*}
No dtree does better. For any dtree over the chain whose internal cutsets all have size \(1\), a leaf at depth \(d_i\) takes \(2^{d_i}\) calls while the Kraft equality \(\sum_i 2^{-d_i} = 1\) holds over the \(n\) leaves, so Cauchy–Schwarz gives
\begin{equation*} \Bigl(\sum_i 2^{d_i}\Bigr)\Bigl(\sum_i 2^{-d_i}\Bigr) \ \ge\ \Bigl(\sum_i 1\Bigr)^2 = n^2 , \end{equation*}
so at least \(n^2\) calls go to leaves alone; and unbalancing buys an occasional empty cutset only by deepening other leaves — in the extreme the right-deep dtree of Figure 8.7 (left) has a-cutset width \(n-1\) and \(\Theta(2^n)\) calls. So on chains RC1 is asymptotically the worse algorithm, because it caches nothing and re-solves each subnetwork once per instantiation of its a-cutset.
Class 2: cutset conditioning worse. Take the networks of Figure 8.4: a chain of \(n\) diamonds on middle variables \(M_0,\dots,M_n\), top variables \(T_1,\dots,T_n\) and bottom variables \(B_1,\dots,B_n\), with edges
\begin{equation*} M_{i-1} \to T_i,\quad T_i \to M_i,\quad M_{i-1} \to B_i,\quad B_i \to M_i \qquad (i = 1,\dots,n), \end{equation*}
so that consecutive diamonds share a middle variable. There are \(3n+1\) nodes and \(k = 2\), only the \(M_i\) with \(i \ge 1\) having two parents.
The \(i\)-th diamond is the edge-disjoint undirected cycle \(M_{i-1}, T_i, M_i, B_i\), and by Definition 8.1 a loop-cutset must break each by deleting outgoing edges. On cycle \(i\) the outgoing edges belong to \(M_{i-1}\), \(T_i\), \(B_i\) (the node \(M_i\) has none), so the cutset contains one of these three for every \(i\); and each of them has all its outgoing edges on cycle \(i\) alone, so no node serves two cycles. Hence \(s \ge n\), and with binary variables cutset conditioning considers at least \(2^n\) cases: \(\Omega(2^n)\) time.
RC1 is polynomial here. Moralizing adds only the edges \(T_i - B_i\), the \(M_i\) being the sole nodes with two parents, and eliminating in the order \(M_0, T_1, B_1, M_1, T_2, \dots\) creates no fill-in: \(M_{i-1}\) leaves \(T_i, B_i\), adjacent through the moral edge, cluster \(\{M_{i-1},T_i,B_i\}\); \(T_i\) leaves \(B_i, M_i\), adjacent through \(B_i \to M_i\), cluster \(\{T_i,B_i,M_i\}\); \(B_i\) leaves only \(M_i\). Every cluster has size \(3\), so the treewidth is \(2\) whatever \(n\), and the construction of Chapter 9 yields a balanced dtree of cutset width \(w \le 3\), for which Theorem 8.2 bounds RC1 by
\begin{equation*} O\bigl(n \exp(w \log n)\bigr) = n^{O(1)} . \end{equation*}
Show that for networks whose loop-cutset is bounded, Algorithm RC2 will have time and space complexity that are linear in the network size if RC2 is run on a carefully chosen dtree.
Take a dtree \(T^{\prime}\) of small width for the polytree and transplant its shape, relabelling the leaves with the true families; the result has width at most \(k+s\), and Theorem 8.4 — RC2 on a width-\(w\) dtree costs \(O(n\exp(w))\) time and space — then gives the claim.
Write \(F_X = \{X\} \cup \mathbf{U}_X\) for the family of \(X\) in \(\mathcal{N}\), \(\mathbf{C}\) for a loop-cutset (Definition 8.1) of size \(s\), \(k\) for the maximum number of parents, and \(\mathcal{N}_{\mathbf{C}}\) for the polytree obtained by deleting the edges out of \(\mathbf{C}\), in which \(X\) has family \(F^{\prime}_X = \{X\} \cup (\mathbf{U}_X \setminus \mathbf{C})\), so that
\begin{equation*} F_X \setminus \mathbf{C} \;=\; F^{\prime}_X \setminus \mathbf{C} , \qquad F^{\prime}_X \subseteq F_X , \qquad F_X \subseteq F^{\prime}_X \cup \mathbf{C} . \end{equation*}
Step 1. \(\mathcal{N}_{\mathbf{C}}\) has an elimination order of width \(k^{\prime} := \max_X |F^{\prime}_X| - 1 \le k\): moralize and repeatedly eliminate a leaf \(X\) of the underlying undirected tree, whose neighbours are either its parents \(\mathbf{U}^{\prime}_X\), made pairwise adjacent by moralization, or (if \(X\) is parentless with one child \(Y\)) the uneliminated part of \(F^{\prime}_Y \setminus \{X\}\), again a clique; either way no fill-in and a cluster inside a family. By the polytime construction of Chapter 9 there is then a dtree \(T^{\prime}\) for \(\mathcal{N}_{\mathbf{C}}\) of width \(\le k^{\prime}\), its leaves labelled \(F^{\prime}_X\).
Step 2. Let \(T\) have the same shape as \(T^{\prime}\) with the leaf of \(X\) relabelled by the true family \(F_X\). This is the carefully chosen dtree: a full binary tree whose leaves correspond one-to-one with the CPTs of \(\mathcal{N}\) (Definition 8.2).
Step 3. Fix a tree shape and two labellings of its leaves, by sets \(L_i\) and by \(L_i \setminus \mathbf{C}\), writing \(\mathrm{vars}^-\) and so on for the second. Since \(\mathrm{vars}(T)\) is the union of the leaf labels below \(T\), \(\mathrm{vars}^-(T) = \mathrm{vars}(T) \setminus \mathbf{C}\) at every node, and we claim
\begin{equation*} \mathrm{cutset}^-(T) = \mathrm{cutset}(T)\setminus \mathbf{C}, \qquad \mathrm{acutset}^-(T) = \mathrm{acutset}(T)\setminus \mathbf{C}. \end{equation*}
by induction on depth: both a-cutsets are empty at the root, and given \(\mathrm{acutset}^-(T) = \mathrm{acutset}(T)\setminus \mathbf{C}\), Definition 8.3 gives
\begin{equation*} \begin{aligned} \mathrm{cutset}^-(T) &= \bigl(\mathrm{vars}^-(T^l) \cap \mathrm{vars}^-(T^r)\bigr) \setminus \mathrm{acutset}^-(T)\\ &= \Bigl(\bigl(\mathrm{vars}(T^l) \cap \mathrm{vars}(T^r)\bigr)\setminus \mathbf{C}\Bigr) \setminus \bigl(\mathrm{acutset}(T)\setminus \mathbf{C}\bigr)\\ &= \bigl(\mathrm{vars}(T^l) \cap \mathrm{vars}(T^r)\bigr) \setminus \bigl(\mathbf{C} \cup \mathrm{acutset}(T)\bigr)\\ &= \mathrm{cutset}(T)\setminus \mathbf{C}, \end{aligned} \end{equation*}
the third equality because removing \(\mathbf{C}\) and then \(\mathrm{acutset}(T)\setminus\mathbf{C}\) removes exactly \(\mathbf{C} \cup \mathrm{acutset}(T)\); a child’s a-cutset being its parent’s a-cutset together with its cutset, the induction goes through. Consequently
\begin{equation*} \mathrm{context}^-(T) = \mathrm{vars}^-(T)\cap \mathrm{acutset}^-(T) = \mathrm{context}(T)\setminus \mathbf{C}, \end{equation*}
and therefore \(\mathrm{cluster}^-(T) = \mathrm{cluster}(T)\setminus \mathbf{C}\) at every node by Definition 8.6, leaves included.
Reduce both \(T\) and \(T^{\prime}\) by \(\mathbf{C}\). Their shapes agree and their reduced leaf labels agree, \(F_X \setminus \mathbf{C} = F^{\prime}_X \setminus \mathbf{C}\), so the two reductions are the same labelled tree and
\begin{equation*} \mathrm{cluster}_T(T) \setminus \mathbf{C} \;=\; \mathrm{cluster}_{T^{\prime}}(T)\setminus \mathbf{C} \;\subseteq\; \mathrm{cluster}_{T^{\prime}}(T), \end{equation*}
and so
\begin{equation*} |\mathrm{cluster}_T(T)| \le |\mathrm{cluster}_{T^{\prime}}(T)| + |\mathbf{C}| \le (k^{\prime}+1) + s . \end{equation*}
The width of \(T\) is therefore at most \(k^{\prime} + s \le k + s\).
Step 4. By Theorem 8.4, RC2 on \(T\) takes
\begin{equation*} O\bigl(n\exp(k+s)\bigr) = O\bigl(\exp(s)\cdot n\exp(k)\bigr) \end{equation*}
in both time and space. With the loop-cutset bounded, \(s = O(1)\), this is \(O(n \exp(k))\) — the complexity of the polytree algorithm, and linear in the size of the network, since a network with \(n\) nodes and at most \(k\) parents each has \(O(n\exp(k))\) CPT parameters.
Show that if a network is pruned as given in Section 6.9 before applying RC1, then Line 6 of algorithm LOOKUP will never be reached. Recall that pruning a network can only be done under a given query.
For reference, LOOKUP\((T,\mathbf{e})\) is
- \(\Theta_{X|\mathbf{U}} \leftarrow\) CPT associated with dtree node \(T\)
- \(\mathbf{u} \leftarrow\) instantiation of \(\mathbf{U}\) compatible with evidence \(\mathbf{e}\)
- if \(X\) is instantiated to \(x\) in evidence \(\mathbf{e}\) then
- \(\quad\) return \(\theta_{x|\mathbf{u}}\)
- else
- \(\quad\) return \(1\) (that is, \(\sum_x \theta_{x|\mathbf{u}}\))
- end if
Suppose Line 6 is reached at a leaf dtree node \(T\) carrying \(\Theta_{X|\mathbf{U}}\); two facts force a contradiction. Since RC1 computes \(\Pr(\mathbf{e})\), the query variables are \(\mathbf{Q} = \emptyset\), and pruning under that query (Section 6.9) prunes the edges outgoing from the evidence nodes \(\mathbf{E}\) and repeatedly deletes leaf nodes outside \(\mathbf{Q}\cup\mathbf{E} = \mathbf{E}\), leaving a network \(\mathcal{N}^{\star}\) for which the dtree is built.
Fact 1: every leaf node of \(\mathcal{N}^{\star}\) is in \(\mathbf{E}\), node pruning having run until no such node remains.
Fact 2: the evidence RC1 passes to LOOKUP at \(T\) is \(\mathbf{e}\mathbf{c}\), with \(\mathbf{c}\) an instantiation of \(\mathrm{acutset}(T)\), since Line 7 extends the evidence by the current cutset instantiation at each call and the cutsets along the root-to-\(T\) path are exactly \(\mathrm{acutset}(T)\) (Definition 8.3). So Line 3 succeeds exactly when \(X \in \mathbf{E} \cup \mathrm{acutset}(T)\), and Line 6 is reached only if \(X \notin \mathbf{E}\) and \(X \notin \mathrm{acutset}(T)\).
The latter forces \(X\) into a single dtree leaf. Let \(\mathcal{S}\) be the leaves whose CPT mentions \(X\) and suppose \(|\mathcal{S}| \ge 2\), with deepest common ancestor \(T^{\star}\). Then \(T^{\star}\) is a nonleaf with a member of \(\mathcal{S}\) in each subtree, so \(X \in \mathrm{vars}(T^{\star l}) \cap \mathrm{vars}(T^{\star r})\); and for any proper ancestor \(A\) of \(T^{\star}\) all of \(\mathcal{S}\) lies in one of \(A\)’s subtrees, so \(X\) is missing from the other and \(X \notin \mathrm{cutset}(A)\), i.e. \(X \notin \mathrm{acutset}(T^{\star})\). Definition 8.3 then gives \(X \in \mathrm{cutset}(T^{\star}) \subseteq \mathrm{acutset}(T)\), against Fact 2. Hence \(|\mathcal{S}| = 1\).
But \(X\) occurs in its own CPT and in that of each of its children in \(\mathcal{N}^{\star}\), so \(|\mathcal{S}| = 1\) makes \(X\) a leaf node of \(\mathcal{N}^{\star}\) and thus \(X \in \mathbf{E}\) by Fact 1, contradicting \(X \notin \mathbf{E}\). So Line 6 is never reached.
Consider the Bayesian network and dtree shown in Figure 8.14. The network has four variables with edges
\begin{equation*} A \to C,\quad B \to C,\quad B \to D,\quad C \to D, \end{equation*}
so its four families (CPTs) are \(\{A\}\), \(\{B\}\), \(\{A,B,C\}\), \(\{B,C,D\}\). The dtree has seven nodes:
- the root \(R\) has children \(N_2\) and the leaf \(BCD\)
- \(N_2\) has children \(N_3\) and the leaf \(B\)
- \(N_3\) has children the leaf \(A\) and the leaf \(ABC\)
Create a dgraph for this network by orienting the given dtree with respect to each of its leaf nodes, that is, by running Algorithm DT2DG.
Stage 1. Line 2 of DT2DG drops the edge directions, removes the dtree root and joins its neighbors. The dtree edges are
\begin{equation*} R - N_2,\quad R - BCD,\quad N_2 - N_3,\quad N_2 - B,\quad N_3 - A,\quad N_3 - ABC . \end{equation*}
so deleting \(R\) and joining \(N_2\) to \(BCD\) leaves \(\mathit{Tree}\) with edges
\begin{equation*} N_2 - BCD,\quad N_2 - N_3,\quad N_2 - B,\quad N_3 - A,\quad N_3 - ABC . \end{equation*}
Writing \(c_1 = N_2\) and \(c_2 = N_3\), this tree has four leaves \(A\), \(ABC\), \(B\), \(BCD\) and two internal nodes of degree three:
\begin{equation*} c_1 \text{ adjacent to } \{BCD,\ B,\ c_2\}, \qquad c_2 \text{ adjacent to } \{A,\ ABC,\ c_1\} . \end{equation*}
Stage 2. For a leaf \(P\) with neighbor \(C\), DT2DG creates a root with children \(P\) and \(\mathrm{ORIENT}(C,P)\), where \(\mathrm{ORIENT}(C,P)\) returns \(C\) if \(C\) is a leaf and otherwise a node with children \(\mathrm{ORIENT}(N_1,C)\), \(\mathrm{ORIENT}(N_2,C)\) for the two neighbors \(N_1,N_2 \ne P\) of \(C\); results are cached under \((C,P)\).
Toward \(A\): here \(C = c_2\), with other neighbors \(ABC\) and \(c_1\), and the neighbors of \(c_1\) other than \(c_2\) are the leaves \(BCD\), \(B\), so
\begin{equation*} R_A = (\,A,\ X_1\,),\qquad X_1 = (\,ABC,\ X_2\,),\qquad X_2 = (\,BCD,\ B\,). \end{equation*}
Toward \(ABC\): again \(C = c_2\), now with other neighbors \(A\) and \(c_1\), and \(\mathrm{ORIENT}(c_1,c_2)\) hits the cache, returning \(X_2\):
\begin{equation*} R_{ABC} = (\,ABC,\ X_3\,),\qquad X_3 = (\,A,\ X_2\,). \end{equation*}
Toward \(B\): here \(C = c_1\), with other neighbors \(BCD\) and \(c_2\), whose remaining neighbors are the leaves \(A\), \(ABC\), so \(\mathrm{ORIENT}(c_2,c_1) = X_5\):
\begin{equation*} R_B = (\,B,\ X_4\,),\qquad X_4 = (\,BCD,\ X_5\,),\qquad X_5 = (\,A,\ ABC\,). \end{equation*}
Toward \(BCD\): here \(C = c_1\), with other neighbors \(B\) and \(c_2\), and \(\mathrm{ORIENT}(c_2,c_1)\) hits the cache, returning \(X_5\):
\begin{equation*} R_{BCD} = (\,BCD,\ X_6\,),\qquad X_6 = (\,B,\ X_5\,). \end{equation*}
The dgraph therefore has four roots \(R_A, R_{ABC}, R_B, R_{BCD}\), six internal nodes \(X_1,\dots,X_6\), and the four shared leaves \(A\), \(ABC\), \(B\), \(BCD\):
| node | children |
|---|---|
| \(R_A\) | \(A\), \(X_1\) |
| \(R_{ABC}\) | \(ABC\), \(X_3\) |
| \(R_B\) | \(B\), \(X_4\) |
| \(R_{BCD}\) | \(BCD\), \(X_6\) |
| \(X_1\) | \(ABC\), \(X_2\) |
| \(X_2\) | \(BCD\), \(B\) |
| \(X_3\) | \(A\), \(X_2\) |
| \(X_4\) | \(BCD\), \(X_5\) |
| \(X_5\) | \(A\), \(ABC\) |
| \(X_6\) | \(B\), \(X_5\) |
The sharing is visible: \(X_2\) has parents \(X_1, X_3\) and \(X_5\) has parents \(X_4, X_6\), while each leaf has three parents. The counts match Theorem 8.6 for \(n = 7\): \((5n-7)/2 = 14\) nodes and \(4(n-2) = 20\) edges.
The root cutsets deliver the family marginals. Computing \(\mathrm{vars}\) bottom-up,
\begin{equation*} \begin{aligned} \mathrm{vars}(X_2) &= \{B,C,D\}, & \mathrm{vars}(X_5) &= \{A,B,C\},\\ \mathrm{vars}(X_1) &= \{A,B,C,D\}, & \mathrm{vars}(X_3) &= \{A,B,C,D\},\\ \mathrm{vars}(X_4) &= \{A,B,C,D\}, & \mathrm{vars}(X_6) &= \{A,B,C\}, \end{aligned} \end{equation*}
so, since each root has an empty a-cutset,
\begin{equation*} \begin{aligned} \mathrm{cutset}(R_A) &= \{A\} \cap \{A,B,C,D\} = \{A\},\\ \mathrm{cutset}(R_{ABC}) &= \{A,B,C\} \cap \{A,B,C,D\} = \{A,B,C\},\\ \mathrm{cutset}(R_B) &= \{B\} \cap \{A,B,C,D\} = \{B\},\\ \mathrm{cutset}(R_{BCD}) &= \{B,C,D\} \cap \{A,B,C\} = \{B,C\}. \end{aligned} \end{equation*}
Since \(A\), \(B\), \(C\) all have children, their roots carry the full families \(\{A\}\), \(\{B\}\), \(\{A,B,C\}\), and running RC there yields \(\Pr(A,\mathbf{e})\), \(\Pr(B,\mathbf{e})\), \(\Pr(A,B,C,\mathbf{e})\); \(D\) is a network leaf, so its root carries only \(\mathbf{U}_D = \{B,C\}\) and RC yields \(\Pr(B,C,\mathbf{e})\), whence \(\Pr(B,C,D,\mathbf{e}) = \Pr(B,C,\mathbf{e})\,\theta_{d|bc}\).
Exercises 8.8–8.14
Suppose that Algorithm DT2DG is passed a dtree with \(n\) nodes and height \(O(\log n)\). Will the generated dgraph also have height \(O(\log n)\)?
Recall the algorithm. Given a dtree \(T\) with at least five nodes, DT2DG first builds an undirected tree \(\mathrm{Tree}\) by dropping all edge directions, deleting the dtree root, and connecting the root’s two neighbors by an edge. It then produces one dtree of the dgraph for each leaf \(P\) of \(T\): the root of that dtree is a new node whose children are \(P\) and \(\mathrm{ORIENT}(C,P)\), where \(C\) is the unique neighbor of \(P\) in \(\mathrm{Tree}\); and \(\mathrm{ORIENT}(C,P)\) returns \(C\) itself if \(C\) is a leaf, otherwise a new node whose children are \(\mathrm{ORIENT}(N_1,C)\) and \(\mathrm{ORIENT}(N_2,C)\), where \(N_1,N_2\) are the two neighbors of \(C\) in \(\mathrm{Tree}\) other than \(P\). The results of ORIENT are cached, so the dtrees of the dgraph share structure. The height of a dgraph is the maximum height of the dtrees it contains.
Yes: the dgraph’s height is at most twice the input dtree’s height \(h\), so \(O(\log n)\) is preserved.
Step 1: in the dtree \(T_P\) obtained by orienting \(\mathrm{Tree}\) toward a leaf \(P\), a node created by \(\mathrm{ORIENT}(C,\cdot)\) — say it represents \(C\) — sits at depth \(d_{\mathrm{Tree}}(P,C)\), the root \(R\) having depth \(0\). By induction on depth: the children of \(R\) are \(P\) at depth \(1\) and \(\mathrm{ORIENT}(C,P)\) for \(C\) the unique neighbor of \(P\), at depth \(1 = d_{\mathrm{Tree}}(P,C)\); and if a node representing \(C\) sits at depth \(d = d_{\mathrm{Tree}}(P,C)\), created by \(\mathrm{ORIENT}(C,P^{\prime})\), then \(P^{\prime}\) is the neighbor of \(C\) on the path from \(P\) (the recursion only moves away from \(P\)), so for each of the two other neighbors \(N_i\) that path passes through \(C\) and
\begin{equation*} d_{\mathrm{Tree}}(P,N_i) = d_{\mathrm{Tree}}(P,C)+1 = d+1 . \end{equation*}
Those two neighbors always exist: every nonleaf node of \(\mathrm{Tree}\) has degree \(3\), a nonroot internal dtree node keeping its parent and two children, and each neighbor of the deleted root gaining the other in exchange for it.
Step 2: the leaves of \(T_P\) are the leaves of \(\mathrm{Tree}\) other than \(P\), returned unchanged by ORIENT, together with the copy of \(P\) at depth \(1\). So by Step 1 the height of \(T_P\) is \(\max_L d_{\mathrm{Tree}}(P,L)\) over those leaves, the eccentricity of \(P\), since the farthest node from any node of a tree is a leaf — hence at most \(\mathrm{diam}(\mathrm{Tree})\).
Step 3: \(\mathrm{diam}(\mathrm{Tree}) \le 2h\). In the undirected version of the input dtree the path between \(u\) and \(v\) runs through their deepest common ancestor, so has length at most \(\mathrm{depth}(u)+\mathrm{depth}(v) \le 2h\); and deleting the root \(r\) while joining its two children replaces each subpath \(u^{\prime}-r-v^{\prime}\) by a single edge, leaving other distances unchanged, so distances only decrease.
Hence every dtree in the dgraph has height at most \(2h\), and \(h = O(\log n)\) gives a dgraph of height \(O(\log n)\).
Let \(T_1, T_2, \ldots, T_n\) be a descending path in a dtree (that is, \(T_{i+1}\) is a child of \(T_i\) for \(i = 1,\ldots,n-1\)) where
\begin{equation*} cf(T_i) = \begin{cases} 1, & \text{for } i = 1 \text{ and } i = n\\ 0, & \text{otherwise.}\end{cases} \end{equation*}
Show that each entry of \(cache_{T_n}\) will be retrieved no more than
\begin{equation*} \Big(\big(\mathrm{context}(T_1) \cup \bigcup_{i=1}^{n-1} \mathrm{cutset}(T_i)\big) \setminus \mathrm{context}(T_n)\Big)^{\#} - 1 \end{equation*}
times after it has been filled by Algorithm RC. Show also that the definition of a dead dtree cache given by Equation 8.4, namely that the cache at node \(T\) is dead when \(\mathrm{context}(T) = \mathrm{cluster}(T^p)\) and we cache at \(T^p\), follows as a special case.
Here \(\mathbf{X}^{\#}\) denotes the number of instantiations of the variables \(\mathbf{X}\), so that \(\emptyset^{\#} = 1\).
Take the evidence empty, the worst case, since evidence only removes instantiations from the loop on Line 11 of RC. Write
\begin{equation*} \mathbf{W} \;=\; \mathrm{context}(T_1) \cup \bigcup_{i=1}^{n-1} \mathrm{cutset}(T_i), \qquad \mathbf{X} \;=\; \mathbf{W} \setminus \mathrm{context}(T_n), \end{equation*}
so the claimed bound is \(\mathbf{X}^{\#} - 1\).
Part 1: \(\mathbf{W}\) is a disjoint union. The cutsets of distinct nonleaf nodes are pairwise disjoint by Lemma 8.1(d); and \(\mathrm{context}(T_1) \subseteq \mathrm{acutset}(T_1) \subseteq \mathrm{acutset}(T_i)\) (Definition 8.5, and \(T_1\) an ancestor of each \(T_i\)) while Definition 8.3 makes \(\mathrm{cutset}(T_i)\) exclude \(\mathrm{acutset}(T_i)\), so \(\mathrm{cutset}(T_i) \cap \mathrm{context}(T_1) = \emptyset\). Hence
\begin{equation*} \mathbf{W}^{\#} \;=\; \mathrm{context}(T_1)^{\#}\prod_{i=1}^{n-1}\mathrm{cutset}(T_i)^{\#}. \end{equation*}
Part 2: the calls to \(T_n\) are labelled injectively by instantiations of \(\mathbf{W}\). Since \(cf(T_1) = 1\), the first call to \(T_1\) carrying an instantiation \(\mathbf{y}\) of \(\mathrm{context}(T_1)\) executes Lines 9-14 and stores the result while every later call carrying \(\mathbf{y}\) returns on Line 7, so \(T_1\) is expanded at most \(\mathrm{context}(T_1)^{\#}\) times, each expansion calling \(T_2\) once per instantiation of \(\mathrm{cutset}(T_1)\). For \(1 < i \le n-1\), \(cf(T_i) = 0\), so no call to \(T_i\) returns on Line 7 and every one is expanded, again calling \(T_{i+1}\) once per instantiation of \(\mathrm{cutset}(T_i)\). So each call to \(T_n\) is identified by the record
\begin{equation*} (\mathbf{y},\mathbf{c}_1,\mathbf{c}_2,\ldots,\mathbf{c}_{n-1}), \end{equation*}
with \(\mathbf{y}\) the instantiation of \(\mathrm{context}(T_1)\) at the expansion of \(T_1\) that started the chain and \(\mathbf{c}_i\) the instantiation of \(\mathrm{cutset}(T_i)\) chosen on Line 11. By Part 1 such a record is exactly an instantiation of \(\mathbf{W}\), distinct calls receive distinct records, and each record is a subinstantiation of the evidence \(\mathbf{ec}\) passed to \(T_n\) in that call.
Part 3: \(\mathrm{context}(T_n) \subseteq \mathbf{W}\). The ancestors of \(T_n\) are \(T_1,\ldots,T_{n-1}\) together with those of \(T_1\), so
\begin{equation*} \mathrm{acutset}(T_n) = \mathrm{acutset}(T_1) \cup \bigcup_{i=1}^{n-1}\mathrm{cutset}(T_i). \end{equation*}
and \(\mathrm{vars}(T_n) \subseteq \mathrm{vars}(T_1)\), \(T_n\) being a descendant of \(T_1\). Hence
\begin{equation*} \begin{aligned} \mathrm{context}(T_n) &= \mathrm{vars}(T_n) \cap \mathrm{acutset}(T_n)\\ &\subseteq \big(\mathrm{vars}(T_1) \cap \mathrm{acutset}(T_1)\big) \cup \bigcup_{i=1}^{n-1}\mathrm{cutset}(T_i)\\ &= \mathrm{context}(T_1) \cup \bigcup_{i=1}^{n-1}\mathrm{cutset}(T_i) \;=\; \mathbf{W}. \end{aligned} \end{equation*}
Part 4: counting one \(T_n\)-type. Fix an instantiation \(\mathbf{z}\) of \(\mathrm{context}(T_n)\), that is, one entry of \(cache_{T_n}\). By Part 2 the calls of type \(\mathbf{z}\) carry pairwise distinct instantiations of \(\mathbf{W}\), and by Part 3 each agrees with \(\mathbf{z}\) on \(\mathrm{context}(T_n) \subseteq \mathbf{W}\); the number of instantiations of \(\mathbf{W}\) extending a fixed one of \(\mathrm{context}(T_n)\) is
\begin{equation*} \big(\mathbf{W}\setminus\mathrm{context}(T_n)\big)^{\#} = \mathbf{X}^{\#}, \end{equation*}
so \(T_n\) receives at most \(\mathbf{X}^{\#}\) calls of type \(\mathbf{z}\). Since \(cf(T_n) = 1\), the first fills \(cache_{T_n}[\mathbf{z}]\) on Line 14 and each later one retrieves it on Line 7, so the retrievals after filling number at most
\begin{equation*} \mathbf{X}^{\#} - 1 = \Big(\big(\mathrm{context}(T_1) \cup \bigcup_{i=1}^{n-1}\mathrm{cutset}(T_i)\big) \setminus \mathrm{context}(T_n)\Big)^{\#} - 1, \end{equation*}
independently of the entry chosen, so for every entry of \(cache_{T_n}\).
Part 5. Take \(n = 2\), i.e. \(T_1 = T^p\) and \(T_2 = T\) with \(cf(T^p) = cf(T) = 1\), the situation of Equation 8.4. Then
\begin{equation*} \mathbf{W} = \mathrm{context}(T^p) \cup \mathrm{cutset}(T^p) = \mathrm{cluster}(T^p) \end{equation*}
by Definition 8.6, so each entry of \(cache_T\) is retrieved at most
\begin{equation*} \big(\mathrm{cluster}(T^p)\setminus\mathrm{context}(T)\big)^{\#} - 1 \end{equation*}
times. Under the condition of Equation 8.4, \(\mathrm{context}(T) = \mathrm{cluster}(T^p)\), that difference is \(\emptyset\), with \(\emptyset^{\#} = 1\), and the bound is \(0\): the cache at \(T\) is dead.
Show that the definition of a dead cache given by Equation 8.4 is not sufficient for a cache at a dgraph node \(T\). That is, show an example where this condition is satisfied for every parent of dgraph node \(T\) yet cache entries at \(T\) are retrieved by RC after the cache has been filled.
Recall that Equation 8.4 declares the cache at a dtree node \(T\) dead when
\begin{equation*} \mathrm{context}(T) = \mathrm{cluster}(T^p) \end{equation*}
and we also cache at the parent \(T^p\); recall also that a dgraph is a set of dtrees that share structure, that a dgraph node may therefore have several parents, that RC is run on a dgraph by running it on each of its root dtrees in turn, and that the cache attached to a shared dgraph node is shared by all the dtrees passing through it.
The dgraph of Figure 8.9 is already a counterexample: its shared node \(M\) satisfies Equation 8.4 at both parents, yet each of its four cache entries is retrieved once. Its network is that of Figure 8.10, with binary \(A,B,C,D\) and edges \(A \to B\), \(A \to C\), \(B \to C\), \(C \to D\), so the four CPTs — the leaves of every dtree in the dgraph — have variables \(A\), \(AB\), \(ABC\), \(CD\); Figure 8.9 is what DT2DG returns on the dtree of Figure 8.10, whose root has children \(N\) (children \(A\), \(AB\)) and \(M_0\) (children \(ABC\), \(CD\)).
Step 1. Deleting that root and joining \(N\) to \(M_0\) leaves the undirected tree \(\mathrm{Tree}\) of Figure 8.11, with edges
\begin{equation*} N - A, \quad N - AB, \quad N - M_0, \quad M_0 - ABC, \quad M_0 - CD . \end{equation*}
Orienting toward the leaf \(A\) gives
\begin{equation*} R_A \to \{\, A,\ Q_A \,\},\qquad Q_A \to \{\, AB,\ M \,\},\qquad M \to \{\, ABC,\ CD \,\}, \end{equation*}
where \(M = \mathrm{ORIENT}(M_0,N)\), and orienting toward the leaf \(AB\) gives
\begin{equation*} R_{AB} \to \{\, AB,\ Q_{AB} \,\},\qquad Q_{AB} \to \{\, A,\ M \,\}, \end{equation*}
where ORIENT is called with \((M_0,N)\) a second time and DT2DG’s cache returns the very same node \(M\). So \(M\) has the two parents \(Q_A\), \(Q_{AB}\) and one cache \(cache_M\) shared by both dtrees.
Step 2. With \(\mathrm{vars}(M) = ABCD\), Definitions 8.3, 8.5 and 8.6 give, top down in the dtree oriented toward \(A\),
\begin{equation*} \begin{aligned} \mathrm{cutset}(R_A) &= \mathrm{vars}(A)\cap\mathrm{vars}(Q_A) = A \cap ABCD = A,\\ \mathrm{context}(R_A) &= \emptyset, \qquad \mathrm{cluster}(R_A) = A,\\ \mathrm{cutset}(Q_A) &= \big(\mathrm{vars}(AB)\cap\mathrm{vars}(M)\big)\setminus A = AB \setminus A = B,\\ \mathrm{context}(Q_A) &= \mathrm{vars}(Q_A)\cap\mathrm{acutset}(Q_A) = ABCD \cap A = A,\\ \mathrm{cluster}(Q_A) &= B \cup A = AB,\\ \mathrm{cutset}(M) &= (ABC \cap CD)\setminus AB = C,\\ \mathrm{context}(M) &= ABCD \cap AB = AB . \end{aligned} \end{equation*}
In the dtree oriented toward \(AB\),
\begin{equation*} \begin{aligned} \mathrm{cutset}(R_{AB}) &= \mathrm{vars}(AB)\cap\mathrm{vars}(Q_{AB}) = AB,\\ \mathrm{context}(R_{AB}) &= \emptyset, \qquad \mathrm{cluster}(R_{AB}) = AB,\\ \mathrm{cutset}(Q_{AB}) &= \big(\mathrm{vars}(A)\cap\mathrm{vars}(M)\big)\setminus AB = A \setminus AB = \emptyset,\\ \mathrm{context}(Q_{AB}) &= ABCD \cap AB = AB,\\ \mathrm{cluster}(Q_{AB}) &= \emptyset \cup AB = AB,\\ \mathrm{context}(M) &= ABCD \cap (AB \cup \emptyset) = AB . \end{aligned} \end{equation*}
The context of \(M\) is \(AB\) in both dtrees, so \(cache_M\) is indexed by instantiations of \(AB\) and has four entries, as the sharing requires.
Step 3: Equation 8.4 holds at both parents, since
\begin{equation*} \mathrm{cluster}(Q_A) = AB = \mathrm{context}(M), \qquad \mathrm{cluster}(Q_{AB}) = AB = \mathrm{context}(M). \end{equation*}
so if the condition were sufficient for a dgraph node, \(cache_M\) could be deleted without penalty.
Step 4: the entries are nevertheless retrieved. Assume full caching, \(cf \equiv 1\), empty evidence, and run RC on the roots in turn, \(R_A\) first.
In \(RC(R_A,\mathrm{true})\), the root is expanded once and Line 11 ranges over the two instantiations \(\mathbf{a}\) of \(\mathrm{cutset}(R_A) = A\), calling \(RC(Q_A,\mathbf{a})\); these carry distinct instantiations of \(\mathrm{context}(Q_A) = A\), so both miss and expand, each looping over the two instantiations \(\mathbf{b}\) of \(\mathrm{cutset}(Q_A) = B\) and calling \(RC(M,\mathbf{ab})\). The four calls carry the four distinct instantiations of \(\mathrm{context}(M) = AB\), so all four miss and fill \(cache_M\) on Line 14 — no retrieval, as Equation 8.4 and Exercise 8.9 on the path \(Q_A, M\) predict.
In \(RC(R_{AB},\mathrm{true})\), the root loops over the four instantiations \(\mathbf{ab}\) of \(\mathrm{cutset}(R_{AB}) = AB\), calling \(RC(Q_{AB},\mathbf{ab})\); these carry the four distinct instantiations of \(\mathrm{context}(Q_{AB}) = AB\), so all miss and expand, and since \(\mathrm{cutset}(Q_{AB}) = \emptyset\) each expansion runs Line 11 once, issuing \(RC(M,\mathbf{ab})\). Those four calls carry instantiations already stored from the first run, so all four are hits on Line 7: every entry of \(cache_M\) is retrieved once after being filled, and Equation 8.4 is not sufficient for a dgraph cache.
Assume that CPTs support an implementation of LOOKUP that takes time and space that are linear in the number of CPT variables (instead of exponential). Provide a class of networks that have an unbounded treewidth yet on which RC will take time and space that are linear in the number of network variables.
Take \(\mathcal{N}_k\) below: a single dense family hung with a long chain, of treewidth exactly \(k\) yet solved by RC in \(O(n)\) time and space. The assumption buys only that a leaf \(T\) with CPT \(\Theta_{X|\mathbf{U}}\) costs \(O(|\mathbf{U}|+1)\) on Line 2 of RC rather than a table of size \(\Theta(\exp(|\mathbf{U}|))\), so leaves need no caches and a family may be arbitrarily large without the network being exponential; it does not reduce the number of recursive calls, and that is what must stay linear.
For \(k = 1,2,3,\ldots\) let \(\mathcal{N}_k\) be the network over binary variables
\begin{equation*} U_1,\ldots,U_k,\; X,\; Y_1,\ldots,Y_m, \qquad m = k\,2^k, \end{equation*}
with edges \(U_i \to X\), \(X \to Y_1\), and \(Y_j \to Y_{j+1}\) for \(j = 1,\ldots,m-1\), so that
\begin{equation*} n \;=\; k+1+m \;=\; k+1+k\,2^{k} \;=\; \Theta(k\,2^{k}). \end{equation*}
Moralizing makes \(\{X,U_1,\ldots,U_k\}\) a clique, forcing treewidth \(\ge k\), while the clusters \(\{X,U_1,\ldots,U_k\}\), \(\{X,Y_1\},\{Y_1,Y_2\},\ldots\) form a jointree of width \(k\); so the treewidth is exactly \(k\) and the class is unbounded.
The leaves of the dtree are the \(k+m+1\) CPTs, namely \(\{U_i\}\), the family \(\{X,U_1,\ldots,U_k\}\), and \(\{Y_1,X\}, \{Y_2,Y_1\},\ldots,\{Y_m,Y_{m-1}\}\). Build
- \(D\): the comb over the family part. Let \(D_0\) be the leaf \(\{X,U_1,\ldots,U_k\}\) and let \(D_i\) have children \(D_{i-1}\) and the leaf \(\{U_i\}\); put \(D = D_k\).
- \(C\): any balanced dtree over the \(m\) chain leaves, as in the right-hand dtree of Figure 8.7.
- the root \(R\) with children \(D\) and \(C\).
Since \(\mathrm{vars}(D) = \{X,U_1,\ldots,U_k\}\) and \(\mathrm{vars}( C) = \{X,Y_1,\ldots,Y_m\}\), Definition 8.3 gives \(\mathrm{cutset}( R) = \{X\}\): conditioning on \(X\) alone separates the dense family from the chain. Inside \(D\), top down,
\begin{equation*} \mathrm{cutset}(D_i) = \{U_i\},\qquad \mathrm{context}(D_i) = \{X,U_{i+1},\ldots,U_k\}, \end{equation*}
while inside \(C\) every cutset is a single chain variable and every cluster has at most three variables, the balanced chain dtree having width \(2\) once \(X\) is counted.
Run RC with full caching at the internal nodes and none at the leaves. Every internal node being cached, Equation 8.5 collapses for a nonroot \(T\) to \(calls(T) = \mathrm{cutset}(T^p)^{\#}\,\mathrm{context}(T^p)^{\#}\), the bound of Theorem 8.3 attained with equality, giving \(2 \cdot 2^{k-i+1}\) calls to \(D_{i-1}\) and so
\begin{equation*} \begin{aligned} \text{calls inside } D &= \textstyle\sum_{i=0}^{k}\Theta(2^{k-i+1}) = \Theta(2^{k}),\\ \text{calls inside } C &= O(m\exp(2)) = O(m), \end{aligned} \end{equation*}
the second by Theorem 8.4 on the width-\(2\) balanced chain dtree, whose subproblems are solved once per value of \(X\). The big leaf \(D_0\) receives \(2^{k+1}\) calls at \(O(k)\) each by the assumed LOOKUP, contributing \(O(k2^{k}) = O(n)\), so
\begin{equation*} \text{time} = O(2^{k}\,k + m) = O(k2^{k}) = O(n). \end{equation*}
For space, the caches hold \(\sum_T \mathrm{context}(T)^{\#} = \Theta(2^{k}) + O(m) = O(n)\) entries, the dtree has \(O(n)\) nodes, and by the assumption the CPTs occupy \(O(k) + O(m) = O(n)\) rather than the \(\Theta(2^{k})\) a tabular \(\Theta_{X|U_1\ldots U_k}\) would need. Hence
\begin{equation*} \text{space} = O(n). \end{equation*}
Suppose that you are running recursive conditioning under a limited amount of space. You have already run the depth-first branch-and-bound algorithm OPTIMAL CF and found the optimal discrete cache factor for your dgraph under a bound of \(M_{\mathrm{old}}\) cache entries. Suddenly, the amount of space available to you increases to \(M_{\mathrm{new}} > M_{\mathrm{old}}\). You want to find the new optimal discrete cache factor as quickly as possible.
(a) What is wrong with the following idea? Simply run the branch-and-bound algorithm on the set of nodes that are not included in the current cache factor, finding the subset of these nodes that will most efficiently fill up the new space. Then add these nodes to the current cache factor.
(b) How can we use our current cache factor to find the new optimal cache factor more quickly than if we had to start from scratch?
(a) The idea is unsound: it returns only cache factors extending \(cf_{\mathrm{old}}\), and the optimum for \(M_{\mathrm{new}}\) need not extend the optimum for \(M_{\mathrm{old}}\).
(i) Wrong search space. Let \(\mathrm{context}(T)^{\#} = 8\) and \(\mathrm{context}(T^{\prime})^{\#} = 4\), with caching at \(T\) alone removing \(100\) calls and at \(T^{\prime}\) alone removing \(20\). Under \(M_{\mathrm{old}} = 4\) only \(T^{\prime}\) fits, so \(cf_{\mathrm{old}}\) caches at \(T^{\prime}\); under \(M_{\mathrm{new}} = 8\) the optimum caches at \(T\) alone, but the procedure is locked into \(T^{\prime}\), has \(4\) entries left, cannot afford \(T\), and misses the optimum by a factor of five. (Knapsack behaviour: an optimal small packing need not sit inside an optimal larger one.)
(ii) Ill-posed subproblem. Call reduction is not additive over nodes: by Equation 8.7 the gain from caching at \(T\) is
\begin{equation*} c_1 - c_2 = \mathrm{cutset}(T)^{\#}\big(calls_{cf}(T) - \mathrm{context}(T)^{\#}\big) \big(cpc_{cf}(T^l) + cpc_{cf}(T^r)\big), \end{equation*}
which depends on the whole factor \(cf\) through \(calls_{cf}\) and \(cpc_{cf}\) (Equation 8.5). Indeed caching at an ancestor \(T\) lowers \(calls(T^{\prime})\) at a descendant and can render \(cache_{T^{\prime}}\) dead (Equation 8.4 and Exercise 8.9), so memory already committed becomes waste. A correct algorithm must be free to withdraw a cache; this one is not.
(b) Reuse \(cf_{\mathrm{old}}\) as an incumbent, not as a fixed core. Since \(M_{\mathrm{new}} > M_{\mathrm{old}}\), every old-feasible factor is new-feasible, so \(c^{\ast}_{\mathrm{new}} \le c^{\ast}_{\mathrm{old}}\), and we may rerun OPTIMAL CF with bound \(M_{\mathrm{new}}\) after replacing Lines 1–2 by
\begin{equation*} cf^{o} \leftarrow cf_{\mathrm{old}}, \qquad c^{o} \leftarrow c^{\ast}_{\mathrm{old}} \end{equation*}
in place of \(c^{o} \leftarrow \infty\). Every search node with lower bound \(\ge c^{\ast}_{\mathrm{old}}\) is then pruned immediately on Line 1, where a fresh search must first descend to a complete factor; optimality survives because we prune only completions that cannot beat a factor in hand, and factors not extending \(cf_{\mathrm{old}}\) are still explored.
Three further savings. (i) If \(c^{\ast}_{\mathrm{old}}\) equals \(\mathrm{lower\ bound}(\emptyset)\), the call count under full caching, then \(cf_{\mathrm{old}}\) is optimal for any memory and no search is needed; in general stop as soon as an incumbent attains that value. (ii) Order Line 7 to prefer nodes cached by \(cf_{\mathrm{old}}\), ties by largest \(\mathrm{context}(T)^{\#}\) (Section 8.6.1), so the first dive spends the leftover memory and tightens the incumbent early. (iii) The dgraph, the lower-bound function and the quantities \(calls(\cdot)\), \(cpc(\cdot)\) of Section 8.6.2 do not depend on \(M\), so the incremental update scheme starts from the old values.
Not reusable: the record of subtrees pruned for violating \(M_{\mathrm{old}}\), since such a subtree may hold the new optimum. Prunings from the bound test remain valid and are subsumed by the initialization above.
Consider the dtree in Figure 8.13. Assuming all variables are binary, which internal node will the greedy cache allocation algorithm GREEDY CF select first for caching? Show your work.
The Bayesian network of Figure 8.13 has binary variables \(A,B,C,D,E,F,G\) and edges
\begin{equation*} \begin{aligned} &A \to D,\quad B \to D,\quad B \to E,\quad C \to E,\\ &C \to F,\quad D \to F,\quad E \to G,\quad F \to G, \end{aligned} \end{equation*}
so its seven CPTs (the leaves of the dtree) have variable sets \(A\), \(B\), \(C\), \(ABD\), \(BCE\), \(CDF\), and \(EFG\).
The accompanying dtree has thirteen nodes, numbered \(1\) through \(13\), with the following structure:
- node \(1\) (the root) has children \(2\) and \(3\); node \(3\) is the leaf \(C\);
- node \(2\) has children \(4\) and \(5\); node \(5\) is the leaf \(EFG\);
- node \(4\) has children \(6\) and \(7\); node \(6\) is the leaf \(CDF\);
- node \(7\) has children \(8\) and \(9\); node \(8\) is the leaf \(BCE\);
- node \(9\) has children \(10\) and \(11\); node \(10\) is the leaf \(B\);
- node \(11\) has children \(12\) and \(13\); node \(12\) is the leaf \(ABD\) and node \(13\) is the leaf \(A\).
Recall that GREEDY CF starts from the cache factor that caches nowhere and picks the node \(T\) maximizing \((c_1-c_2)/\mathrm{context}(T)^{\#}\), where \(c_1\) and \(c_2\) are the total numbers of recursive calls before and after caching at \(T\); recall also that an internal node is one that is neither a leaf nor the root.
GREEDY CF selects node \(9\), with score \(42\), allocating it \(\mathrm{context}(9)^{\#} = 4\) cache entries.
Cutsets, contexts and clusters top down by Definitions 8.3, 8.5 and 8.6, using \(\mathrm{vars}(2) = ABCDEFG\), \(\mathrm{vars}(4) = ABCDEF\), \(\mathrm{vars}(7) = ABCDE\), \(\mathrm{vars}(9) = \mathrm{vars}(11) = ABD\):
| \(T\) | \(\mathrm{cutset}(T)\) | \(\mathrm{acutset}(T)\) | \(\mathrm{context}(T)\) | \(\mathrm{cluster}(T)\) | \(\mathrm{cutset}(T)^{\#}\) | \(\mathrm{context}(T)^{\#}\) |
|---|---|---|---|---|---|---|
| 1 | \(C\) | \(\emptyset\) | \(\emptyset\) | \(C\) | 2 | 1 |
| 2 | \(EF\) | \(C\) | \(C\) | \(CEF\) | 4 | 2 |
| 3 | leaf | \(C\) | \(C\) | \(C\) | - | 2 |
| 4 | \(D\) | \(CEF\) | \(CEF\) | \(CDEF\) | 2 | 8 |
| 5 | leaf | \(CEF\) | \(EF\) | \(EFG\) | - | 4 |
| 6 | leaf | \(CDEF\) | \(CDF\) | \(CDF\) | - | 8 |
| 7 | \(B\) | \(CDEF\) | \(CDE\) | \(BCDE\) | 2 | 8 |
| 8 | leaf | \(BCDEF\) | \(BCE\) | \(BCE\) | - | 8 |
| 9 | \(\emptyset\) | \(BCDEF\) | \(BD\) | \(BD\) | 1 | 4 |
| 10 | leaf | \(BCDEF\) | \(B\) | \(B\) | - | 2 |
| 11 | \(A\) | \(BCDEF\) | \(BD\) | \(ABD\) | 2 | 4 |
| 12 | leaf | \(ABCDEF\) | \(ABD\) | \(ABD\) | - | 8 |
| 13 | leaf | \(ABCDEF\) | \(A\) | \(A\) | - | 2 |
(For instance \(\mathrm{cutset}(9) = (\mathrm{vars}(10)\cap\mathrm{vars}(11))\setminus\mathrm{acutset}(9) = B \setminus BCDEF = \emptyset\) and \(\mathrm{context}(9) = ABD \cap BCDEF = BD\); the rest is routine. Check!)
GREEDY CF starts from \(cf_1 \equiv 0\), so Equation 8.5 collapses to \(calls(T) = \mathrm{cutset}(T^p)^{\#}\,calls(T^p)\) and Equation 8.6 to \(cpc(T) = 1 + \mathrm{cutset}(T)^{\#}(cpc(T^l)+cpc(T^r))\), with \(cpc = 1\) at leaves. Traversing downward for \(calls\) and upward for \(cpc\):
| \(T\) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| \(calls(T)\) | 1 | 2 | 2 | 8 | 8 | 16 | 16 | 32 | 32 | 32 | 32 | 64 | 64 |
| \(cpc(T)\) | 309 | 153 | 1 | 37 | 1 | 1 | 17 | 1 | 7 | 1 | 5 | 1 | 1 |
Consistently, \(c_1 = \sum_T calls(T) = 309 = cpc(1)\), the calls RC1 makes with no evidence.
The internal nodes are \(2, 4, 7, 9, 11\), and Equation 8.7 gives
\begin{equation*} score_{cf_1}(T) = \frac{\mathrm{cutset}(T)^{\#}\big(calls(T)-\mathrm{context}(T)^{\#}\big) \big(cpc(T^l)+cpc(T^r)\big)}{\mathrm{context}(T)^{\#}} . \end{equation*}
Substituting the tables above:
\begin{equation*} \begin{aligned} score(2) &= \frac{4\,(2-2)(37+1)}{2} = 0,\\ score(4) &= \frac{2\,(8-8)(1+17)}{8} = 0,\\ score(7) &= \frac{2\,(16-8)(1+7)}{8} = 16,\\ score(9) &= \frac{1\,(32-4)(1+5)}{4} = \frac{168}{4} = 42,\\ score(11) &= \frac{2\,(32-4)(1+1)}{4} = \frac{112}{4} = 28 . \end{aligned} \end{equation*}
Directly: caching at \(T\) replaces \(calls(T)\) by \(\mathrm{context}(T)^{\#}\) where \(T\) feeds its children, leaving counts above \(T\) unchanged, so recomputing \(c_2 = \sum_S calls(S)\) gives
| cached node \(T\) | \(c_1\) | \(c_2\) | \(c_1-c_2\) | \(M = \mathrm{context}(T)^{\#}\) | \((c_1-c_2)/M\) |
|---|---|---|---|---|---|
| 2 | 309 | 309 | 0 | 2 | 0 |
| 4 | 309 | 309 | 0 | 8 | 0 |
| 7 | 309 | 181 | 128 | 8 | 16 |
| 9 | 309 | 141 | 168 | 4 | 42 |
| 11 | 309 | 197 | 112 | 4 | 28 |
(At node \(9\), caching turns its \(32\) calls into \(4\) expansions, so \(10, 11\) drop from \(32\) to \(4\) and \(12, 13\) from \(64\) to \(8\), giving \(c_2 = 117 + 4 + 4 + 8 + 8 = 141\).) The direct counts match Equation 8.7 throughout, and the largest score is \(42\) at node \(9\).
The zeros are dead caches in the sense of Equation 8.4, since \(\mathrm{context}(2) = C = \mathrm{cluster}(1)\) and \(\mathrm{context}(4) = CEF = \mathrm{cluster}(2)\), so by Exercise 8.9 neither cache is ever read; deleting such nodes first leaves \(7, 9, 11\) and again selects \(9\).
Prove Equation 8.7. That is, let \(cf_1\) be a cache factor for a dgraph with \(cf_1(T) = 0\) at some nonleaf node \(T\), let \(cf_2\) be the cache factor that results from caching at \(T\) (so \(cf_2(T) = 1\) and \(cf_2 = cf_1\) everywhere else), and let \(c_1\) and \(c_2\) be the total numbers of recursive calls made by RC under \(cf_1\) and \(cf_2\) as given by
\begin{equation*} calls(T) = \sum_{T^p}\mathrm{cutset}(T^p)^{\#} \big[cf(T^p)\mathrm{context}(T^p)^{\#} + (1-cf(T^p))\,calls(T^p)\big], \end{equation*}
which is Equation 8.5. With
\begin{equation*} cpc_{cf}(T) = \begin{cases} 1, & \text{if } T \text{ is a leaf or } cf(T) = 1\\ 1 + \mathrm{cutset}(T)^{\#}\big(cpc_{cf}(T^l)+cpc_{cf}(T^r)\big), & \text{otherwise,} \end{cases} \end{equation*}
which is Equation 8.6, show that
\begin{equation*} score_{cf_1}(T) = \frac{c_1-c_2}{\mathrm{context}(T)^{\#}} = \frac{\mathrm{cutset}(T)^{\#}\big(calls_{cf_1}(T)-\mathrm{context}(T)^{\#}\big) \big(cpc_{cf_1}(T^l)+cpc_{cf_1}(T^r)\big)}{\mathrm{context}(T)^{\#}} . \end{equation*}
Write \(V\) for the set of dgraph nodes and, for a cache factor \(cf\), put
\begin{equation*} e_{cf}(S) \;=\; cf(S)\,\mathrm{context}(S)^{\#} + (1-cf(S))\,calls_{cf}(S), \end{equation*}
the number of calls to \(S\) actually expanded (\(cf\) being discrete, this is \(\mathrm{context}(S)^{\#}\) when \(cf(S) = 1\) and \(calls_{cf}(S)\) when \(cf(S) = 0\)). Equation 8.5 then reads
\begin{equation*} calls_{cf}(S) \;=\; \sum_{S^p} \mathrm{cutset}(S^p)^{\#}\,e_{cf}(S^p), \tag{\(\ast\)} \end{equation*}
with \(calls_{cf}(S) = 1\) for a root \(S\), independently of \(cf\). The total number of recursive calls is \(c = \sum_{S\in V} calls_{cf}(S)\).
Set \(\delta(S) = calls_{cf_2}(S) - calls_{cf_1}(S)\) and \(\varepsilon(S) = e_{cf_2}(S) - e_{cf_1}(S)\). Inducting in topological order, \(\delta = 0\) at every root, and if \(S\) is not a proper descendant of \(T\) then no parent of \(S\) is \(T\) or a descendant of it, so \(\delta = 0\) and (as \(cf_1 = cf_2\) off \(T\)) \(\varepsilon = 0\) at every parent, whence \(\delta(S) = 0\) by \((\ast)\). In particular
\begin{equation*} calls_{cf_2}(T) = calls_{cf_1}(T), \end{equation*}
(a DAG node is not a proper descendant of itself), while \(cf_1(T)=0\), \(cf_2(T)=1\) give
\begin{equation*} \varepsilon(T) \;=\; \mathrm{context}(T)^{\#} - calls_{cf_1}(T), \end{equation*}
and \(\varepsilon(S) = (1-cf_1(S))\,\delta(S)\) for \(S \neq T\). Unrolling \((\ast)\) along the DAG (terminating by acyclicity) therefore gives, for every \(S\),
\begin{equation*} \delta(S) \;=\; \varepsilon(T)\sum_{\pi\,:\,T \rightsquigarrow S} w(\pi), \end{equation*}
the sum ranging over all directed paths \(\pi : T = S_0 \to S_1 \to \cdots \to S_r = S\) with \(r \ge 1\), where
\begin{equation*} w(\pi) \;=\; \mathrm{cutset}(S_0)^{\#}\prod_{j=1}^{r-1}\big(1-cf_1(S_j)\big)\,\mathrm{cutset}(S_j)^{\#} . \end{equation*}
each application of \((\ast)\) pushing the perturbation to the children scaled by \(\mathrm{cutset}(\cdot)^{\#}\), while a node with \(cf_1(S_j) = 1\) absorbs it entirely (\(e(S_j) = \mathrm{context}(S_j)^{\#}\) is independent of \(calls(S_j)\)). Paths are the right bookkeeping because a node may be reached from \(T\) by several routes, and by \((\ast)\) calls from different parents add.
Let \(W(S)\) be the sum over all directed paths out of \(S\), the empty path included, of \(\prod_{j=0}^{r-1}(1-cf_1(S_j))\mathrm{cutset}(S_j)^{\#}\) (empty path weight \(1\)). Splitting off the first edge,
\begin{equation*} W(S) \;=\; 1 + \big(1-cf_1(S)\big)\mathrm{cutset}(S)^{\#}\big(W(S^l)+W(S^r)\big), \end{equation*}
with \(W(S) = 1\) at a leaf. As \(cf_1\) is discrete, \(1-cf_1(S)\) is \(0\) when \(cf_1(S)=1\) and \(1\) otherwise, so this recurrence is Equation 8.6 verbatim and \(W = cpc_{cf_1}\) everywhere. Summing the path expansion over all nodes and grouping paths out of \(T\) by whether the first edge goes to \(T^l\) or \(T^r\),
\begin{equation*} \begin{aligned} c_2-c_1 &= \sum_{S\in V}\delta(S) = \varepsilon(T)\!\!\sum_{\pi \text{ starts at } T,\ |\pi|\ge 1}\!\! w(\pi)\\ &= \varepsilon(T)\,\mathrm{cutset}(T)^{\#}\big(W(T^l)+W(T^r)\big)\\ &= \varepsilon(T)\,\mathrm{cutset}(T)^{\#}\big(cpc_{cf_1}(T^l)+cpc_{cf_1}(T^r)\big). \end{aligned} \end{equation*}
Substituting \(\varepsilon(T) = \mathrm{context}(T)^{\#} - calls_{cf_1}(T)\) and changing sign,
\begin{equation*} c_1-c_2 = \mathrm{cutset}(T)^{\#}\big(calls_{cf_1}(T)-\mathrm{context}(T)^{\#}\big) \big(cpc_{cf_1}(T^l)+cpc_{cf_1}(T^r)\big). \end{equation*}
Dividing by the memory \(M = \mathrm{context}(T)^{\#}\) that the greedy method allocates to \(cache_T\) yields Equation 8.7:
\begin{equation*} score_{cf_1}(T) = \frac{c_1-c_2}{\mathrm{context}(T)^{\#}} = \frac{\mathrm{cutset}(T)^{\#}\big(calls_{cf_1}(T)-\mathrm{context}(T)^{\#}\big) \big(cpc_{cf_1}(T^l)+cpc_{cf_1}(T^r)\big)}{\mathrm{context}(T)^{\#}} . \qquad \blacksquare \end{equation*}
Models for Graph Decomposition
Exercises 9.1–9.7
Construct a jointree for the DAG in Figure 9.28 using the elimination order \(\pi = A, G, B, C, D, E, F\) and Algorithm 23.
The DAG of Figure 9.28 has nodes \(A, B, C, D, E, F, G\) and edges
\begin{equation*} A \to D,\quad B \to D,\quad B \to E,\quad C \to E, \end{equation*}
\begin{equation*} C \to F,\quad D \to F,\quad E \to G,\quad F \to G . \end{equation*}
Its families are therefore \(A\), \(B\), \(C\), \(ABD\), \(BCE\), \(CDF\), \(EFG\).
Algorithm 23 returns the chain \(ABD - BCDE - CDEF - EFG\), with separators \(BD\), \(CDE\), \(EF\).
Moralizing marries the parents of \(D\), \(E\), \(F\), \(G\), adding \(A - B\), \(B - C\), \(C - D\), \(E - F\), so \(G^m\) has adjacency
| node | neighbours in \(G^m\) |
|---|---|
| \(A\) | \(B, D\) |
| \(B\) | \(A, C, D, E\) |
| \(C\) | \(B, D, E, F\) |
| \(D\) | \(A, B, C, F\) |
| \(E\) | \(B, C, F, G\) |
| \(F\) | \(C, D, E, G\) |
| \(G\) | \(E, F\) |
By Definition 9.4, \(C_i\) is \(\pi(i)\) with its current neighbours, which are then made a clique. Eliminating \(A\) (neighbours \(B, D\), already adjacent) and \(G\) (neighbours \(E, F\), already adjacent) creates no fill-in; eliminating \(B\) (remaining neighbours \(C, D, E\), with \(D - E\) missing) adds the fill-in \(D - E\), after which \(C, D, E, F\) are pairwise adjacent and the remaining eliminations add nothing. The induced sequence is
\begin{equation*} \begin{aligned} C_1 &= ABD, & C_2 &= EFG, & C_3 &= BCDE, & C_4 &= CDEF,\\ C_5 &= DEF, & C_6 &= EF, & C_7 &= F. \end{aligned} \end{equation*}
so \(\mathrm{width}(\pi, G) = 3\) by Definition 9.5, and every family lies in a cluster as Theorem 9.5 guarantees (\(A, B, ABD \subseteq C_1\); \(C, BCE \subseteq C_3\); \(CDF \subseteq C_4\); \(EFG = C_2\)).
Each of \(C_5 = DEF\), \(C_6 = EF\), \(C_7 = F\) is contained in \(C_4 = CDEF\), which is in each case the largest index below with this property, so Theorem 9.7 deletes them one at a time, moving \(C_4\) into the vacated adjacent position and thus leaving the order unchanged:
\begin{equation*} C_1 = ABD,\quad C_2 = EFG,\quad C_3 = BCDE,\quad C_4 = CDEF . \end{equation*}
None of the four contains another, and the running intersection property of Theorem 9.6 survives:
\begin{equation*} \begin{aligned} C_1 \cap (C_2 \cup C_3 \cup C_4) &= BD \subseteq C_3,\\ C_2 \cap (C_3 \cup C_4) &= EF \subseteq C_4,\\ C_3 \cap C_4 &= CDE \subseteq C_4 . \end{aligned} \end{equation*}
Theorem 9.8 now attaches each \(C_i\), working backwards from \(C_4\), to a later cluster containing \(C_i \cap (C_{i+1} \cup \dots \cup C_4)\): (i) \(CDE \subseteq C_4\), giving \(BCDE - CDEF\); (ii) \(EF\) sits only in \(C_4\) (\(BCDE\) lacks \(F\)), giving \(EFG - CDEF\); (iii) \(BD\) sits only in \(C_3\), giving \(ABD - BCDE\). The jointree is the chain
\begin{equation*} ABD \;\overset{BD}{-\!\!-}\; BCDE \;\overset{CDE}{-\!\!-}\; CDEF \;\overset{EF}{-\!\!-}\; EFG , \end{equation*}
separators written above their edges. Definition 9.13 holds: families lie in clusters as checked, and each variable spans a subpath of the chain (\(D\) in \(ABD, BCDE, CDEF\); \(E\) in \(BCDE, CDEF, EFG\); the rest in one or two adjacent clusters). Width \(3 = \mathrm{width}(\pi, G)\).
Construct a jointree for the DAG in Figure 9.28 using the elimination order \(\pi = A, G, B, C, D, E, F\) and Algorithm 24. In case of multiple maximum spanning trees, show all of them.
The DAG of Figure 9.28 has nodes \(A, B, C, D, E, F, G\) and edges
\begin{equation*} A \to D,\quad B \to D,\quad B \to E,\quad C \to E, \end{equation*}
\begin{equation*} C \to F,\quad D \to F,\quad E \to G,\quad F \to G . \end{equation*}
The maximum spanning tree is unique, namely the chain \(ABD - BCDE - CDEF - EFG\) of Exercise 9.1.
Algorithm 24 keeps the maximal clusters, weights edge \(C_i - C_j\) of the complete cluster graph by \(|C_i \cap C_j|\), and returns a maximum spanning tree (Theorem 9.9). The clusters are those of Exercise 9.1:
\begin{equation*} \begin{aligned} C_1 &= ABD, & C_2 &= EFG, & C_3 &= BCDE, & C_4 &= CDEF,\\ C_5 &= DEF, & C_6 &= EF, & C_7 &= F. \end{aligned} \end{equation*}
Since \(DEF, EF, F \subset CDEF\) and none of the other four contains another,
\begin{equation*} S = \{\, ABD,\; EFG,\; BCDE,\; CDEF \,\} , \end{equation*}
no reordering by Theorem 9.7 being needed here, as EO2JT2 wants only the set. The six weights \(|C_i \cap C_j|\) are
| edge | intersection | weight |
|---|---|---|
| \(BCDE - CDEF\) | \(CDE\) | \(3\) |
| \(ABD - BCDE\) | \(BD\) | \(2\) |
| \(EFG - CDEF\) | \(EF\) | \(2\) |
| \(ABD - CDEF\) | \(D\) | \(1\) |
| \(EFG - BCDE\) | \(E\) | \(1\) |
| \(ABD - EFG\) | \(\emptyset\) | \(0\) |
A spanning tree on four nodes has three edges, so its weight is at most \(3 + 2 + 2 = 7\); the three heaviest edges \(BCDE - CDEF\), \(ABD - BCDE\), \(EFG - CDEF\) form a simple path, hence attain it. Omitting any of the three forces weight at most \(3 + 2 + 1 = 6\), since the remaining weights are \(\{1, 1, 0\}\), so the maximum spanning tree is unique:
\begin{equation*} ABD \;-\; BCDE \;-\; CDEF \;-\; EFG , \end{equation*}
with separators \(BD\), \(CDE\), \(EF\). This is Exercise 9.1’s jointree; by Theorem 9.9 it has the jointree property, of width \(4 - 1 = 3 = \mathrm{width}(\pi, G)\).
Convert the dtree in Figure 9.28 to a jointree and then remove all nonmaximal clusters.
The dtree in Figure 9.28 is a full binary tree with thirteen nodes, numbered \(1\) to \(13\), whose leaves correspond to the seven families of the DAG of Figure 9.28 (nodes \(A, \dots, G\) with edges \(A \to D\), \(B \to D\), \(B \to E\), \(C \to E\), \(C \to F\), \(D \to F\), \(E \to G\), \(F \to G\)). Its structure is
| node | children | family (if a leaf) |
|---|---|---|
| \(1\) | \(2, 3\) | |
| \(2\) | \(4, 5\) | |
| \(3\) | — | \(C\) |
| \(4\) | \(6, 7\) | |
| \(5\) | — | \(EFG\) |
| \(6\) | — | \(CDF\) |
| \(7\) | \(8, 9\) | |
| \(8\) | — | \(BCE\) |
| \(9\) | \(10, 11\) | |
| \(10\) | — | \(B\) |
| \(11\) | \(12, 13\) | |
| \(12\) | — | \(ABD\) |
| \(13\) | — | \(A\) |
Labelling each dtree node by \(\mathrm{cluster}(T)\) gives a jointree, which reduces to the chain \(ABD - BCDE - CDEF - EFG\); by Theorem 9.10 the dtree clusters satisfy the jointree property, and the leaf clusters are exactly the families.
Bottom-up, \(\mathrm{vars}\) is the family at a leaf and \(\mathrm{vars}(T^l) \cup \mathrm{vars}(T^r)\) at a nonleaf:
\begin{equation*} \begin{aligned} \mathrm{vars}(11) &= ABD \cup A = ABD,\\ \mathrm{vars}(9) &= B \cup ABD = ABD,\\ \mathrm{vars}(7) &= BCE \cup ABD = ABCDE,\\ \mathrm{vars}(4) &= CDF \cup ABCDE = ABCDEF,\\ \mathrm{vars}(2) &= ABCDEF \cup EFG = ABCDEFG,\\ \mathrm{vars}(1) &= ABCDEFG \cup C = ABCDEFG . \end{aligned} \end{equation*}
Descending with \(\mathrm{cutset}(T) = (\mathrm{vars}(T^l) \cap \mathrm{vars}(T^r)) \setminus \mathrm{acutset}(T)\) and \(\mathrm{context}(T) = \mathrm{vars}(T) \cap \mathrm{acutset}(T)\), where \(\mathrm{acutset}(T)\) unions the cutsets of the proper ancestors: \(\mathrm{cutset}(1) = C\), \(\mathrm{cutset}(2) = EF \setminus C = EF\), \(\mathrm{cutset}(4) = CD \setminus CEF = D\), \(\mathrm{cutset}(7) = B \setminus CDEF = B\), \(\mathrm{cutset}(9) = B \setminus BCDEF = \emptyset\), \(\mathrm{cutset}(11) = A \setminus BCDEF = A\). With \(\mathrm{cluster}(T) = \mathrm{cutset}(T) \cup \mathrm{context}(T)\) at nonleaves and \(\mathrm{vars}(T)\) at leaves,
| node | \(\mathrm{cutset}\) | \(\mathrm{context}\) | \(\mathrm{cluster}\) |
|---|---|---|---|
| \(1\) | \(C\) | \(\emptyset\) | \(C\) |
| \(2\) | \(EF\) | \(C\) | \(CEF\) |
| \(3\) | — | \(C\) | \(C\) |
| \(4\) | \(D\) | \(CEF\) | \(CDEF\) |
| \(5\) | — | \(EF\) | \(EFG\) |
| \(6\) | — | \(CDF\) | \(CDF\) |
| \(7\) | \(B\) | \(CDE\) | \(BCDE\) |
| \(8\) | — | \(BCE\) | \(BCE\) |
| \(9\) | \(\emptyset\) | \(BD\) | \(BD\) |
| \(10\) | — | \(B\) | \(B\) |
| \(11\) | \(A\) | \(BD\) | \(ABD\) |
| \(12\) | — | \(ABD\) | \(ABD\) |
| \(13\) | — | \(A\) | \(A\) |
a jointree of width \(4 - 1 = 3\). Now apply the Section 9.4 transformations, both of which preserve the jointree properties: remove cluster deletes a \(C_j\) whose single neighbour \(C_i\) contains it, and merge clusters replaces neighbours by \(C_i \cup C_j\), inheriting their neighbours. Removals: leaf \(3\) (\(C\)) into \(1\) (\(C\)); then leaf \(1\) (\(C\)) into \(2\) (\(CEF\)); then \(2\) (\(CEF\)) merges into \(4\) (\(CDEF\)), reattaching \(5\) to \(4\); leaf \(6\) (\(CDF\)) into \(4\); leaf \(8\) (\(BCE\)) into \(7\) (\(BCDE\)); \(9\) (\(BD\)) merges into \(7\), reattaching \(10, 11\); leaf \(10\) (\(B\)) into \(7\); leaves \(12\) (\(ABD\)) and \(13\) (\(A\)) into \(11\) (\(ABD\)).
Surviving are \(4\), \(5\), \(7\), \(11\), with \(5\) and \(7\) on \(4\) and \(11\) on \(7\), and no remaining cluster contains another (\(A \notin BCDE\), \(G \notin CDEF\)):
\begin{equation*} ABD \;\overset{BD}{-\!\!-}\; BCDE \;\overset{CDE}{-\!\!-}\; CDEF \;\overset{EF}{-\!\!-}\; EFG , \end{equation*}
the jointree of Exercises 9.1 and 9.2, still of width \(3\).
Construct a total elimination order that is consistent with the partial elimination order induced by the dtree in Figure 9.28. When the relative order of two variables is not fixed by the dtree, place them in alphabetic order.
The dtree in Figure 9.28 is the full binary tree on nodes \(1, \dots, 13\) in which node \(1\) has children \(2\) and \(3\); node \(2\) has children \(4\) and \(5\); node \(4\) has children \(6\) and \(7\); node \(7\) has children \(8\) and \(9\); node \(9\) has children \(10\) and \(11\); node \(11\) has children \(12\) and \(13\). The leaves carry the families of the DAG of Figure 9.28: node \(3\) is \(C\), node \(5\) is \(EFG\), node \(6\) is \(CDF\), node \(8\) is \(BCE\), node \(10\) is \(B\), node \(12\) is \(ABD\), node \(13\) is \(A\).
\(\pi = A, B, D, G, E, F, C\).
By Definition 9.11, \(X\) is eliminated at the node \(T\) with \(X \in \mathrm{cluster}(T) \setminus \mathrm{context}(T)\), which at a nonleaf is \(\mathrm{cutset}(T)\), and by Theorem 9.3 this node is unique. From Exercise 9.3,
\begin{equation*} \begin{aligned} \mathrm{cutset}(1) &= C, & \mathrm{cutset}(2) &= EF, & \mathrm{cutset}(4) &= D,\\ \mathrm{cutset}(7) &= B, & \mathrm{cutset}(9) &= \emptyset, & \mathrm{cutset}(11) &= A, \end{aligned} \end{equation*}
while at the leaves \(\mathrm{cluster} \setminus \mathrm{context}\) is empty except at node \(5\), where it is \(EFG \setminus EF = G\):
| variable | eliminated at node |
|---|---|
| \(A\) | \(11\) |
| \(B\) | \(7\) |
| \(C\) | \(1\) |
| \(D\) | \(4\) |
| \(E\) | \(2\) |
| \(F\) | \(2\) |
| \(G\) | \(5\) |
By Definition 9.12, \(X < Y\) when \(X\)’s node is a descendant of \(Y\)’s, and the two are unordered when the nodes coincide. The dtree’s ancestor chains are \(11 \prec 9 \prec 7 \prec 4 \prec 2 \prec 1\) and \(5 \prec 2 \prec 1\), with \(5\) and \(11\) in different subtrees of \(2\), so
\begin{equation*} A < B < D < E, \qquad A < B < D < F, \end{equation*}
\begin{equation*} G < E, \qquad G < F, \qquad E < C, \qquad F < C, \end{equation*}
with \(E, F\) unordered (both at node \(2\)) and \(G\) unordered against \(A\), \(B\), \(D\). Extending greedily, alphabetically first among the available minimal elements: \(A\) (over \(G\)), then \(B\) (over \(G\)), then \(D\) (over \(G\)), then \(G\) forced since \(E, F\) await it, then \(E\) before \(F\) alphabetically, then \(C\):
\begin{equation*} \pi = A,\; B,\; D,\; G,\; E,\; F,\; C . \end{equation*}
Theorem 9.4 predicts \(\mathrm{width}(\pi, G) \le 3\), the Exercise 9.3 dtree width. Applying \(\pi\) to the moral graph (edges \(A - B\), \(A - D\), \(B - C\), \(B - D\), \(B - E\), \(C - D\), \(C - E\), \(C - F\), \(D - F\), \(E - F\), \(E - G\), \(F - G\)) gives
\begin{equation*} \begin{aligned} ABD,\; BCDE,\; CDEF,\; EFG,\; CEF,\; CF,\; C , \end{aligned} \end{equation*}
the only fill-in being \(D - E\) on eliminating \(B\). The largest cluster has four variables, so \(\mathrm{width}(\pi, G) = 3\), matching the dtree width.
Construct a dtree for the DAG in Figure 9.28 using the elimination order \(\pi = A, G, B, C, D, E, F\) and Algorithm 25. What is the width of this order? What is the width of the generated dtree?
The DAG of Figure 9.28 has nodes \(A, B, C, D, E, F, G\) and edges
\begin{equation*} A \to D,\quad B \to D,\quad B \to E,\quad C \to E, \end{equation*}
\begin{equation*} C \to F,\quad D \to F,\quad E \to G,\quad F \to G , \end{equation*}
so its seven families are \(A\), \(B\), \(C\), \(ABD\), \(BCE\), \(CDF\), \(EFG\).
Both widths are \(3\).
The order: by Exercise 9.1, moralization adds \(A - B\), \(B - C\), \(C - D\), \(E - F\), and \(\pi\) induces the clusters \(ABD, EFG, BCDE, CDEF, DEF, EF, F\), the largest of size four, so \(\mathrm{width}(\pi, G) = 3\) by Definition 9.5.
Algorithm 25 starts with \(\Sigma = \{ A, ABD, B, BCE, C, CDF, EFG \}\), one single-node dtree per family, and for each \(\pi(i)\) composes all trees mentioning it (a single tree composes to itself, leaving \(\Sigma\) fixed). The trace:
| \(\pi(i)\) | trees composed | result | \(\Sigma\) after |
|---|---|---|---|
| \(A\) | \(A\), \(ABD\) | \(T_1\), \(\mathrm{vars} = ABD\) | \(T_1, B, BCE, C, CDF, EFG\) |
| \(G\) | \(EFG\) only | — | unchanged |
| \(B\) | \(T_1\), \(B\), \(BCE\) | \(T_3\), \(\mathrm{vars} = ABCDE\) | \(T_3, C, CDF, EFG\) |
| \(C\) | \(T_3\), \(C\), \(CDF\) | \(T_4\), \(\mathrm{vars} = ABCDEF\) | \(T_4, EFG\) |
| \(D\) | \(T_4\) only | — | unchanged |
| \(E\) | \(T_4\), \(EFG\) | \(T_6\), \(\mathrm{vars} = ABCDEFG\) | \(T_6\) |
| \(F\) | \(T_6\) only | — | unchanged |
so the algorithm returns \(T_6\). Taking the left-linear \(\mathrm{COMPOSE}\), which may connect its arguments into a binary tree any way, in the order listed:
| node | children |
|---|---|
| \(n_6\) | \(n_5\), leaf \(EFG\) |
| \(n_5\) | \(n_4\), leaf \(CDF\) |
| \(n_4\) | \(n_3\), leaf \(C\) |
| \(n_3\) | \(n_2\), leaf \(BCE\) |
| \(n_2\) | \(n_1\), leaf \(B\) |
| \(n_1\) | leaf \(A\), leaf \(ABD\) |
rooted at \(n_6\): a full binary tree whose seven leaves biject with the families, hence a dtree by Definition 9.14. Bottom-up,
\begin{equation*} \begin{aligned} \mathrm{vars}(n_1) &= ABD, & \mathrm{vars}(n_2) &= ABD, & \mathrm{vars}(n_3) &= ABCDE,\\ \mathrm{vars}(n_4) &= ABCDE, & \mathrm{vars}(n_5) &= ABCDEF, & \mathrm{vars}(n_6) &= ABCDEFG, \end{aligned} \end{equation*}
then cutsets top-down:
\begin{equation*} \begin{aligned} \mathrm{cutset}(n_6) &= (ABCDEF \cap EFG) \setminus \emptyset = EF,\\ \mathrm{cutset}(n_5) &= (ABCDE \cap CDF) \setminus EF = CD,\\ \mathrm{cutset}(n_4) &= (ABCDE \cap C) \setminus CDEF = \emptyset,\\ \mathrm{cutset}(n_3) &= (ABD \cap BCE) \setminus CDEF = B,\\ \mathrm{cutset}(n_2) &= (ABD \cap B) \setminus BCDEF = \emptyset,\\ \mathrm{cutset}(n_1) &= (A \cap ABD) \setminus BCDEF = A . \end{aligned} \end{equation*}
With \(\mathrm{context}(T) = \mathrm{vars}(T) \cap \mathrm{acutset}(T)\) and \(\mathrm{cluster}(T) = \mathrm{cutset}(T) \cup \mathrm{context}(T)\) at nonleaves, \(\mathrm{cluster}(T) = \mathrm{vars}(T)\) at leaves, we get
| node | \(\mathrm{cutset}\) | \(\mathrm{context}\) | \(\mathrm{cluster}\) |
|---|---|---|---|
| \(n_6\) | \(EF\) | \(\emptyset\) | \(EF\) |
| \(n_5\) | \(CD\) | \(EF\) | \(CDEF\) |
| \(n_4\) | \(\emptyset\) | \(CDE\) | \(CDE\) |
| \(n_3\) | \(B\) | \(CDE\) | \(BCDE\) |
| \(n_2\) | \(\emptyset\) | \(BD\) | \(BD\) |
| \(n_1\) | \(A\) | \(BD\) | \(ABD\) |
| leaf \(A\) | — | \(A\) | \(A\) |
| leaf \(ABD\) | — | \(ABD\) | \(ABD\) |
| leaf \(B\) | — | \(B\) | \(B\) |
| leaf \(BCE\) | — | \(BCE\) | \(BCE\) |
| leaf \(C\) | — | \(C\) | \(C\) |
| leaf \(CDF\) | — | \(CDF\) | \(CDF\) |
| leaf \(EFG\) | — | \(EF\) | \(EFG\) |
The largest clusters \(CDEF\) and \(BCDE\) have size four, so the dtree has width \(4 - 1 = 3\), meeting the Theorem 9.14 bound \(\mathrm{width}(\pi, G) = 3\).
Consider the networks in Figure 6.6(d) and Figure 6.6(e) on Page 142. Show that the treewidth of these networks is 3. Hint: Use the preprocessing rules for generating optimal elimination prefixes.
Both networks have eleven nodes drawn in two columns. Name the node at the very top \(A\); the left column, top to bottom, is \(B, D, F, H, J\) and the right column, top to bottom, is \(C, E, G, I, K\), so that \(B\) and \(C\) sit on one row, \(D\) and \(E\) on the next, and so on.
The network of Figure 6.6(d) has the edges
\begin{equation*} \begin{aligned} &A \to C, \quad B \to C, \quad C \to E, \quad E \to G, \quad G \to I, \quad I \to K,\\ &B \to D, \quad D \to F, \quad F \to H, \quad H \to J, \quad F \to I, \quad C \to K . \end{aligned} \end{equation*}
That is: two parallel chains \(B \to D \to F \to H \to J\) and \(C \to E \to G \to I \to K\), the extra root \(A \to C\), the cross edge \(B \to C\), the cross edge \(F \to I\), and the long edge \(C \to K\).
The network of Figure 6.6(e) has all of these edges plus the two further cross edges
\begin{equation*} B \to E, \qquad D \to G . \end{equation*}
Both reduce under the preprocessing rules to a \(K_4\), so both have treewidth \(3\).
Work in the moral graphs \(G_d^m\), \(G_e^m\), widths with respect to a DAG being widths with respect to its moral graph (Definition 9.5). The multi-parent nodes are \(C\) (\(A, B\)), \(I\) (\(G, F\)), \(K\) (\(I, C\)) in \(G_d\), joined by \(E\) (\(C, B\)) and \(G\) (\(E, D\)) in \(G_e\), so moralization adds \(A - B\), \(F - G\), \(C - I\), plus \(D - E\) in \(G_e\) (\(B - C\) is already there):
| node | in \(G_d^m\) | in \(G_e^m\) |
|---|---|---|
| \(A\) | \(B, C\) | \(B, C\) |
| \(B\) | \(A, C, D\) | \(A, C, D, E\) |
| \(C\) | \(A, B, E, I, K\) | \(A, B, E, I, K\) |
| \(D\) | \(B, F\) | \(B, E, F, G\) |
| \(E\) | \(C, G\) | \(B, C, D, G\) |
| \(F\) | \(D, G, H, I\) | \(D, G, H, I\) |
| \(G\) | \(E, F, I\) | \(D, E, F, I\) |
| \(H\) | \(F, J\) | \(F, J\) |
| \(I\) | \(C, F, G, K\) | \(C, F, G, K\) |
| \(J\) | \(H\) | \(H\) |
| \(K\) | \(C, I\) | \(C, I\) |
The Section 9.3.2 invariant is \(\mathrm{treewidth}(G) = \max(\mathrm{treewidth}(G^{\prime}), low)\), the eliminated variables forming an optimal prefix; start at \(low = 1\), each graph having an edge. In both graphs the twig rule takes \(J\) then \(H\) (degree \(1\), \(low = 1\)), and the simplicial rule takes \(A\) (neighbours \(B, C\) with \(B - C\)) and \(K\) (neighbours \(C, I\) with \(C - I\)), raising \(low\) to \(2\) and adding no fill-in.
(i) Figure 6.6(d). What remains on \(B, C, D, E, F, G, I\) is
\begin{equation*} \begin{aligned} B &: C, D & C &: B, E, I & D &: B, F & E &: C, G\\ F &: D, G, I & G &: E, F, I & I &: C, F, G . \end{aligned} \end{equation*}
Here \(B\), \(D\), \(E\) have degree \(2\), hence are almost simplicial (a single neighbour is trivially a clique), so with \(low = 2\) the series rule eliminates each, with fill-ins \(C - D\), \(C - F\), \(C - G\) respectively. This leaves \(K_4\) on \(\{C, F, G, I\}\), of treewidth exactly \(3\) (at least \(3\) by Theorem 9.1, at most \(3\) since any order gives clusters \(4, 3, 2, 1\)). By the invariant,
\begin{equation*} \mathrm{treewidth}(G_d^m) = \max(3, low) = \max(3, 2) = 3 . \end{equation*}
The prefix, completed by the four survivors, is
\begin{equation*} \pi_d = J,\, H,\, A,\, K,\, B,\, D,\, E,\, C,\, F,\, G,\, I, \end{equation*}
whose induced cluster sequence is
\begin{equation*} \begin{aligned} &HJ,\; FH,\; ABC,\; CIK,\; BCD,\; CDF,\\ &CEG,\; CFGI,\; FGI,\; GI,\; I , \end{aligned} \end{equation*}
of maximum size \(4\), so \(\mathrm{width}(\pi_d, G_d) = 3\) and \(\pi_d\) is optimal.
(ii) Figure 6.6(e). After the same four eliminations the remaining \(G^{\prime}\) on \(\{B, C, D, E, F, G, I\}\) is
\begin{equation*} \begin{aligned} B &: C, D, E & C &: B, E, I & D &: B, E, F, G\\ E &: B, C, D, G & F &: D, G, I & G &: D, E, F, I\\ I &: C, F, G . \end{aligned} \end{equation*}
and the rules stall: every degree is \(\ge 3\) and no node is simplicial (\(B\) lacks \(C - D\), \(C\) lacks \(B - I\), and so on), while the almost simplicial rule needs \(low \ge 3\). Raise the bound instead. Since \(J, H, A, K\) were simplicial when eliminated, no fill-in was ever added, so \(G^{\prime}\) is the induced subgraph of \(G_e^m\) on \(\{B, C, D, E, F, G, I\}\), with degrees
\begin{equation*} B \mapsto 3,\quad C \mapsto 3,\quad D \mapsto 4,\quad E \mapsto 4, \end{equation*}
\begin{equation*} F \mapsto 3,\quad G \mapsto 4,\quad I \mapsto 3, \end{equation*}
so \(G^{\prime}\) has degree \(3\) in the sense of Definition 9.7. Degree lower-bounds treewidth (Exercise 9.12) and treewidth is subgraph-monotone, so \(\mathrm{treewidth}(G_e^m) \ge \mathrm{treewidth}(G^{\prime}) \ge 3\) and we may set \(low = 3\), which unlocks the almost simplicial rule at degree \(3\).
\(C\) (neighbours \(B, E, I\)) is almost simplicial: discarding \(I\) leaves the clique \(\{B, E\}\), since \(B - E\) is one of the two extra edges of Figure 6.6(e). Eliminating it adds fill-ins \(B - I\), \(E - I\):
\begin{equation*} \begin{aligned} B &: D, E, I & D &: B, E, F, G & E &: B, D, G, I\\ F &: D, G, I & G &: D, E, F, I & I &: B, E, F, G . \end{aligned} \end{equation*}
Now \(B\) (neighbours \(D, E, I\)) is almost simplicial, \(\{D, E\}\) being a clique; eliminating it adds \(D - I\):
\begin{equation*} \begin{aligned} D &: E, F, G, I & E &: D, G, I & F &: D, G, I\\ G &: D, E, F, I & I &: D, E, F, G . \end{aligned} \end{equation*}
Then \(E\) (neighbours \(D, G, I\), pairwise adjacent) is simplicial of degree \(3\), so it goes with no fill-in and \(low = 3\). The remainder on \(\{D, F, G, I\}\) carries all six edges, again a \(K_4\) of treewidth \(3\), so by the invariant
\begin{equation*} \mathrm{treewidth}(G_e^m) = \max(3, low) = \max(3, 3) = 3 . \end{equation*}
The resulting order is
\begin{equation*} \pi_e = J,\, H,\, A,\, K,\, C,\, B,\, E,\, D,\, F,\, G,\, I, \end{equation*}
with induced cluster sequence
\begin{equation*} \begin{aligned} &HJ,\; FH,\; ABC,\; CIK,\; BCEI,\; BDEI,\\ &DEGI,\; DFGI,\; FGI,\; GI,\; I , \end{aligned} \end{equation*}
whose largest clusters have four variables, so \(\mathrm{width}(\pi_e, G_e) = 3\).
Show that the leaf nodes of a Bayesian network represent a prefix for an optimal elimination order.
Here a leaf node of a Bayesian network is a node of its DAG that has no children, and a prefix \(\tau\) of an elimination order \(\pi\) is a sequence of variables occurring at the beginning of \(\pi\); \(\tau\) is an optimal elimination prefix when it can be completed into an elimination order of width equal to the treewidth.
Every leaf of the DAG \(G\) is simplicial in the moral graph \(G^m\), and distinct leaves are nonadjacent there, so the simplicial rule of Section 9.3.2 applies to them one after another; any enumeration \(\tau = L_1, \dots, L_k\) of the leaves is thus an optimal prefix. Widths with respect to \(G\) are widths with respect to \(G^m\) (Definition 9.5), so it suffices to argue in \(G^m\).
Simpliciality: a leaf \(X\) has no children, so the DAG edges at \(X\) are exactly \(U \to X\) for \(U \in \mathrm{Parents}(X)\), and \(X\) is never married as a co-parent; hence
\begin{equation*} \mathrm{Neighbours}_{G^m}(X) = \mathrm{Parents}(X), \end{equation*}
which moralizing the family of \(X\) makes a clique. So \(X\) is simplicial of degree \(d_X = |\mathrm{Parents}(X)|\).
Nonadjacency: for leaves \(X \ne Y\), neither is a parent of the other and neither is a co-parent of anything, so \(X - Y \notin G^m\). Eliminating \(X\) therefore removes no neighbour of \(Y\), and being simplicial it adds no fill-in at all, so \(Y\) is still simplicial with the same neighbourhood. Inductively, after \(L_1, \dots, L_{i-1}\) the node \(L_i\) remains simplicial with neighbourhood \(\mathrm{Parents}(L_i)\), no fill-in has appeared, the cluster induced at step \(i\) is the family \(\{L_i\} \cup \mathrm{Parents}(L_i)\), and the graph left is \(G^m \setminus L\).
The simplicial rule of Section 9.3.2 is thus licensed at each of the \(k\) steps, its invariant giving both optimality of the prefix and
\begin{equation*} \mathrm{treewidth}(G^m) = \max\Bigl(\max_{i} |\mathrm{Parents}(L_i)|,\; \mathrm{treewidth}(G^m \setminus L)\Bigr). \qquad \blacksquare \end{equation*}
Exercises 9.8–9.14
Show that the root nodes of a Bayesian network, which have a single child each, represent a prefix for an optimal elimination order.
Each single-child root is simplicial in the moral graph \(G^m\), so the simplicial rule of Section 9.3.2 applies to them in turn, exactly as for the leaves in Exercise 9.7. Widths with respect to \(G\) are widths with respect to \(G^m\) (Definitions 9.2 and 9.5).
Let \(X\) be a root whose only child is \(C\). Its neighbours in \(G^m\) are its parents (none), its children (just \(C\)) and its spouses, the other parents of \(C\), so
\begin{equation*} N_{G^m}(X) \;=\; \{C\} \cup \bigl(\mathrm{Pa}( C) \setminus \{X\}\bigr), \end{equation*}
a clique: moralization retains every edge \(U \to C\) and marries all parents of \(C\). Hence \(X\) is simplicial.
Let \(X_1, \dots, X_k\) be all such roots, in any order, and put \(G^m_j = G^m - X_1 - \cdots - X_{j-1}\). Inductively, no fill-in has been added, so \(G^m_j\) is the induced subgraph of \(G^m\) on the survivors and
\begin{equation*} N_{G^m_j}(X_j) \;=\; N_{G^m}(X_j) \setminus \{X_1,\ldots,X_{j-1}\}, \end{equation*}
a subset of a \(G^m\)-clique and hence a clique of \(G^m_j\), since deleting nodes destroys no edges among the survivors. So \(X_j\) is simplicial in \(G^m_j\) and its elimination again adds no fill-in.
Applying the simplicial rule \(k\) times therefore yields an optimal elimination order of \(G^m\) beginning \(X_1, \dots, X_k\), and the choice of order among them is immaterial by Theorem 9.2. \(\blacksquare\)
The preprocessing rules of Section 9.3.2 include the following two special cases of the Simplicial rule:
- Islet rule
- Eliminate nodes with degree 0.
- Twig rule
- Eliminate nodes with degree 1.
Show that the Islet and Twig rules are complete for graphs with treewidth 1; that is, they are sufficient to generate optimal elimination orders for such graphs.
A graph of treewidth \(\le 1\) is a forest, on which one of the two rules always fires and never creates fill-in, so the order they generate has width \(\le 1\) and is optimal.
Cycles force treewidth \(\ge 2\): let \(Z_1 - \cdots - Z_m - Z_1\) be a cycle (\(m \ge 3\)), let \(\pi\) be any order, and let \(i\) be the first step eliminating a cycle node \(X = \pi(i) = Z_t\), with distinct cycle neighbours \(U = Z_{t-1}\), \(W = Z_{t+1}\) still present in \(G_i\). Elimination only adds edges and deletes the eliminated node (Definition 9.3), so \(X - U\) and \(X - W\) survive in \(G_i\) and
\begin{equation*} C_i \;\supseteq\; \{X, U, W\}, \qquad |C_i| \ge 3, \end{equation*}
so \(\mathrm{width}(\pi,G) \ge 2\) (Definition 9.5) and, \(\pi\) being arbitrary, \(\mathrm{treewidth}(G) \ge 2\) (Definition 9.6). Contrapositively, \(\mathrm{treewidth}(G) \le 1\) makes \(G\) a forest.
A nonempty forest has a node of degree \(\le 1\): with no edges every degree is \(0\); otherwise an endpoint \(v\) of a longest path has no neighbour off the path (it would extend it) and none on the path but its predecessor (it would close a cycle), so \(\deg(v) = 1\). One of the two rules therefore always fires, and eliminating a node of degree \(d \le 1\) creates no fill-in (no nonadjacent neighbour pair exists), leaving the forest \(F - X\) and a cluster of size \(d + 1 \le 2\).
Iterating to the empty graph gives an order \(\pi\) with all clusters of size \(\le 2\), so \(\mathrm{width}(\pi, G) \le 1\). If \(G\) has an edge then \(\mathrm{treewidth}(G) \ge 1\) by Theorem 9.1, forcing \(\mathrm{width}(\pi,G) = \mathrm{treewidth}(G) = 1\) since no width falls below the treewidth; if \(G\) has none, every cluster is a singleton and both are \(0\). Either way \(\pi\) is optimal. \(\blacksquare\)
The preprocessing rules of Section 9.3.2 operate on an undirected graph while maintaining a value \(\mathrm{low}\) that is a lower bound on the treewidth of the original graph. Three of the rules are:
- Islet rule
- Eliminate nodes with degree 0.
- Twig rule
- Eliminate nodes with degree 1.
- Series rule
- Eliminate nodes with degree 2 if \(\mathrm{low} \ge 2\).
Show that the Islet, Twig, and Series rules are complete for graphs with treewidth 2; that is, they are sufficient to generate optimal elimination orders for such graphs.
On a graph \(G\) with \(\mathrm{treewidth}(G) \le 2\) the three rules never stall and the order they generate is optimal. Three ingredients.
(i) A nonempty graph has a node of degree at most its treewidth, since the degree of a graph lower-bounds its treewidth (Exercise 9.12); so a nonempty graph of treewidth \(\le 2\) offers a node of degree \(0\), \(1\) or \(2\).
(ii) Eliminating a node \(X\) of degree \(d \le 2\) in \(H\) yields a minor \(H^{\prime}\) (Definition 9.3).
- If \(d \le 1\) there is no nonadjacent pair of neighbors, so no fill-in is added and \(H^{\prime} = H - X\), a subgraph of \(H\).
- If \(d = 2\) with neighbors \(U, W\), then \(H^{\prime}\) is \(H - X\) together with the single fill-in edge \(U - W\) (absent when \(U\) and \(W\) are already adjacent, in which case \(H^{\prime} = H - X\)). But \(H^{\prime}\) is exactly the graph obtained from \(H\) by contracting the edge \(X - U\): contraction replaces \(X\) and \(U\) by a node adjacent to
\begin{equation*} \bigl(N(X) \cup N(U)\bigr) \setminus \{X,U\} \;=\; \{W\} \cup \bigl(N(U)\setminus\{X\}\bigr), \end{equation*}
and renaming that node \(U\) gives precisely \(H - X\) plus the edge \(U-W\).
So \(H^{\prime}\) is a minor of \(H\) (Definition 9.9), and since deleting nodes cannot raise the treewidth (restrict any order: every cluster shrinks) while contraction cannot either (Exercise 9.13),
\begin{equation*} \mathrm{treewidth}(H^{\prime}) \;\le\; \mathrm{treewidth}(H). \end{equation*}
(iii) Minimum degree \(\ge 2\) forces a cycle, hence treewidth \(\ge 2\) by Exercise 9.9: take a longest path, let \(v\) be an endpoint and \(u\) its predecessor; \(v\) has a neighbour \(w \ne u\), which cannot lie off the path (it would extend it), so the path segment from \(w\) to \(v\) closes into a cycle of length \(\ge 3\).
Now run from \(H_1 = G\) with any sound initial \(\mathrm{low}\). At each stage \(H_i\) is a minor of \(G\), so \(\mathrm{treewidth}(H_i) \le 2\) by (ii), and if nonempty it has a node of degree \(\le 2\) by (i).
- If it has a node of degree \(0\) or \(1\), fire the Islet or Twig rule.
- Otherwise the minimum degree is exactly 2, so \(\mathrm{treewidth}(G) \ge \mathrm{treewidth}(H_i) \ge 2\) by (iii) and minor-monotonicity; \(\mathrm{low} \leftarrow 2\) is sound and the Series rule fires.
Either way one node goes, so the run terminates after \(n\) steps with an order \(\pi\) whose every cluster is \(\{X\} \cup N_{H_i}(X)\) for some \(X\) of degree \(\le 2\), of size \(\le 3\); hence
\begin{equation*} \mathrm{width}(\pi, G) \;\le\; 2 \end{equation*}
by Definition 9.5. Two cases match this to the treewidth. (i) \(G\) a forest: every \(H_i\) is then a forest with a node of degree \(\le 1\) (Exercise 9.9), so the Series rule never fires and the run is that of Exercise 9.9, giving \(\mathrm{width}(\pi,G) = \mathrm{treewidth}(G) \in \{0,1\}\). (ii) \(G\) not a forest: it has a cycle, so \(\mathrm{treewidth}(G) \ge 2\) by Exercise 9.9, hence \(= 2\), and as no width falls below the treewidth,
\begin{equation*} 2 \;\le\; \mathrm{width}(\pi,G) \;\le\; 2 . \end{equation*}
Either way \(\pi\) is optimal. \(\blacksquare\)
The min-degree elimination heuristic of Section 9.3.1 repeatedly eliminates a node having the smallest number of neighbors in the current graph. Show that the min-degree heuristic is optimal for graphs with treewidth \(\le 2\); that is, on such graphs the order it generates has width equal to the treewidth.
Every graph in the min-degree run keeps treewidth \(\le 2\), which caps every cluster at size \(3\).
Let \(\pi\) be a min-degree order on \(G\) with \(\mathrm{treewidth}(G) \le 2\), with graph sequence \(G_1 = G, \dots, G_n\) and clusters \(C_i\), and put \(d_i = |C_i| - 1\), the minimum degree of \(G_i\) by the heuristic, that is \(\mathrm{degree}(G_i)\) in the sense of Definition 9.7. Inductively, if \(\mathrm{treewidth}(G_i) \le 2\) then \(d_i \le 2\) by Exercise 9.12, so eliminating \(\pi(i)\) yields a minor of \(G_i\) by Exercise 9.10(ii) and \(\mathrm{treewidth}(G_{i+1}) \le \mathrm{treewidth}(G_i) \le 2\) by minor-monotonicity (Exercise 9.13 for the contraction case). Hence \(|C_i| \le 3\) throughout and, by Definition 9.5,
\begin{equation*} \mathrm{width}(\pi, G) \;=\; \max_{i} |C_i| - 1 \;\le\; 2 . \end{equation*}
Since \(\mathrm{width}(\pi,G) \ge \mathrm{treewidth}(G)\) always (Definition 9.6), only a strict gap need be ruled out. (i) \(\mathrm{treewidth}(G) = 2\): the display forces equality. (ii) \(\mathrm{treewidth}(G) \le 1\): then \(G\) is a forest (Exercise 9.9), whose minimum degree is \(\le 1\), so each elimination adds no fill-in and leaves a forest; inductively \(d_i \le 1\) and \(\mathrm{width}(\pi,G) \le 1\), which equals \(1 = \mathrm{treewidth}(G)\) by Theorem 9.1 if \(G\) has an edge and equals \(0\) otherwise. \(\blacksquare\)
Definition 9.7 defines the degree of a graph as the minimum number of neighbors attained by any of its nodes. Show that the degree of a graph is a lower bound on the treewidth of the graph.
The first cluster of any elimination order already witnesses the bound.
Let \(\pi\) be any elimination order for a nonempty \(G\), with clusters \(C_1, \dots, C_n\) (Definition 9.4). Since \(G_1 = G\) carries no fill-in yet,
\begin{equation*} C_1 \;=\; \{\pi(1)\} \cup N_G(\pi(1)), \qquad |C_1| \;=\; 1 + \deg_G(\pi(1)). \end{equation*}
and the width of \(\pi\) is the largest cluster size minus one (Definition 9.5), hence at least \(|C_1| - 1\):
\begin{equation*} \mathrm{width}(\pi,G) \;\ge\; |C_1| - 1 \;=\; \deg_G(\pi(1)) \;\ge\; \min_{v \in V}\deg_G(v) \;=\; \mathrm{degree}(G), \end{equation*}
the last step because \(\pi(1)\) is one of the nodes minimized over. As \(\pi\) was arbitrary, Definition 9.6 gives
\begin{equation*} \mathrm{treewidth}(G) \;=\; \min_{\pi} \mathrm{width}(\pi,G) \;\ge\; \mathrm{degree}(G), \end{equation*}
the required bound. Equivalently: every nonempty graph has a node of degree at most its treewidth, the form used in Exercises 9.10 and 9.11. \(\blacksquare\)
Exercise 9.25 defines a jointree for an undirected graph \(G\) as a pair \((T,C)\), where \(T\) is a tree and \(C\) is a function mapping each node \(i\) of \(T\) to a label \(C_i\), called a cluster, satisfying:
- The cluster \(C_i\) is a set of nodes in graph \(G\).
- For every edge \(X - Y\) in graph \(G\), the variables \(X\) and \(Y\) appear together in some cluster \(C_i\).
- The clusters of tree \(T\) satisfy the jointree property: if a node of \(G\) appears in two clusters \(C_i\) and \(C_j\), it appears in every cluster on the path connecting \(i\) and \(j\) in \(T\).
As in Definition 9.13, the width of a jointree is the size of its largest cluster minus one. Suppose that the treewidth of an undirected graph is the width of its best jointree (one with lowest width). Use this definition of treewidth to show that contracting an edge in a graph does not increase its treewidth. Here, contracting the edge \(X - Y\) means replacing the nodes \(X\) and \(Y\) by a new node \(Z\) that is adjacent to the union of their neighbors, as illustrated in Figure 9.7.
Rename \(X\) and \(Y\) to \(Z\) inside every cluster of an optimal jointree; the same tree then works for the contracted graph, with no cluster larger.
Let \(G^{\prime}\) be \(G\) with the edge \(X - Y\) contracted, so its nodes are \((V(G) \setminus \{X,Y\}) \cup \{Z\}\), its edges being \(A - B\) for edges of \(G\) avoiding \(X, Y\), and \(Z - A\) whenever \(A \notin \{X,Y\}\) neighbours \(X\) or \(Y\) in \(G\). Let \((T, C)\) be a jointree for \(G\) of minimal width \(w = \mathrm{treewidth}(G)\) and define \(C^{\prime}\) on the same \(T\) by
\begin{equation*} C^{\prime}_i \;=\; \begin{cases} \bigl(C_i \setminus \{X,Y\}\bigr) \cup \{Z\}, & \text{if } C_i \cap \{X,Y\} \ne \emptyset,\\ C_i, & \text{otherwise.} \end{cases} \end{equation*}
The three conditions hold for \((T, C^{\prime})\) over \(G^{\prime}\).
(1) Each \(C^{\prime}_i\) drops \(X, Y\) and possibly adds \(Z\), all of whose elements are nodes of \(G^{\prime}\).
(2) An edge \(A - B\) of \(G^{\prime}\) avoiding \(X, Y\) is an edge of \(G\), so lies in some \(C_i\), and both survive renaming; an edge \(Z - A\) comes from an edge \(X - A\) or \(Y - A\) of \(G\), whose cluster \(C_i\) renames to one containing \(Z\) and \(A\).
(3) For \(A \ne Z\) the renaming touches nothing, so \(\{i : A \in C^{\prime}_i\} = \{i : A \in C_i\}\) is connected. For \(Z\), write
\begin{equation*} T_X = \{\, i : X \in C_i \,\}, \qquad T_Y = \{\, i : Y \in C_i \,\}, \end{equation*}
so that by construction
\begin{equation*} \{\, i : Z \in C^{\prime}_i \,\} \;=\; \{\, i : C_i \cap \{X,Y\} \ne \emptyset \,\} \;=\; T_X \cup T_Y . \end{equation*}
Each of \(T_X\), \(T_Y\) is a connected subtree by the jointree property for \((T,C)\), and they meet: \(X - Y\) being an edge of \(G\), some \(C_k\) holds both, so \(k \in T_X \cap T_Y\). Two connected subtrees sharing a node have connected union – for \(i \in T_X\), \(j \in T_Y\), the \(i\)-to-\(k\) path stays in \(T_X\) and the \(k\)-to-\(j\) path in \(T_Y\), and their concatenation contains the unique \(i\)-to-\(j\) path. So the jointree property holds for \(Z\) too. Finally, for each \(i\),
\begin{equation*} |C^{\prime}_i| \;=\; |C_i| - |C_i \cap \{X,Y\}| + \bigl[\, C_i \cap \{X,Y\} \ne \emptyset \,\bigr] \;\le\; |C_i|, \end{equation*}
the bracketed indicator being at most \(|C_i \cap \{X,Y\}|\) when that intersection is nonempty and both sides vanishing otherwise. So \(\mathrm{width}(T,C^{\prime}) \le w\), and as the treewidth of \(G^{\prime}\) is the width of its best jointree,
\begin{equation*} \mathrm{treewidth}(G^{\prime}) \;\le\; w \;=\; \mathrm{treewidth}(G). \qquad \blacksquare \end{equation*}
Definition 9.7 defines the degree of a graph as the minimum number of neighbors attained by any of its nodes, and Definition 9.8 defines the degeneracy of a graph as the maximum degree attained by any of its subgraphs. Show that the degeneracy of a graph can be computed by generating a sequence of subgraphs, starting with the original graph, and then generating the next subgraph by removing a minimum-degree node. The degeneracy is then the maximum degree attained by any of the generated subgraphs.
The maximum \(M\) returned by the min-degree removal sequence equals \(\mathrm{degeneracy}(G)\). The procedure generates
\begin{equation*} G \;=\; H_1,\ H_2,\ \ldots,\ H_n, \qquad H_{i+1} \;=\; H_i - v_i , \end{equation*}
where \(v_i\) is a node of minimum degree in \(H_i\), and returns
\begin{equation*} M \;=\; \max_{1 \le i \le n} \mathrm{degree}(H_i) \;=\; \max_{1 \le i \le n} \deg_{H_i}(v_i), \end{equation*}
the two agreeing since \(v_i\) has minimum degree in \(H_i\), and Definition 9.8 makes \(\mathrm{degeneracy}(G) = \max_H \mathrm{degree}(H)\) over nonempty subgraphs.
The maximum is attained at an induced subgraph: a nonempty subgraph \(H\) with \(S = V(H)\) sits inside \(G[S]\), so \(\deg_H(v) \le \deg_{G[S]}(v)\) on \(S\) and
\begin{equation*} \mathrm{degree}(H) \;\le\; \mathrm{degree}(G[S]). \end{equation*}
so only the \(G[S]\) matter.
\(M \le \mathrm{degeneracy}(G)\): each \(H_i = G[V(H_i)]\) is a nonempty subgraph of \(G\), so \(\mathrm{degeneracy}(G) \ge \mathrm{degree}(H_i)\) by Definition 9.8, and the maximum over \(i\) is \(M\).
\(M \ge \mathrm{degeneracy}(G)\): fix \(S \ne \emptyset\), put \(\delta = \mathrm{degree}(G[S])\), and let
\begin{equation*} i \;=\; \min\{\, j : v_j \in S \,\} \end{equation*}
be the step removing the first node of \(S\) (every node is removed exactly once). By minimality \(S \subseteq V(H_i)\), so \(G[S]\) is an induced subgraph of \(H_i\) containing \(v_i\) and \(\deg_{G[S]}(v_i) \le \deg_{H_i}(v_i)\), restricting to \(S\) only dropping neighbours. Since \(v_i\) is one of the nodes \(\delta\) minimizes over,
\begin{equation*} \delta \;=\; \mathrm{degree}(G[S]) \;\le\; \deg_{G[S]}(v_i) \;\le\; \deg_{H_i}(v_i) \;=\; \mathrm{degree}(H_i) \;\le\; M . \end{equation*}
the penultimate equality being precisely where the min-degree choice is used: \(v_i\) realizes \(\mathrm{degree}(H_i)\). Maximizing over \(S\) gives \(\mathrm{degeneracy}(G) \le M\), so \(M = \mathrm{degeneracy}(G)\). \(\blacksquare\)
Exercises 9.15–9.21
Show the following about Algorithm 20, BFS OEO: at no point during the search can we have a node \((G_\rho, \rho, w_\rho, b_\rho)\) on the open list and another node \((G_{\rho^{\prime}}, \rho^{\prime}, w_{\rho^{\prime}}, b_{\rho^{\prime}})\) on the closed list where \(G_\rho = G_{\rho^{\prime}}\).
Recall Algorithm 20, BFS OEO, which searches for an optimal elimination order of a graph \(G\) with \(n\) nodes. A search node is a tuple \((G_\tau, \tau, w_\tau, b_\tau)\): \(\tau\) is an elimination prefix, \(G_\tau\) is the subgraph obtained by applying \(\tau\) to \(G\), \(w_\tau\) is the width of the prefix, and \(b_\tau\) is a lower bound on \(\mathrm{treewidth}(G_\tau)\). The algorithm initializes the open list to \(OL = \{(G, \tau, 0, b)\}\) with \(\tau\) empty, and the closed list \(CL\) to empty. While \(OL\) is nonempty it removes from \(OL\) a node \((G_\tau, \tau, w_\tau, b_\tau)\) minimizing \(\max(w_\tau, b_\tau)\); if \(G_\tau\) is empty it returns \(\tau\); otherwise, for every variable \(X\) of \(G_\tau\) it forms the child \((G_\rho, \rho, w_\rho, b_\rho)\) obtained by eliminating \(X\), and then:
- if \(OL\) contains a node \((G_{\rho^{\prime}}, \rho^{\prime}, w_{\rho^{\prime}}, b_{\rho^{\prime}})\) with \(G_{\rho^{\prime}} = G_\rho\), then that node is replaced by the new child when \(w_\rho < w_{\rho^{\prime}}\) and the new child is discarded otherwise;
- else if \(CL\) contains no node whose subgraph equals \(G_\rho\), the child is added to \(OL\);
- otherwise (a node with subgraph \(G_\rho\) sits on \(CL\)) the child is discarded.
Finally the expanded node \((G_\tau, \tau, w_\tau, b_\tau)\) is added to \(CL\).
The claim is the second half of a loop invariant: (A) no two \(OL\) nodes share a subgraph; (B) no \(OL\) node shares a subgraph with a \(CL\) node. Both hold initially, \(OL\) being a singleton and \(CL\) empty. Note that a search node’s subgraph depends only on the set of eliminated variables (Theorem 9.2), which is what makes the duplicate tests meaningful, and that eliminating a variable deletes exactly that variable (Definition 9.3), so a child \(\rho\) of \(\tau\) has \(|G_\rho| = |G_\tau| - 1\) and hence
\begin{equation*} G_\rho \ne G_\tau \quad\text{for every child } \rho \text{ of } \tau , \end{equation*}
expansion being entered only for nonempty \(G_\tau\).
Assume (A) and (B) at the start of an iteration whose chosen node \((G_\tau, \tau, w_\tau, b_\tau)\) is expanded (otherwise the algorithm returns).
(A) survives: \(OL\) changes only by the replacement on Lines 18–19, which keeps the count of \(G_\rho\)-nodes at one and touches no other subgraph, and by the insertion on Line 22, reached only when Line 16 found no \(G_\rho\)-node on \(OL\), raising that count from zero to one.
(B) survives insertion into \(OL\): a child inserted on Line 19 has \(OL\) already carrying \(G_\rho\), so (B) puts no \(G_\rho\)-node on \(CL\); a child inserted on Line 22 has passed the Line 21 guard, which checks exactly that. These are the only ways into \(OL\).
(B) survives insertion into \(CL\) on Line 25: the chosen node was the only \(OL\) node with subgraph \(G_\tau\) by (A), and was removed on Line 6, while every node added to \(OL\) during the expansion is a child, with \(G_\rho \ne G_\tau\) by the display. So no \(OL\) node carries \(G_\tau\) when Line 25 runs.
Nodes never leave \(CL\) and no other line touches either list, so (A) and (B) persist. \(\blacksquare\)
Show that Algorithm 20, BFS OEO, will not choose a node \((G_\tau, \tau, w_\tau, b_\tau)\) from the open list where \(\tau\) is a complete yet suboptimal elimination order.
Recall from Exercise 9.15 the structure of Algorithm 20: search nodes are tuples \((G_\tau, \tau, w_\tau, b_\tau)\) where \(\tau\) is an elimination prefix of the input graph \(G\), \(G_\tau\) is the subgraph obtained by applying \(\tau\) to \(G\), \(w_\tau\) is the width of the prefix, and \(b_\tau\) is a lower bound on \(\mathrm{treewidth}(G_\tau)\). Each iteration removes from the open list a node minimizing \(\max(w_\tau, b_\tau)\), returns \(\tau\) if \(G_\tau\) is empty, and otherwise generates one child per variable \(X\) of \(G_\tau\), with \(w_\rho = \max(w_\tau, d)\) where \(d\) is the number of neighbors of \(X\) in \(G_\tau\); duplicates are resolved against the open and closed lists as described in Exercise 9.15, and the expanded node is moved to the closed list.
Every node the algorithm selects satisfies \(f = \max(w_\sigma, b_\sigma) \le w^\star = \mathrm{treewidth}(G)\), so a selected complete order has \(w_\tau \le w^\star\) and is optimal.
Fix an optimal order \(\pi = \pi(1), \dots, \pi(n)\), and for \(0 \le k \le n\) let \(H_k\) be the subgraph left by the prefix \(\pi(1), \dots, \pi(k)\), so \(H_0 = G\) and \(H_n\) is empty.
Fact 1 (width decomposition). By Definition 9.4 the graph and cluster sequences induced by \(\sigma\rho\) on \(G\) split into those of \(\sigma\) on \(G\) followed by those of \(\rho\) on \(G_\sigma\), so by Definition 9.5
\begin{equation*} \mathrm{width}(\sigma\rho, G) = \max\bigl(w_\sigma,\ \mathrm{width}(\rho, G_\sigma)\bigr) \;\ge\; \max(w_\sigma, b_\sigma), \end{equation*}
using \(\mathrm{width}(\rho, G_\sigma) \ge \mathrm{treewidth}(G_\sigma) \ge b_\sigma\); thus \(f\) is admissible. Fact 2: \(\mathrm{treewidth}(H_k) \le w^\star\), since the tail of \(\pi\) eliminates \(H_k\) within width \(w^\star\).
Call \(N = (G_\sigma, \sigma, w_\sigma, b_\sigma)\) good when \(G_\sigma = H_k\) for some \(k\) and \(w_\sigma \le w^\star\). Then \(\sigma\,\pi(k+1)\cdots\pi(n)\) is a complete order (Theorem 9.2) of width \(\le w^\star\) by Fact 1, and \(f(N) \le w^\star\) by Fact 2.
Fact 3 (persistence). Once \(OL \cup CL\) holds a good node with subgraph \(H_k\), it always does: a node leaves \(OL\) only by selection (going to \(CL\)) or by replacement with a same-subgraph node of strictly smaller width, itself good; \(CL\) never loses nodes.
Induct on the iteration index \(t\) for (I1) the node selected at \(t\) has \(f \le w^\star\), and (I2) \(OL\) holds a good node at the start of \(t\). Initially \(OL = \{(G, \varepsilon, 0, b)\}\), good since \(G = H_0\), giving (I2) at \(t = 1\); and (I2) gives (I1) at once, Line 6 minimizing \(f\) over a list containing a node of \(f \le w^\star\).
Expanding a good node \(N^\star = (H_k, \sigma, w_\sigma, b_\sigma)\) with \(H_k\) nonempty yields a good successor. Eliminating \(\pi(k+1)\) from \(H_k\) gives subgraph \(H_{k+1}\) (Theorem 9.2) and width \(w_\rho = \max(w_\sigma, d)\), where \(\pi(k+1)\) together with its \(d\) neighbours in \(H_k\) is exactly the cluster \(C_{k+1}\) induced by \(\pi\) on \(G\), so \(d = |C_{k+1}| - 1 \le w^\star\) and the child is good. Lines 16–23 then either update the \(OL\) node for \(H_{k+1}\) to width \(\min(w_\rho, w_{\rho^{\prime}}) \le w^\star\), or insert the good child, or discard it because \(CL\) holds an \(H_{k+1}\)-node, which was selected earlier and so has width \(\le f \le w^\star\) by (I1). All three leave a good \(H_{k+1}\)-node in \(OL \cup CL\).
For (I2) at \(t+1\), assuming the algorithm did not return at \(t\), put
\begin{equation*} J = \{\, k : OL \cup CL \text{ contains a good node with subgraph } H_k \,\}, \end{equation*}
at the start of iteration \(t+1\). Then \(0 \in J\) by Fact 3, so \(k = \max J\) exists; let \(M\) be a good \(H_k\)-node in \(OL \cup CL\). Were \(M \in CL\), Exercise 9.15 would put no \(H_k\)-node at all on \(OL\); also \(k < n\), an \(H_n\)-node never reaching \(CL\) since selecting it returns. But \(M\) reached \(CL\) by being selected and expanded while good (width \(\le f \le w^\star\) by (I1)), so by the previous paragraph and Fact 3 a good \(H_{k+1}\)-node survives, contradicting maximality of \(k\). Hence \(M \in OL\), which is (I2).
Now let a selected node have \(\tau\) complete, so \(G_\tau\) is empty and \(b_\tau \le 0 \le w_\tau\), giving \(f = w_\tau \le w^\star\) by (I1). Since \(w_\tau = \mathrm{width}(\tau, G) \ge \mathrm{treewidth}(G) = w^\star\) (Definition 9.6), \(w_\tau = w^\star\) and \(\tau\) is optimal. \(\blacksquare\)
Prove the correctness of Algorithm 21, JT2EO. One way to prove this is to bound the size of factors constructed by the elimination Algorithm VE PR from Chapter 6 while using the elimination order generated by JT2EO.
Algorithm 21, JT2EO, takes a jointree \((T, \mathbf{C})\) for a DAG \(G\) (Definition 9.13) and returns an elimination order as follows. It starts with an empty order \(\pi\); while tree \(T\) has more than one node, it removes a node \(i\) that has a single neighbor \(j\) and appends the variables \(C_i \setminus (C_i \cap C_j)\) to \(\pi\) (in any order); when a single node \(r\) remains, it appends the variables of \(C_r\) to \(\pi\) and returns \(\pi\). Correctness means: \(\pi\) is an elimination order for \(G\) and \(\mathrm{width}(\pi, G)\) is no greater than the width of the jointree, where the width of a jointree is the size of its largest cluster minus one, and \(\mathrm{width}(\pi, G)\) is the width of \(\pi\) with respect to the moral graph \(G^m\) of \(G\) (Definitions 9.1, 9.2, and 9.5).
Every factor VE PR builds under the order \(\pi\) returned by JT2EO lives inside a jointree cluster, so \(\mathrm{width}(\pi, G) \le w\), the jointree width.
JT2EO removes leaves one at a time, so the remaining tree is always a subtree of \(T\), and since a path in a subtree is the path in \(T\), the jointree property (Definition 9.13) holds at every stage.
\(\pi\) is an elimination order. Let \(T_X = \{i : X \in C_i\}\), a connected subtree. When JT2EO removes \(i \in T_X\) with sole neighbour \(j\): if some other remaining node \(k\) lies in \(T_X\), the path from \(i\) to \(k\) starts with \(i - j\), so \(X \in C_j\) and \(X\) is not appended; otherwise \(X \notin C_j\) and \(X\) is appended now. So \(X\) is appended exactly once, when the last node of \(T_X\) goes (or with \(C_r\) if that node is the survivor \(r\)). Every variable lies in its own family, hence in some cluster (Definition 9.13), so \(\pi\) lists all variables exactly once.
The width claim reduces to a bound on VE factors. Run VE PR on any network with DAG \(G\) using \(\pi\), with empty query and evidence, so the initial factors are the CPTs. By Definition 6.4, their interaction graph is the moral graph \(G^m\), since \(\mathrm{vars}(f_X)\) is the family of \(X\) and making each family a clique is moralization (Definition 9.1). The two observations after Definition 6.4 say that eliminating \(\pi(i)\) builds a factor over \(\pi(i)\) and its current neighbours, and that the new interaction graph connects those neighbours pairwise and deletes \(\pi(i)\) – exactly graph elimination (Definition 9.3). Inductively the interaction graph before step \(i\) is \(G_i\) and the factor built has variable set \(C_i^{\pi}\), so
\begin{equation*} \mathrm{width}(\pi, G) \;=\; \max_i |C_i^\pi| - 1 \;=\; \bigl(\text{largest number of variables in a constructed factor}\bigr) - 1 , \end{equation*}
and it suffices to confine every constructed factor to a cluster.
Every family lies in some cluster (Definition 9.13), so assign each CPT \(f_X\) to a node \(i\) with \(\mathrm{vars}(f_X) \subseteq C_i\), and run JT2EO and VE PR in lockstep under the invariant
(INV) every factor held at a node \(i\) of the remaining tree has its variables inside \(C_i\),
which holds initially. Let JT2EO remove leaf \(i\) with sole neighbour \(j\), so VE PR eliminates \(V = C_i \setminus (C_i \cap C_j)\) in some order, and let \(X \in V\). No remaining cluster but \(C_i\) contains \(X\), so by (INV) no factor away from \(i\) mentions \(X\), and eliminating \(X\) multiplies exactly the factors at \(i\), building a factor inside \(C_i\) and leaving \(\sum_X \prod f_k\) inside \(C_i \setminus \{X\}\) at node \(i\). The argument repeats down \(V\), and the surviving factor lands inside \(C_i \setminus V = C_i \cap C_j \subseteq C_j\), so moving it to \(j\) restores (INV). When only \(r\) remains, all factors lie inside \(C_r\) and eliminating \(C_r\) builds only subsets of it.
Hence every constructed factor has at most \(|C_i| \le w + 1\) variables, so every \(C_i^\pi\) does, and
\begin{equation*} \mathrm{width}(\pi, G) \;=\; \max_i |C_i^\pi| - 1 \;\le\; w . \qquad \blacksquare \end{equation*}
Consider a cluster sequence \(C_1, \ldots, C_n\) induced by an elimination order \(\pi\) on graph \(G\). Show that it is impossible for a cluster \(C_i\) to be contained in another cluster \(C_j\) where \(j > i\).
Recall Definition 9.4: eliminating nodes from \(G\) according to \(\pi\) induces a graph sequence \(G_1, G_2, \ldots, G_n\) with \(G_1 = G\) and \(G_{i+1}\) the result of eliminating node \(\pi(i)\) from \(G_i\), and a cluster sequence \(C_1, \ldots, C_n\) where \(C_i\) consists of node \(\pi(i)\) together with its neighbors in \(G_i\).
The witness is \(\pi(i)\) itself, which lies in \(C_i\) but is gone by \(G_j\).
The nodes of \(G_k\) are those of \(G\) other than \(\pi(1), \dots, \pi(k-1)\): eliminating a node adds fill-in edges and deletes that node (Definition 9.3), leaving the node set otherwise untouched, so the claim follows by induction from \(G_1 = G\).
Fix \(i < j\). Then \(\pi(i) \in C_i\) by Definition 9.4, while \(C_j\) consists of nodes of \(G_j\), from which \(\pi(i)\) has already been deleted since \(i \le j-1\). Hence
\begin{equation*} \pi(i) \in C_i \quad\text{and}\quad \pi(i) \notin C_j , \end{equation*}
so \(C_i \not\subseteq C_j\). \(\blacksquare\)
Prove Lemma 9.5.
Lemma 9.5 reads: consider a dtree node \(T\) and define \(\mathrm{vars}^\uparrow(T) = \emptyset\) if \(T\) is a root node; otherwise \(\mathrm{vars}^\uparrow(T) = \bigcup_{T^{\prime}} \mathrm{vars}(T^{\prime})\), where \(T^{\prime}\) ranges over the leaf dtree nodes connected to node \(T\) through its parent. We have
\begin{equation*} \begin{aligned} \mathrm{cutset}(T) &= \bigl(\mathrm{vars}(T^l) \cap \mathrm{vars}(T^r)\bigr) \setminus \mathrm{vars}^\uparrow(T), \\ \mathrm{context}(T) &= \mathrm{vars}(T) \cap \mathrm{vars}^\uparrow(T), \\ \mathrm{cluster}(T) &= \bigl(\mathrm{vars}(T^l) \cap \mathrm{vars}(T^r)\bigr) \cup \bigl(\mathrm{vars}(T^l) \cap \mathrm{vars}^\uparrow(T)\bigr) \cup \bigl(\mathrm{vars}(T^r) \cap \mathrm{vars}^\uparrow(T)\bigr), \end{aligned} \end{equation*}
the first and third statements being about nonleaf nodes \(T\). This implies that \(X \in \mathrm{cluster}(T)\) only if \(X \in \mathrm{vars}(T)\).
Recall the definitions of Section 9.5 for a dtree, a full binary tree whose leaves correspond to the families of a DAG: \(\mathrm{vars}(T) = \mathrm{vars}(T^l) \cup \mathrm{vars}(T^r)\) for nonleaf \(T\); \(\mathrm{cutset}(T) = (\mathrm{vars}(T^l) \cap \mathrm{vars}(T^r)) \setminus \mathrm{acutset}(T)\) for nonleaf \(T\); \(\mathrm{acutset}(T) = \bigcup_{T^\star} \mathrm{cutset}(T^\star)\) over the proper ancestors \(T^\star\) of \(T\); \(\mathrm{context}(T) = \mathrm{vars}(T) \cap \mathrm{acutset}(T)\); and \(\mathrm{cluster}(T) = \mathrm{vars}(T)\) for a leaf, \(\mathrm{cutset}(T) \cup \mathrm{context}(T)\) otherwise.
Everything follows from \(\mathrm{acutset}(T) \subseteq U(T)\) and \(\mathrm{vars}(T) \cap U(T) \subseteq \mathrm{acutset}(T)\), where \(U(T) = \mathrm{vars}^\uparrow(T)\).
Note that \(U(T)\) unions \(\mathrm{vars}\) over the leaves outside the subtree of \(T\) (deleting \(T\) leaves exactly the part hanging off its parent), that \(\mathrm{vars}(T)\) unions \(\mathrm{vars}\) over the leaves inside it, and that \(\mathrm{vars}(T) \subseteq \mathrm{vars}(T^p)\).
First inclusion: if \(X \in \mathrm{cutset}(T^\star) \subseteq \mathrm{vars}(T^{\star l}) \cap \mathrm{vars}(T^{\star r})\) for a proper ancestor \(T^\star\), with \(T\) inside the subtree of, say, \(T^{\star l}\), then \(X\) occurs at a leaf under \(T^{\star r}\), which is outside the subtree of \(T\); so \(X \in U(T)\).
Second inclusion: let \(X \in \mathrm{vars}(T) \cap U(T)\), occurring at a leaf \(L\) outside the subtree of \(T\), and let \(T^\star\) be the deepest node whose subtree holds both. Then \(T^\star \ne T\) is a proper ancestor of \(T\), with \(T\) and \(L\) under different children, say \(T^{\star l}\) and \(T^{\star r}\), so upward monotonicity gives \(X \in \mathrm{vars}(T^{\star l}) \cap \mathrm{vars}(T^{\star r})\). Either \(X \in \mathrm{acutset}(T^\star)\), so \(X\) lies in the cutset of an ancestor of \(T\), or \(X \in \mathrm{cutset}(T^\star)\) by definition of cutset; either way \(X \in \mathrm{acutset}(T)\).
Hence \(\mathrm{vars}(T) \cap \mathrm{acutset}(T)\), \(\mathrm{vars}(T) \cap U(T)\) and \(\mathrm{vars}(T) \cap \mathrm{acutset}(T)\) chain into each other, so all coincide:
\begin{equation*} \mathrm{context}(T) = \mathrm{vars}(T) \cap \mathrm{acutset}(T) = \mathrm{vars}(T) \cap U(T). \end{equation*}
For the cutset, take \(T\) nonleaf and abbreviate \(L = \mathrm{vars}(T^l)\), \(R = \mathrm{vars}(T^r)\), \(U = U(T)\), so \(\mathrm{vars}(T) = L \cup R \supseteq L \cap R\). Subtracting a set from a subset of \(\mathrm{vars}(T)\) is subtracting its intersection with \(\mathrm{vars}(T)\), so
\begin{equation*} \begin{aligned} \mathrm{cutset}(T) &= (L \cap R) \setminus \mathrm{acutset}(T) \\ &= (L \cap R) \setminus \bigl(\mathrm{vars}(T) \cap \mathrm{acutset}(T)\bigr) \\ &= (L \cap R) \setminus \bigl(\mathrm{vars}(T) \cap U\bigr) \\ &= (L \cap R) \setminus U , \end{aligned} \end{equation*}
the third equality being the context equation and the last using \(L \cap R \subseteq \mathrm{vars}(T)\). For the cluster, again with \(T\) nonleaf,
\begin{equation*} \mathrm{cluster}(T) = \mathrm{cutset}(T) \cup \mathrm{context}(T) = \bigl((L \cap R) \setminus U\bigr) \cup \bigl((L \cup R) \cap U\bigr), \end{equation*}
so, distributing the second term,
\begin{equation*} \mathrm{cluster}(T) = \bigl((L \cap R) \setminus U\bigr) \cup (L \cap U) \cup (R \cap U). \end{equation*}
which equals \((L \cap R) \cup (L \cap U) \cup (R \cap U)\): \(\subseteq\) is clear, and for \(\supseteq\) only \(L \cap R\) needs covering, an \(X\) there lying in \((L \cap R) \setminus U\) when \(X \notin U\) and in \(L \cap U\) otherwise.
Finally \(\mathrm{cluster}(T) \subseteq \mathrm{vars}(T)\), trivially at a leaf and because all three terms sit inside \(L \cup R\) at a nonleaf. \(\blacksquare\)
Consider a dtree generated from an elimination order \(\pi\) using Algorithm 25. Is it possible for the order not to be consistent with the dtree according to Definition 9.12, that is, the total order \(\pi\) is not compatible with the partial order induced by the dtree? Either show impossibility or provide a concrete example showing such a possibility.
Algorithm 25, EO2DT\((G, \pi)\), works as follows. It initializes a collection \(\Sigma\) of one-node dtrees, one per family of the DAG \(G\). Then, for \(i = 1\) to the length of \(\pi\), it collects the trees \(T_1, \ldots, T_m\) in \(\Sigma\) that contain variable \(\pi(i)\), removes them from \(\Sigma\), and adds \(T = \mathrm{COMPOSE}(T_1, \ldots, T_m)\) to \(\Sigma\); the COMPOSE operator connects the given binary trees arbitrarily into a single binary tree. It finally returns the composition of all trees remaining in \(\Sigma\).
Definition 9.11 says that a variable \(X\) is eliminated at dtree node \(T\) precisely when \(X \in \mathrm{cluster}(T) \setminus \mathrm{context}(T)\), and Theorem 9.3 says each variable is eliminated at a unique node. Definition 9.12 says the dtree induces the partial order in which \(X < Y\) when the node at which \(X\) is eliminated is a descendant of the node at which \(Y\) is eliminated, and \(X = Y\) when the two are eliminated at the same node. A total order is consistent with the dtree when \(X < Y\) in this partial order implies that \(X\) precedes \(Y\) in the total order.
Yes. Take \(G\) on \(X, Y, Z, W\) with edges \(X \to Y\), \(X \to Z\), \(Y \to Z\), \(X \to W\), families
\begin{equation*} L_1 = \{X\}, \quad L_2 = \{X, Y\}, \quad L_3 = \{X, Y, Z\}, \quad L_4 = \{X, W\}, \end{equation*}
and \(\pi = X, Y, Z, W\). At \(i = 1\) the variable \(X\) occurs in all four trees, so EO2DT replaces them by \(\mathrm{COMPOSE}(L_1, L_2, L_3, L_4)\), which may be the vine
\begin{equation*} N_1 = (L_2, L_3), \qquad N_2 = (N_1, L_4), \qquad N_3 = (N_2, L_1), \end{equation*}
rooted at \(N_3\); the later steps see a single tree and change nothing. With \(\mathrm{vars}(N_1) = XYZ\) and \(\mathrm{vars}(N_2) = \mathrm{vars}(N_3) = XYZW\), the Section 9.5 definitions give
| node | vars | cutset | context | cluster | eliminated here |
|---|---|---|---|---|---|
| \(N_3\) | XYZW | X | X | X | |
| \(N_2\) | XYZW | X | X | ||
| \(N_1\) | XYZ | Y | X | XY | Y |
| \(L_1\) | X | X | X | ||
| \(L_2\) | XY | XY | XY | ||
| \(L_3\) | XYZ | XY | XYZ | Z | |
| \(L_4\) | XW | X | XW | W |
The two loaded rows: \(\mathrm{acutset}(N_3) = \emptyset\) and \(\mathrm{cutset}(N_3) = XYZW \cap X = X\), so \(X\) is eliminated at \(N_3\); and since \(\mathrm{cutset}(N_2) = (XYZ \cap XW) \setminus X = \emptyset\) gives \(\mathrm{acutset}(N_1) = X\),
\begin{equation*} \mathrm{cutset}(N_1) = (\mathrm{vars}(L_2) \cap \mathrm{vars}(L_3)) \setminus X = (XY \cap XYZ) \setminus X = Y , \end{equation*}
so \(Y\) is eliminated at \(N_1\), each variable at a unique node as Theorem 9.3 requires. (The remaining rows: Check!)
But \(N_1\) is a descendant of \(N_3\), so Definition 9.12 imposes \(Y < X\), while \(\pi\) places \(X\) first. Hence \(\pi\) is inconsistent with the dtree EO2DT built from it.
Provide a polytime, width-preserving algorithm for converting a jointree into a dtree. Your algorithm should be direct, bypassing the notion of an elimination order.
Recall Definition 9.13: a jointree for a DAG \(G\) is a pair \((T, \mathbf{C})\) where \(T\) is a tree and \(C_i\) is a cluster of nodes of \(G\) for each tree node \(i\), such that every family of \(G\) appears in some cluster and, if a node of \(G\) appears in two clusters \(C_i\) and \(C_j\), it appears in every cluster on the path between \(i\) and \(j\) (the jointree property); the width of the jointree is the size of its largest cluster minus one. Recall Definition 9.14: a dtree for \(G\) is a pair \((T, \mathrm{vars})\) where \(T\) is a full binary tree whose leaves are in one-to-one correspondence with the families of \(G\), with \(\mathrm{vars}(L)\) the corresponding family; \(\mathrm{vars}\), cutsets, contexts, and clusters extend to internal nodes as in Section 9.5, and the width of a dtree is the size of its largest cluster minus one. Width-preserving means the output dtree has width no greater than that of the input jointree.
JT2DT: root the jointree, assign each family to a cluster containing it, and compose each node’s families and child dtrees into a binary tree bottom-up. Let \((T, \mathbf{C})\) have width \(w\), so \(|C_i| \le w+1\).
- Root the jointree at an arbitrary node \(r\), orienting each edge away from \(r\).
- Assign every family \(\mathbf{F}\) of \(G\) to a single tree node \(\mathrm{node}(\mathbf{F})\) with \(\mathbf{F} \subseteq C_{\mathrm{node}(\mathbf{F})}\). Such a node exists by Condition 2 of Definition 9.13; if several qualify, pick any one. Let \(\mathrm{fams}(i)\) be the set of families assigned to node \(i\).
- Discard every rooted subtree that contains no assigned family (such subtrees carry no information); this does not touch the root, since \(G\) has at least one family.
- Process the remaining nodes bottom-up. For node \(i\) with children \(i_1, \ldots, i_k\)
(after step 3) and assigned families \(\mathbf{F}_1, \ldots, \mathbf{F}_m\), let the
components of \(i\) be the fresh dtree leaves \(L_1, \ldots, L_m\) with
\(\mathrm{vars}(L_j) = \mathbf{F}_j\), together with the already-built dtrees
\(D(i_1), \ldots, D(i_k)\). Set
- \(D(i) = \) the unique component, if there is exactly one;
- \(D(i) = \) any full binary tree whose leaves are exactly the components – for instance the vine \(((c_1, c_2), c_3), \ldots)\) – if there are two or more.
- Return \(D( r)\).
Step 3 leaves every surviving node at least one component, so \(D(i)\) is defined; each jointree node and family is touched once, giving linear time and no elimination order. The output is a dtree by Definition 9.14: leaves biject with families, and every Step 4 node has exactly two children.
For the width, set, for a surviving node \(i\),
\begin{equation*} \mathbf{V}_i = \bigcup \{\, \mathbf{F} : \mathrm{node}(\mathbf{F}) \text{ lies in the subtree rooted at } i \,\}, \end{equation*}
\begin{equation*} \mathbf{U}_i = \bigcup \{\, \mathbf{F} : \mathrm{node}(\mathbf{F}) \text{ lies outside the subtree rooted at } i \,\}. \end{equation*}
so that \(\mathrm{vars}(D(i)) = \mathbf{V}_i\) and the final-dtree leaves outside \(D(i)\) carry exactly \(\mathbf{U}_i\). The jointree property gives two facts, both because every path joining a node inside the subtree of \(i\) to one outside (or joining subtrees of two distinct children) passes through \(i\), while each assigned family sits inside its node’s cluster:
- (A) \(X \in \mathbf{V}_{i_a} \cap \mathbf{V}_{i_b}\) for distinct children \(i_a, i_b\) implies \(X \in C_i\);
- (B) \(X \in \mathbf{V}_i \cap \mathbf{U}_i\) implies \(X \in C_i\).
Now every dtree cluster sits inside a jointree cluster. For a leaf \(L_j\) built from \(\mathbf{F}_j\) assigned to \(i\), \(\mathrm{cluster}(L_j) = \mathbf{F}_j \subseteq C_i\). For an internal \(T^\star\) built while composing the components of \(i\), with \(U = \mathrm{vars}^\uparrow(T^\star)\), Lemma 9.5 gives
\begin{equation*} \mathrm{cluster}(T^\star) \subseteq \bigl(\mathrm{vars}(T^{\star l}) \cap \mathrm{vars}(T^{\star r})\bigr) \cup \bigl(\mathrm{vars}(T^{\star l}) \cap U\bigr) \cup \bigl(\mathrm{vars}(T^{\star r}) \cap U\bigr). \end{equation*}
Now \(\mathrm{vars}(T^{\star l})\) and \(\mathrm{vars}(T^{\star r})\) union the \(\mathrm{vars}\) of two disjoint sets of components of \(i\), while \(U\) unions those of the remaining components together with \(\mathbf{U}_i\). So \(X \in \mathrm{cluster}(T^\star)\) lies in at least two distinct members of
\begin{equation*} \{\, \mathbf{F}_1, \ldots, \mathbf{F}_m,\ \mathbf{V}_{i_1}, \ldots, \mathbf{V}_{i_k},\ \mathbf{U}_i \,\}. \end{equation*}
and in each case \(X \in C_i\): (i) if one member is a family \(\mathbf{F}_j\) assigned to \(i\), then \(X \in \mathbf{F}_j \subseteq C_i\); (ii) if they are \(\mathbf{V}_{i_a}\), \(\mathbf{V}_{i_b}\) with \(a \ne b\), by (A); (iii) if they are \(\mathbf{V}_{i_a}\), \(\mathbf{U}_i\), by (B). These exhaust the cases, \(\mathbf{U}_i\) occurring once. So \(\mathrm{cluster}(T^\star) \subseteq C_i\).
Every dtree cluster therefore has at most \(w + 1\) variables, and the dtree has width at most \(w\). \(\blacksquare\)
Exercises 9.22–9.28
Show the following. Given a probability distribution \(\Pr(\mathbf{X})\) that is induced by a Bayesian network and given a corresponding dtree, the distribution can be expressed in the following form:
\begin{equation*} \Pr(\mathbf{X}) \;=\; \frac{\displaystyle\prod_{\text{dtree node } T} \Pr(\mathrm{cluster}(T))} {\displaystyle\prod_{\text{dtree node } T} \Pr(\mathrm{context}(T))} . \end{equation*}
Both products range over all nodes \(T\) of the dtree, leaves included.
The identity is Theorem 9.12 applied to the dtree labelled by its clusters, once separators are recognized as contexts.
\((T, \mathrm{cluster})\) is a jointree for \(G\) by Definition 9.13: each cluster is a set of variables of \(G\); each family appears as \(\mathrm{cluster}(L) = \mathrm{vars}(L)\) at its leaf, the leaves biject with the families; and the jointree property is Theorem 9.10. Hence Theorem 9.12 gives
\begin{equation*} \Pr(\mathbf{X}) \;=\; \frac{\displaystyle\prod_{\text{jointree node } i} \Pr(C_i)} {\displaystyle\prod_{\text{jointree edge } i-j} \Pr(C_i\cap C_j)} . \end{equation*}
whose numerator is already \(\prod_{T}\Pr(\mathrm{cluster}(T))\). In a rooted tree the map \(T \mapsto T - T^p\) bijects the non-root nodes with the edges, and the separator of \(T - T^p\) is \(\mathrm{cluster}(T)\cap\mathrm{cluster}(T^p) = \mathrm{context}(T)\) by Theorem 9.13(e), so
\begin{equation*} \prod_{\text{jointree edge } i-j} \Pr(C_i\cap C_j) \;=\; \prod_{T \ne \text{root}} \Pr(\mathrm{context}(T)). \end{equation*}
The root \(R\) has no ancestors, so \(\mathrm{acutset}( R)=\varnothing\), whence \(\mathrm{context}( R)=\varnothing\) and \(\Pr(\mathrm{context}( R)) = 1\), the marginal over no variables. Multiplying the denominator by it changes nothing:
\begin{equation*} \prod_{T \ne \text{root}} \Pr(\mathrm{context}(T)) \;=\; \prod_{\text{dtree node } T} \Pr(\mathrm{context}(T)). \end{equation*}
Substituting both into the jointree factorization yields
\begin{equation*} \Pr(\mathbf{X}) \;=\; \frac{\displaystyle\prod_{\text{dtree node } T} \Pr(\mathrm{cluster}(T))} {\displaystyle\prod_{\text{dtree node } T} \Pr(\mathrm{context}(T))}, \end{equation*}
which is the required identity. \(\blacksquare\)
For the dtree of Figure 9.28, the clusters and contexts are
| node | cluster | context |
|---|---|---|
| 1 | \(C\) | \(\varnothing\) |
| 2 | \(CEF\) | \(C\) |
| 3 | \(C\) | \(C\) |
| 4 | \(CDEF\) | \(CEF\) |
| 5 | \(EFG\) | \(EF\) |
| 6 | \(CDF\) | \(CDF\) |
| 7 | \(BCDE\) | \(CDE\) |
| 8 | \(BCE\) | \(BCE\) |
| 9 | \(BD\) | \(BD\) |
| 10 | \(B\) | \(B\) |
| 11 | \(ABD\) | \(BD\) |
| 12 | \(ABD\) | \(ABD\) |
| 13 | \(A\) | \(A\) |
so the identity reads
\begin{equation*} \begin{aligned} \Pr(A,\dots,G)=\; &\frac{\Pr( C)\Pr(CEF)\Pr( C)\Pr(CDEF)\Pr(EFG)\Pr(CDF)\Pr(BCDE)} {\Pr( C)\Pr( C)\Pr(CEF)\Pr(EF)\Pr(CDF)\Pr(CDE)\Pr(BCE)}\\ \times\; &\frac{\Pr(BCE)\Pr(BD)\Pr(B)\Pr(ABD)\Pr(ABD)\Pr(A)} {\Pr(BD)\Pr(B)\Pr(BD)\Pr(ABD)\Pr(A)} . \end{aligned} \end{equation*}
in which every nonmaximal cluster cancels against an equal context, leaving
\begin{equation*} \Pr(A,\dots,G)= \frac{\Pr(CDEF)\,\Pr(BCDE)\,\Pr(ABD)\,\Pr(EFG)}{\Pr(CDE)\,\Pr(BD)\,\Pr(EF)} , \end{equation*}
the Theorem 9.12 factorization for the minimal jointree of Exercise 9.3.
Show that a dtree will have width \(\le 4w+1\) if each of its nodes \(T\) satisfies the following conditions:
- The cutset of \(T\) has no more than \(w+1\) variables.
- No more than two thirds of the variables in \(\mathrm{context}(T)\) appear in either \(\mathrm{vars}(T^l)\) or \(\mathrm{vars}(T^r)\).
Here \(w\) is a nonnegative integer, \(T^l\) and \(T^r\) are the left and right children of \(T\), and the second condition is to be read as \(|\mathrm{context}(T)\cap \mathrm{vars}(T^l)| \le \tfrac{2}{3}|\mathrm{context}(T)|\) and \(|\mathrm{context}(T)\cap \mathrm{vars}(T^r)| \le \tfrac{2}{3}|\mathrm{context}(T)|\).
Every cluster satisfies \(|\mathrm{cluster}(T)|\le (w+1)+(3w+1)=4w+2\), so the width, one less than the largest cluster, is at most \(4w+1\). Cutsets at leaves are read as \(\mathrm{cutset}(L)=\mathrm{vars}(L)\setminus\mathrm{acutset}(L)\), which is what makes the first hypothesis a condition on every node; with that reading \(\mathrm{cluster}(T)=\mathrm{cutset}(T)\uplus\mathrm{context}(T)\) at every node (Theorem 9.13(a) at a nonleaf; at a leaf the two sets partition \(\mathrm{vars}(L)\)), so
\begin{equation*} |\mathrm{cluster}(T)| = |\mathrm{cutset}(T)| + |\mathrm{context}(T)| . \end{equation*}
Since \(|\mathrm{cutset}(T)|\le w+1\) by the first hypothesis, only \(|\mathrm{context}(T)|\le 3w+1\) is at issue.
Inheritance. For a child \(T^c\) of a nonleaf \(T\) we have \(\mathrm{acutset}(T^c)=\mathrm{acutset}(T)\cup\mathrm{cutset}(T)\); intersecting with \(\mathrm{vars}(T^c)\) and using \(\mathrm{vars}(T^c)\subseteq\mathrm{vars}(T)\) on the first part and \(\mathrm{cutset}(T)\subseteq\mathrm{vars}(T^l)\cap\mathrm{vars}(T^r)\) on the second,
\begin{equation*} \mathrm{context}(T^c) = \bigl(\mathrm{context}(T)\cap\mathrm{vars}(T^c)\bigr) \uplus \mathrm{cutset}(T), \end{equation*}
disjointly because \(\mathrm{context}(T)\cap\mathrm{cutset}(T)=\varnothing\) by Theorem 9.13(a).
Induction on depth. At the root \(\mathrm{acutset}=\varnothing\), so \(|\mathrm{context}|=0\). Given \(|\mathrm{context}(T)|\le 3w+1\), the second hypothesis yields \(|\mathrm{context}(T)\cap\mathrm{vars}(T^c)|\le\tfrac{2}{3}(3w+1)=2w+\tfrac{2}{3}\), hence \(\le 2w\), a cardinality being an integer and \(2w\) being one too; so by the inheritance identity and the first hypothesis
\begin{equation*} |\mathrm{context}(T^c)| \le 2w + (w+1) = 3w+1 . \qquad \blacksquare \end{equation*}
Use Algorithm BAL DT of Section 9.5.3 to balance the dtree in Figure 9.28.
Figure 9.28 shows a Bayesian network over the variables \(A,\dots,G\) with edges
\begin{equation*} \begin{aligned} &A\to D,\quad B\to D,\quad B\to E,\quad C\to E,\\ &C\to F,\quad D\to F,\quad E\to G,\quad F\to G, \end{aligned} \end{equation*}
so that its families are \(A\), \(B\), \(C\), \(ABD\), \(BCE\), \(CDF\), \(EFG\).
The figure also shows a corresponding dtree whose thirteen nodes are numbered \(1,\dots,13\) and connected as follows (a caterpillar: leaves hang off the single long path \(1,2,4,7,9,11\)):
- node \(1\) (the root) has children \(2\) and \(3\);
- node \(2\) has children \(4\) and \(5\);
- node \(4\) has children \(6\) and \(7\);
- node \(7\) has children \(8\) and \(9\);
- node \(9\) has children \(10\) and \(11\);
- node \(11\) has children \(12\) and \(13\).
The seven leaves carry the families
\begin{equation*} \mathrm{vars}(3)=C,\;\; \mathrm{vars}(5)=EFG,\;\; \mathrm{vars}(6)=CDF,\;\; \mathrm{vars}(8)=BCE, \end{equation*}
\begin{equation*} \mathrm{vars}(10)=B,\;\; \mathrm{vars}(12)=ABD,\;\; \mathrm{vars}(13)=A . \end{equation*}
Recall BAL DT. Label every nonleaf node of the dtree with the empty dtree and every leaf node with itself; take the label-combining operation to be COMPOSE. Then apply tree contraction repeatedly until a single node remains and return its label. One contraction step is a rake (absorb every leaf into its parent) followed by a compress (identify every maximal chain \(N_1,\dots,N_k\) and absorb \(N_i\) into \(N_{i+1}\) for odd \(i\)), where \(N_1,\dots,N_k\) is a chain when \(N_{i+1}\) is the only child of \(N_i\) for \(1\le i<k\) and \(N_k\) has exactly one child and that child is not a leaf.
BAL DT halts after four contraction steps and returns the dtree displayed below. Write \(\langle t_1,t_2\rangle\) for what COMPOSE returns on two nonempty arguments; on the empty dtree it returns the other argument. Nonleaves start labelled empty, leaves with themselves.
(i) Rake the leaves \(3,5,6,8,10,12,13\) into their parents:
\begin{equation*} 1\leftarrow C,\;\; 2\leftarrow EFG,\;\; 4\leftarrow CDF,\;\; 7\leftarrow BCE,\;\; 9\leftarrow B,\;\; 11\leftarrow \langle ABD,A\rangle, \end{equation*}
node \(11\) taking two leaves at once, and leaving the path \(1\to 2\to 4\to 7\to 9\to 11\). Compress: node \(9\) is barred from a chain because its single child \(11\) is now a leaf, so the unique maximal chain is \(1,2,4,7\), and absorbing \(N_i\) into \(N_{i+1}\) for odd \(i\) gives \(2\leftarrow\langle C,EFG\rangle\) and \(7\leftarrow\langle CDF,BCE\rangle\), leaving \(2\to 7\to 9\to 11\).
(ii) Rake \(11\) into \(9\): \(9\leftarrow\bigl\langle\langle ABD,A\rangle,B\bigr\rangle\), leaving \(2\to 7\to 9\). Compress: the only maximal chain is the single node \(2\), and a chain of length one has no odd \(i\) with a successor, so nothing moves.
(iii) Rake \(9\) into \(7\):
\begin{equation*} 7\leftarrow \Bigl\langle\; \bigl\langle \langle ABD,A\rangle, B\bigr\rangle,\; \langle CDF, BCE\rangle \;\Bigr\rangle ; \end{equation*}
no node now has a nonleaf single child, so compress does nothing.
(iv) Rake \(7\) into \(2\):
\begin{equation*} 2\leftarrow \Bigl\langle\; \Bigl\langle \bigl\langle \langle ABD,A\rangle, B\bigr\rangle, \langle CDF,BCE\rangle \Bigr\rangle,\; \langle C, EFG\rangle \;\Bigr\rangle , \end{equation*}
and one node remains, so this label is returned. Naming the new internal nodes \(R\) (root), \(X\), \(Z\), \(X_1\), \(X_2\), \(Y\), it is the dtree
R |- X | |- X1 | | |- Y | | | |- leaf ABD | | | `- leaf A | | `- leaf B | `- X2 | |- leaf CDF | `- leaf BCE
`- Z |- leaf C
`- leaf EFG
Its height is \(4\) against \(6\) for the dtree of Figure 9.28, the \(O(\log n)\) height promised by Theorem 9.15 for \(n=13\). Clusters of the original dtree, leaf cutsets being read as \(\mathrm{vars}(L)\setminus\mathrm{acutset}(L)\):
| node | vars | cutset | context | cluster |
|---|---|---|---|---|
| 1 | \(ABCDEFG\) | \(C\) | \(\varnothing\) | \(C\) |
| 2 | \(ABCDEFG\) | \(EF\) | \(C\) | \(CEF\) |
| 3 | \(C\) | \(\varnothing\) | \(C\) | \(C\) |
| 4 | \(ABCDEF\) | \(D\) | \(CEF\) | \(CDEF\) |
| 5 | \(EFG\) | \(G\) | \(EF\) | \(EFG\) |
| 6 | \(CDF\) | \(\varnothing\) | \(CDF\) | \(CDF\) |
| 7 | \(ABCDE\) | \(B\) | \(CDE\) | \(BCDE\) |
| 8 | \(BCE\) | \(\varnothing\) | \(BCE\) | \(BCE\) |
| 9 | \(ABD\) | \(\varnothing\) | \(BD\) | \(BD\) |
| 10 | \(B\) | \(\varnothing\) | \(B\) | \(B\) |
| 11 | \(ABD\) | \(A\) | \(BD\) | \(ABD\) |
| 12 | \(ABD\) | \(\varnothing\) | \(ABD\) | \(ABD\) |
| 13 | \(A\) | \(\varnothing\) | \(A\) | \(A\) |
giving width \(3\) and largest context \(w=3\); and for the balanced dtree:
| node | vars | cutset | context | cluster |
|---|---|---|---|---|
| \(R\) | \(ABCDEFG\) | \(CEF\) | \(\varnothing\) | \(CEF\) |
| \(X\) | \(ABCDEF\) | \(BD\) | \(CEF\) | \(BCDEF\) |
| \(X_1\) | \(ABD\) | \(\varnothing\) | \(BD\) | \(BD\) |
| \(Y\) | \(ABD\) | \(A\) | \(BD\) | \(ABD\) |
| \(ABD\) | \(ABD\) | \(\varnothing\) | \(ABD\) | \(ABD\) |
| \(A\) | \(A\) | \(\varnothing\) | \(A\) | \(A\) |
| \(B\) | \(B\) | \(\varnothing\) | \(B\) | \(B\) |
| \(X_2\) | \(BCDEF\) | \(\varnothing\) | \(BCDEF\) | \(BCDEF\) |
| \(CDF\) | \(CDF\) | \(\varnothing\) | \(CDF\) | \(CDF\) |
| \(BCE\) | \(BCE\) | \(\varnothing\) | \(BCE\) | \(BCE\) |
| \(Z\) | \(CEFG\) | \(\varnothing\) | \(CEF\) | \(CEF\) |
| \(C\) | \(C\) | \(\varnothing\) | \(C\) | \(C\) |
| \(EFG\) | \(EFG\) | \(G\) | \(EF\) | \(EFG\) |
Hence cutset width \(3\), context width \(5\) and width \(4\), all inside the Theorem 9.15 guarantees \(\le w=3\), \(\le 2w=6\) and \(\le 3w-1=8\): balancing bought two units of height for one of width. COMPOSE connects its arguments arbitrarily, so this is one legitimate output of BAL DT rather than the only one.
Define a jointree for an undirected graph \(G\) as a pair \((T,C)\), where \(T\) is a tree and \(C\) is a function that maps each node \(i\) in the tree \(T\) to a label \(C_i\), called a cluster, that satisfies the following conditions:
- The cluster \(C_i\) is a set of nodes in graph \(G\).
- For every edge \(X-Y\) in graph \(G\), the variables \(X\) and \(Y\) appear in some cluster \(C_i\).
- The clusters of tree \(T\) satisfy the jointree property: if a node of \(G\) appears in two clusters \(C_i\) and \(C_j\), it appears in every cluster \(C_k\) on the path connecting \(i\) and \(j\) in \(T\).
Show that every clique of \(G\) must be contained in some cluster of the jointree. Show also that if \(G\) is the moral graph of some DAG \(G^\star\), then \((T,C)\) is also a jointree for DAG \(G^\star\). Note: this definition of a jointree is known as a tree decomposition (for graph \(G\)) in the graph-theoretic literature.
Both claims reduce to the Helly property of subtrees. For a node \(X\) of \(G\) put \(T_X=\{\,i\in T : X\in C_i\,\}\); each \(T_X\) is connected, since the jointree property places the whole \(i\)-to-\(j\) path inside \(T_X\) whenever \(i,j\in T_X\).
Helly. Nonempty pairwise-intersecting subtrees \(S_1,\dots,S_k\) of \(T\) share a node. Root \(T\) arbitrarily. Each \(S_i\) has a unique node \(h_i\) of minimum depth, since two of equal minimum depth would force their least common ancestor, which lies on the connecting path and hence in \(S_i\), to be shallower; and every \(v\in S_i\) is a descendant of \(h_i\), the least common ancestor of \(v\) and \(h_i\) lying in \(S_i\) at depth \(\le\mathrm{depth}(h_i)\) and so equalling \(h_i\). Pick \(j\) maximising \(\mathrm{depth}(h_j)\) and fix any \(i\). A node \(v\in S_i\cap S_j\) descends from both \(h_i\) and \(h_j\), so these are comparable and \(h_i\) is an ancestor-or-equal of \(h_j\); then \(h_j\) lies on the \(h_i\)-to-\(v\) path, which lies in the connected \(S_i\). Hence \(h_j\in S_1\cap\dots\cap S_k\). \(\square\)
Cliques. Let \(K\) be a clique with \(|K|\ge 2\). Any two distinct \(X,Y\in K\) are adjacent, so by the second condition some \(C_i\) contains both, giving \(i\in T_X\cap T_Y\); the subtrees \(T_X\), \(X\in K\), are therefore nonempty and pairwise intersecting, and Helly supplies a node \(i\) with \(K\subseteq C_i\). If \(K=\{X\}\) and \(X\) has a neighbour, the cluster covering that edge serves; if \(X\) is isolated the three conditions never mention \(X\), and the claim holds exactly under the usual extra tree-decomposition requirement that every node of \(G\) occur in some cluster, which we adopt.
Moral graphs. Take \(G=G^\star_m\). Conditions 1 and 3 of Definition 9.13 are verbatim the first and third conditions above, the moral graph having exactly the nodes of \(G^\star\) and the jointree property mentioning no graph at all. For condition 2, every family \(X\mathbf{U}\) is a clique of \(G\): Definition 9.1 undirects each edge \(U\to X\), making \(X\) adjacent to every \(U\in\mathbf{U}\), and connects each pair \(U,U^{\prime}\in\mathbf{U}\) as parents of the common child \(X\). The previous paragraph then yields a cluster \(C_i\supseteq X\mathbf{U}\). \(\blacksquare\)
Define a dtree for an undirected graph \(G\) as a pair \((T,\mathrm{vars})\), where \(T\) is a full binary tree whose leaves are in one-to-one correspondence with the graph edges and \(\mathrm{vars}(\cdot)\) is a function that maps each leaf node \(L\) in the dtree to the two variables \(\mathrm{vars}(L)\) of the corresponding edge. Define the cutset, context, and cluster as they are defined for dtrees of DAGs, that is,
\begin{equation*} \begin{aligned} \mathrm{vars}(N) &= \mathrm{vars}(N^l)\cup \mathrm{vars}(N^r) &&\text{for nonleaf } N,\\ \mathrm{cutset}(N) &= \bigl(\mathrm{vars}(N^l)\cap \mathrm{vars}(N^r)\bigr) \setminus \mathrm{acutset}(N) &&\text{for nonleaf } N,\\ \mathrm{acutset}(N) &= \bigcup\nolimits_{N^\star} \mathrm{cutset}(N^\star) &&\text{over ancestors } N^\star \text{ of } N,\\ \mathrm{context}(N) &= \mathrm{vars}(N)\cap \mathrm{acutset}(N), && \end{aligned} \end{equation*}
with \(\mathrm{cluster}(N)=\mathrm{vars}(N)\) at a leaf and \(\mathrm{cluster}(N)=\mathrm{cutset}(N)\cup \mathrm{context}(N)\) otherwise. Show that the dtree clusters satisfy the jointree property. Show also that every clique of \(G\) must be contained in some cluster of the dtree. Note: this definition of a dtree is known as a branch decomposition (for graph \(G\)) in the graph-theoretic literature.
Both claims follow once each variable is pinned to a subtree of clusters. Fix a variable \(X\) occurring in some leaf label, let \(L_X\ne\varnothing\) be the leaves whose label contains \(X\), and let \(M_X\) be their least common ancestor. Unfolding the recursion for \(\mathrm{vars}\),
\begin{equation*} X\in\mathrm{vars}(N) \iff \text{some leaf of } L_X \text{ lies at or below } N . \tag{1} \end{equation*}
Nothing below uses the leaf labels beyond their being sets of variables, so the same argument proves Theorem 9.10 for dtrees of DAGs.
\(X\) lies in exactly one cutset. (i) At a proper ancestor \(N\) of \(M_X\), all of \(L_X\) sits in one child subtree, so by (1) \(X\notin\mathrm{vars}(N^l)\cap\mathrm{vars}(N^r)\) and \(X\notin\mathrm{cutset}(N)\). (ii) If \(M_X\) is a nonleaf, each of its child subtrees holds a leaf of \(L_X\), since otherwise that child would be a deeper common ancestor; so by (1) \(X\) lies in both children’s \(\mathrm{vars}\), while (i) gives \(X\notin\mathrm{acutset}(M_X)\), and hence \(X\in\mathrm{cutset}(M_X)\). (iii) At a proper descendant \(N\) of \(M_X\), (ii) puts \(X\) in \(\mathrm{acutset}(N)\), which the set difference then removes. (iv) At an \(N\) incomparable with \(M_X\), (1) gives \(X\notin\mathrm{vars}(N)\supseteq\mathrm{cutset}(N)\). Thus \(X\) lies in \(\mathrm{cutset}(N)\) exactly when \(N=M_X\) and \(M_X\) is a nonleaf, whence
\begin{equation*} X \in \mathrm{acutset}(N) \iff M_X \text{ is a proper ancestor of } N . \tag{2} \end{equation*}
The clusters holding \(X\).
\begin{equation*} X\in\mathrm{cluster}(N) \iff N \text{ is } M_X \text{ or below it, and } X\in\mathrm{vars}(N). \tag{3} \end{equation*}
At a leaf \(\mathrm{cluster}=\mathrm{vars}\), and every leaf containing \(X\) belongs to \(L_X\) and so lies at or below \(M_X\). At a nonleaf \(N\): if \(N=M_X\) then \(X\in\mathrm{cutset}(N)\) by (ii); if \(N\) is a proper descendant with \(X\in\mathrm{vars}(N)\) then (2) puts \(X\) in \(\mathrm{context}(N)\). Conversely \(X\in\mathrm{cluster}(N)\) forces \(X\in\mathrm{vars}(N)\), since cutset and context both sit inside \(\mathrm{vars}(N)\), so \(N\) is comparable with \(M_X\) by (1); and a proper ancestor is excluded by (i) and (2) together.
Jointree property. By (3), \(S_X=\{N : X\in\mathrm{cluster}(N)\}\) is the set of nodes at or below \(M_X\) having a leaf of \(L_X\) at or below them, and each such \(N\) is joined to \(M_X\) inside \(S_X\), every node on the path from \(N\) up to \(M_X\) still having that leaf below it. So \(S_X\) is connected, hence contains the path between any two of its nodes, which is the jointree property. Variables occurring in no leaf label occur in no cluster, and the property is vacuous for them.
Cliques. The pair \((T,\mathrm{cluster})\) meets the three conditions of Exercise 9.25: clusters are sets of nodes of \(G\); each edge \(X-Y\) is the label of a leaf \(L\) with \(\mathrm{cluster}(L)=\mathrm{vars}(L)=\{X,Y\}\); and the jointree property holds by the above. Exercise 9.25 then places every clique of \(G\) inside some cluster, with the same degenerate isolated-node case. \(\blacksquare\)
Let \(G\) be a DAG, \(G_m\) its moral graph, and consider a jointree \((T,C)\) for DAG \(G\) with width \(w\). Let \(G_d\) be the graph that results from connecting in \(G_m\) every pair of variables that appear together in some jointree cluster. Show that \(G_d\) is triangulated and that its treewidth is \(w\).
Peeling leaves off the jointree, as Algorithm 21 (JT2EO) does, produces a perfect elimination order for \(G_d\), so \(G_d\) is triangulated, and its treewidth is \(w\). Throughout, \(|C_i|\le w+1\) for every cluster with equality for at least one, the jointree having width \(w\).
Two facts. (F1) Every cluster is a clique of \(G_d\), since \(G_d\) joins every pair occurring together in a cluster. (F2) Every edge of \(G_d\) lies inside some cluster: the added edges do by definition, and an edge of \(G_m\) is by Definition 9.1 either an undirected \(U\to X\), inside the family of \(X\), or a link between two parents of a common child \(Z\), inside the family of \(Z\) – and condition 2 of Definition 9.13 puts every family inside a cluster. In particular every variable occurs in a cluster, lying in its own family.
The order. While the current tree \(T^{\prime}\) has more than one node, pick a leaf \(i\) with neighbour \(j\), append \(C_i\setminus C_j\) to \(\pi\) in any order and delete \(i\); at the end append the variables of the one remaining cluster. Only leaves are deleted, so \(T^{\prime}\) is always a connected subtree of \(T\) and each deleted node has a unique attachment point in \(T^{\prime}\), the first \(T^{\prime}\)-node on its path in. Write \(B_i\) for \(\{i\}\) together with the deleted nodes attached at \(i\), so that \(T\) is the disjoint union of the \(B_i\), \(i\in T^{\prime}\).
(i) For a leaf \(i\) with neighbour \(j\) and \(X\in C_i\setminus C_j\), every cluster containing \(X\) is \(C_k\) with \(k\in B_i\). Were \(k\in B_m\) with \(m\in T^{\prime}\), \(m\ne i\), the \(k\)-to-\(i\) path would run to \(m\) and then along \(T^{\prime}\), ending with the edge \(j-i\) as \(i\) is a leaf, so the jointree property would force \(X\in C_j\). Since \(B_i\cap T^{\prime}=\{i\}\), \(C_i\) is the only surviving cluster containing \(X\). Hence peeling \(i\) deletes exactly \(C_i\setminus C_j\) from \(\bigcup_{k\in T^{\prime}}C_k\), the surviving variables \(V\) are always \(\bigcup_{k\in T^{\prime}}C_k\), and each variable is eliminated exactly once.
(ii) Each \(X\in C_i\setminus C_j\) is simplicial when eliminated, of degree \(\le |C_i|-1\le w\). Inductively no fill-in edge has been added, so the current graph is \(G_d\) restricted to \(V\). A surviving \(G_d\)-neighbour \(Y\) of \(X\) shares a cluster \(C_k\) with \(X\) by (F2), and \(k\in B_i\) by (i); if \(k=i\) then \(Y\in C_i\), and otherwise \(Y\in C_m\) for some \(m\in T^{\prime}\) and the \(k\)-to-\(m\) path crosses \(i\), so the jointree property again gives \(Y\in C_i\). All surviving neighbours of \(X\) thus lie in \(C_i\setminus\{X\}\) and are pairwise adjacent by (F1). At the last stage \(V=C_i\) is a clique by (F1), so its vertices are simplicial in turn, again of degree \(\le w\).
No fill-in edge is ever added, so \((G_d)_\pi=G_d\), \(\pi\) is a perfect elimination order in the sense of Definition 9.15, and \(G_d\) is triangulated by Theorem 9.17. By (ii) every cluster induced by \(\pi\) has at most \(w+1\) variables, so \(\mathrm{treewidth}(G_d)\le\mathrm{width}(\pi,G_d)\le w\); and some \(C_i\) has \(w+1\) variables and is a clique of \(G_d\) by (F1), so Theorem 9.1 gives \(\mathrm{treewidth}(G_d)\ge w\). Hence
\begin{equation*} \mathrm{treewidth}(G_d) \;=\; w . \qquad \blacksquare \end{equation*}
Show that the treewidth of a triangulated graph equals the size of its maximal clique minus one; that is, if \(G\) is triangulated and \(\omega(G)\) denotes the number of nodes in a largest clique of \(G\), then \(\mathrm{treewidth}(G)=\omega(G)-1\).
\(\mathrm{treewidth}(G)=\omega(G)-1\), where \(\omega(G)\) is the size of a largest clique; the statement’s “maximal clique” must be read that way, a triangulated graph generally having inclusion-maximal cliques of several sizes.
Lower bound. \(G\) has a clique of size \(\omega(G)\), so Theorem 9.1 gives \(\mathrm{treewidth}(G)\ge\omega(G)-1\), triangulation unused.
Upper bound. By Theorem 9.17 there is a perfect elimination order \(\pi\), so \(G_\pi=G\) by Definition 9.15. Let \(G_1=G\) and let \(G_{i+1}\) come from \(G_i\) by pairwise connecting the neighbours of \(\pi(i)\) and deleting \(\pi(i)\). Elimination only ever adds edges and \(G_\pi=G\), so every edge added at every step was already present in \(G\); hence no step alters the edges among survivors, making \(G_i\) the subgraph of \(G\) induced by \(\pi(i),\dots,\pi(n)\), and the neighbours of \(\pi(i)\) in \(G_i\) pairwise adjacent in \(G\). The induced cluster
\begin{equation*} C_i \;=\; \{\pi(i)\}\cup\{\text{neighbours of } \pi(i) \text{ in } G_i\} \end{equation*}
is therefore a clique of \(G\), those neighbours being adjacent to \(\pi(i)\) in \(G\) as well, so \(|C_i|\le\omega(G)\) for every \(i\) and
\begin{equation*} \mathrm{treewidth}(G) \le \mathrm{width}(\pi,G) = \max_i |C_i| - 1 \le \omega(G)-1 . \qquad\blacksquare \end{equation*}
Most Likely Instantiations
Exercises 10.1–10.7
Compute the MPE probability and a corresponding MPE instantiation for the Bayesian network in Figure 10.1, given evidence \(A = \mathsf{no}\) and using Algorithm 27, VE_MPE.
Figure 10.1 is the following network. Variable \(S\) is the gender of an individual, \(C\) is a condition that is more likely in males, \(T_1\) and \(T_2\) are two tests for the condition, and \(A\) records whether the two tests agree on the individual. The edges are
\begin{equation*} S \to C,\quad S \to T_2,\quad C \to T_1,\quad C \to T_2,\quad T_1 \to A,\quad T_2 \to A . \end{equation*}
The CPTs are:
| \(S\) | \(\theta_s\) |
|---|---|
| male | .55 |
| female | .45 |
| \(S\) | \(C\) | \(\theta_{c \mid s}\) |
|---|---|---|
| male | yes | .05 |
| male | no | .95 |
| female | yes | .01 |
| female | no | .99 |
| \(C\) | \(T_1\) | \(\theta_{t_1 \mid c}\) |
|---|---|---|
| yes | \(+\)ve | .80 |
| yes | \(-\)ve | .20 |
| no | \(+\)ve | .20 |
| no | \(-\)ve | .80 |
| \(S\) | \(C\) | \(T_2\) | \(\theta_{t_2 \mid c,s}\) |
|---|---|---|---|
| male | yes | \(+\)ve | .80 |
| male | yes | \(-\)ve | .20 |
| male | no | \(+\)ve | .20 |
| male | no | \(-\)ve | .80 |
| female | yes | \(+\)ve | .95 |
| female | yes | \(-\)ve | .05 |
| female | no | \(+\)ve | .05 |
| female | no | \(-\)ve | .95 |
| \(T_1\) | \(T_2\) | \(A\) | \(\theta_{a \mid t_1,t_2}\) |
|---|---|---|---|
| \(+\)ve | \(+\)ve | yes | 1 |
| \(+\)ve | \(+\)ve | no | 0 |
| \(+\)ve | \(-\)ve | yes | 0 |
| \(+\)ve | \(-\)ve | no | 1 |
| \(-\)ve | \(+\)ve | yes | 0 |
| \(-\)ve | \(+\)ve | no | 1 |
| \(-\)ve | \(-\)ve | yes | 1 |
| \(-\)ve | \(-\)ve | no | 0 |
\(\mathit{MPE}_{Pr}(A = \mathsf{no}) = .084645\), attained at the unique instantiation \(S = \text{female}\), \(C = \mathsf{no}\), \(T_1 = +\text{ve}\), \(T_2 = -\text{ve}\), \(A = \mathsf{no}\). Write \(e : A = \mathsf{no}\).
Line 1 of VE_MPE calls pruneEdges\((N,e)\), which removes no edge since the sole evidence variable \(A\) is a leaf; only \(\theta_{a \mid t_1,t_2}\) is reduced, to the extended factor
\begin{equation*} f_A^{e}(T_1,T_2,A) = \begin{cases} \theta_{a \mid t_1,t_2}, & a = \mathsf{no}\\ 0, & a = \mathsf{yes}, \end{cases} \end{equation*}
every row of every factor carrying the trivial instantiation \(\top\) as Definition 10.2 requires. Take \(\pi = A, T_1, T_2, C, S\), of width 2: the eliminations work on \(\{T_1,T_2,A\}\), \(\{C,T_1,T_2\}\), \(\{S,C,T_2\}\), \(\{S,C\}\), \(\{S\}\).
Maximizing \(A\) out of the only factor mentioning it, \(f_A^{e}\), records \(A = \mathsf{no}\) throughout, that being the only value with nonzero entries:
| \(T_1\) | \(T_2\) | \(g_1\) | \(g_1[\cdot]\) |
|---|---|---|---|
| \(+\)ve | \(+\)ve | 0 | \(A = \mathsf{no}\) |
| \(+\)ve | \(-\)ve | 1 | \(A = \mathsf{no}\) |
| \(-\)ve | \(+\)ve | 1 | \(A = \mathsf{no}\) |
| \(-\)ve | \(-\)ve | 0 | \(A = \mathsf{no}\) |
So \(g_1\) is the indicator of “the two tests disagree”. Eliminating \(T_1\), the factors mentioning it are \(\theta_{T_1 \mid C}\) and \(g_1\), with product
| \(C\) | \(T_1\) | \(T_2\) | product |
|---|---|---|---|
| yes | \(+\)ve | \(+\)ve | 0 |
| yes | \(+\)ve | \(-\)ve | .80 |
| yes | \(-\)ve | \(+\)ve | .20 |
| yes | \(-\)ve | \(-\)ve | 0 |
| no | \(+\)ve | \(+\)ve | 0 |
| no | \(+\)ve | \(-\)ve | .20 |
| no | \(-\)ve | \(+\)ve | .80 |
| no | \(-\)ve | \(-\)ve | 0 |
Maximizing out \(T_1\) gives
| \(C\) | \(T_2\) | \(g_2\) | \(g_2[\cdot]\) |
|---|---|---|---|
| yes | \(+\)ve | .20 | \(T_1 = -\)ve, \(A = \mathsf{no}\) |
| yes | \(-\)ve | .80 | \(T_1 = +\)ve, \(A = \mathsf{no}\) |
| no | \(+\)ve | .80 | \(T_1 = -\)ve, \(A = \mathsf{no}\) |
| no | \(-\)ve | .20 | \(T_1 = +\)ve, \(A = \mathsf{no}\) |
the instantiations recorded by \(g_1\) being carried along by the multiplication rule of Definition 10.2. Eliminating \(T_2\), the factors \(\theta_{T_2 \mid C,S}\) and \(g_2\) have product
| \(S\) | \(C\) | \(T_2\) | product |
|---|---|---|---|
| male | yes | \(+\)ve | \(.80 \times .20 = .16\) |
| male | yes | \(-\)ve | \(.20 \times .80 = .16\) |
| male | no | \(+\)ve | \(.20 \times .80 = .16\) |
| male | no | \(-\)ve | \(.80 \times .20 = .16\) |
| female | yes | \(+\)ve | \(.95 \times .20 = .19\) |
| female | yes | \(-\)ve | \(.05 \times .80 = .04\) |
| female | no | \(+\)ve | \(.05 \times .80 = .04\) |
| female | no | \(-\)ve | \(.95 \times .20 = .19\) |
Maximizing out \(T_2\) gives (ties for \(S = \) male are broken arbitrarily, which Definition 10.2 permits; here we keep \(T_2 = +\)ve):
| \(S\) | \(C\) | \(g_3\) | \(g_3[\cdot]\) |
|---|---|---|---|
| male | yes | .16 | \(T_2 = +\)ve, \(T_1 = -\)ve, \(A = \mathsf{no}\) |
| male | no | .16 | \(T_2 = +\)ve, \(T_1 = -\)ve, \(A = \mathsf{no}\) |
| female | yes | .19 | \(T_2 = +\)ve, \(T_1 = -\)ve, \(A = \mathsf{no}\) |
| female | no | .19 | \(T_2 = -\)ve, \(T_1 = +\)ve, \(A = \mathsf{no}\) |
Eliminating \(C\), the factors \(\theta_{C \mid S}\) and \(g_3\) have product
| \(S\) | \(C\) | product |
|---|---|---|
| male | yes | \(.05 \times .16 = .0080\) |
| male | no | \(.95 \times .16 = .1520\) |
| female | yes | \(.01 \times .19 = .0019\) |
| female | no | \(.99 \times .19 = .1881\) |
Maximizing out \(C\):
| \(S\) | \(g_4\) | \(g_4[\cdot]\) |
|---|---|---|
| male | .1520 | \(C = \mathsf{no}\), \(T_2 = +\)ve, \(T_1 = -\)ve, \(A = \mathsf{no}\) |
| female | .1881 | \(C = \mathsf{no}\), \(T_2 = -\)ve, \(T_1 = +\)ve, \(A = \mathsf{no}\) |
Finally \(\theta_S\) and \(g_4\) give
\begin{equation*} \begin{aligned} \text{male} &: .55 \times .1520 = .083600,\\ \text{female} &: .45 \times .1881 = .084645 . \end{aligned} \end{equation*}
so maximizing out \(S\) yields the trivial factor
\begin{equation*} \begin{aligned} f(\top) &= .084645,\\ f[\top] &: S = \text{female},\ C = \mathsf{no},\ T_1 = +\text{ve},\\ &\qquad T_2 = -\text{ve},\ A = \mathsf{no}. \end{aligned} \end{equation*}
Uniqueness is visible in the joint of Table 10.1, whose rows compatible with \(A = \mathsf{no}\) are
| \(S\) | \(C\) | \(T_1\) | \(T_2\) | \(Pr(\cdot)\) |
|---|---|---|---|---|
| male | yes | \(+\)ve | \(-\)ve | .004400 |
| male | yes | \(-\)ve | \(+\)ve | .004400 |
| male | no | \(+\)ve | \(-\)ve | .083600 |
| male | no | \(-\)ve | \(+\)ve | .083600 |
| female | yes | \(+\)ve | \(-\)ve | .000180 |
| female | yes | \(-\)ve | \(+\)ve | .000855 |
| female | no | \(+\)ve | \(-\)ve | .084645 |
| female | no | \(-\)ve | \(+\)ve | .017820 |
whose strict maximum is the recovered row, \(.084645\).
Consider the Bayesian network in Figure 10.1. What is the most likely outcome of the two tests \(T_1\) and \(T_2\) for a female on whom the tests came out different? Use Algorithm 30, VE_MAP, to answer this question.
Figure 10.1 has nodes \(S\) (gender), \(C\) (a condition), \(T_1, T_2\) (two tests for the condition), and \(A\) (whether the two tests agree), with edges
\begin{equation*} S \to C,\quad S \to T_2,\quad C \to T_1,\quad C \to T_2,\quad T_1 \to A,\quad T_2 \to A . \end{equation*}
Its CPTs are
| \(S\) | \(\theta_s\) |
|---|---|
| male | .55 |
| female | .45 |
| \(S\) | \(C\) | \(\theta_{c \mid s}\) | \(C\) | \(T_1\) | \(\theta_{t_1 \mid c}\) |
|---|---|---|---|---|---|
| male | yes | .05 | yes | \(+\)ve | .80 |
| male | no | .95 | yes | \(-\)ve | .20 |
| female | yes | .01 | no | \(+\)ve | .20 |
| female | no | .99 | no | \(-\)ve | .80 |
| \(S\) | \(C\) | \(T_2\) | \(\theta_{t_2 \mid c,s}\) |
|---|---|---|---|
| male | yes | \(+\)ve | .80 |
| male | yes | \(-\)ve | .20 |
| male | no | \(+\)ve | .20 |
| male | no | \(-\)ve | .80 |
| female | yes | \(+\)ve | .95 |
| female | yes | \(-\)ve | .05 |
| female | no | \(+\)ve | .05 |
| female | no | \(-\)ve | .95 |
and \(\theta_{a \mid t_1,t_2} = 1\) for \(A = \mathsf{yes}\) exactly when \(T_1 = T_2\), and \(\theta_{a \mid t_1,t_2} = 1\) for \(A = \mathsf{no}\) exactly when \(T_1 \neq T_2\) (so \(A\) is a deterministic agreement indicator).
The most likely outcome is \(T_1 = +\text{ve}\), \(T_2 = -\text{ve}\), with \(\mathit{MAP}_{Pr}(\mathbf{M},e) = .084825\). This is the MAP query with \(\mathbf{M} = \{T_1,T_2\}\) and evidence
\begin{equation*} e : S = \text{female},\ A = \mathsf{no}, \end{equation*}
\(A\) being the deterministic agreement indicator; \(\mathbf{E} \cap \mathbf{M} = \emptyset\), as VE_MAP requires. Line 1 calls pruneNetwork\((N,\mathbf{M},e)\): node pruning removes nothing, the only leaf \(A\) being evidence, and edge pruning deletes \(S \to C\) and \(S \to T_2\) out of the evidence node \(S\). Line 3 reduces every remaining CPT by \(e\), giving
\begin{equation*} \begin{aligned} f_S(S) &= \theta_S^{e} : \ f_S(\text{female}) = .45,\ f_S(\text{male}) = 0,\\ f_C( C) &= \theta_{C \mid S = \text{female}} : \ \theta_{\mathsf{yes}} = .01,\ \theta_{\mathsf{no}} = .99,\\ f_1(C,T_1) &= \theta_{T_1 \mid C},\\ f_2(C,T_2) &= \theta_{T_2 \mid C, S = \text{female}},\\ f_A(T_1,T_2,A) &= \theta_{A \mid T_1,T_2}^{e}, \end{aligned} \end{equation*}
the last being zero on every row with \(A = \mathsf{yes}\). Definition 10.4 forces the MAP variables last, so take the \(\mathbf{M}\)-constrained order
\begin{equation*} \pi = S,\ A,\ C,\ T_1,\ T_2 , \end{equation*}
of width 2, summing out \(S,A,C\) and then maximizing out \(T_1,T_2\). Now \(f_S\) is nonzero only at \(S = \text{female}\), so \(\sum_S f_S = .45\), and \(f_A\) is nonzero only at \(A = \mathsf{no}\), so summing out \(A\) leaves the disagreement indicator
| \(T_1\) | \(T_2\) | \(g(T_1,T_2)\) |
|---|---|---|
| \(+\)ve | \(+\)ve | 0 |
| \(+\)ve | \(-\)ve | 1 |
| \(-\)ve | \(+\)ve | 1 |
| \(-\)ve | \(-\)ve | 0 |
The factors mentioning \(C\) are \(f_C\), \(f_1\) and \(f_2\), with product
| \(C\) | \(T_1\) | \(T_2\) | \(f_C f_1 f_2\) |
|---|---|---|---|
| yes | \(+\)ve | \(+\)ve | \(.01 \times .80 \times .95 = .00760\) |
| yes | \(+\)ve | \(-\)ve | \(.01 \times .80 \times .05 = .00040\) |
| yes | \(-\)ve | \(+\)ve | \(.01 \times .20 \times .95 = .00190\) |
| yes | \(-\)ve | \(-\)ve | \(.01 \times .20 \times .05 = .00010\) |
| no | \(+\)ve | \(+\)ve | \(.99 \times .20 \times .05 = .00990\) |
| no | \(+\)ve | \(-\)ve | \(.99 \times .20 \times .95 = .18810\) |
| no | \(-\)ve | \(+\)ve | \(.99 \times .80 \times .05 = .03960\) |
| no | \(-\)ve | \(-\)ve | \(.99 \times .80 \times .95 = .75240\) |
Summing over \(C\) gives
| \(T_1\) | \(T_2\) | \(h(T_1,T_2)\) |
|---|---|---|
| \(+\)ve | \(+\)ve | .01750 |
| \(+\)ve | \(-\)ve | .18850 |
| \(-\)ve | \(+\)ve | .04150 |
| \(-\)ve | \(-\)ve | .75250 |
At this point the remaining factors are the constant \(.45\), the indicator \(g\), and \(h\); their product is exactly the joint marginal \(Pr(T_1,T_2,e)\):
| \(T_1\) | \(T_2\) | \(Pr(T_1,T_2, S = \text{female}, A = \mathsf{no})\) |
|---|---|---|
| \(+\)ve | \(+\)ve | \(0\) |
| \(+\)ve | \(-\)ve | \(.45 \times .18850 = .084825\) |
| \(-\)ve | \(+\)ve | \(.45 \times .04150 = .018675\) |
| \(-\)ve | \(-\)ve | \(0\) |
Maximizing out \(T_1\) with the extended factors of Section 10.2.1,
| \(T_2\) | \(\max_{T_1}\) | recorded |
|---|---|---|
| \(+\)ve | .018675 | \(T_1 = -\)ve |
| \(-\)ve | .084825 | \(T_1 = +\)ve |
and then \(\max_{T_2}\) of these two numbers is \(.084825\), recorded with \(T_2 = -\)ve, so the returned trivial factor is
\begin{equation*} f(\top) = .084825, \qquad f[\top] : T_1 = +\text{ve},\ T_2 = -\text{ve}. \end{equation*}
that is, \(\mathit{MAP}_{Pr}(\{T_1,T_2\},e) = Pr(T_1 = +\text{ve}, T_2 = -\text{ve}, e) = .084825\).
Show that the MAP example in Section 10.3.1 admits another MAP instantiation with the same probability \(.242720\).
That example uses the digital-circuit network of Figure 10.2, with MAP variables \(\mathbf{M} = \{I, J\}\) and evidence \(e : O = \mathsf{true}\). All five variables are binary with values \(\mathsf{true}/\mathsf{false}\), and the edges are
\begin{equation*} J \to Y,\quad I \to X,\quad J \to X,\quad X \to O,\quad Y \to O . \end{equation*}
The CPTs are
| \(I\) | \(\theta_i\) | \(J\) | \(\theta_j\) | |
|---|---|---|---|---|
| \(\mathsf{true}\) | .5 | \(\mathsf{true}\) | .5 | |
| \(\mathsf{false}\) | .5 | \(\mathsf{false}\) | .5 |
| \(J\) | \(Y\) | \(\theta_{y \mid j}\) |
|---|---|---|
| \(\mathsf{true}\) | \(\mathsf{true}\) | .01 |
| \(\mathsf{true}\) | \(\mathsf{false}\) | .99 |
| \(\mathsf{false}\) | \(\mathsf{true}\) | .99 |
| \(\mathsf{false}\) | \(\mathsf{false}\) | .01 |
| \(I\) | \(J\) | \(X\) | \(\theta_{x \mid i,j}\) |
|---|---|---|---|
| \(\mathsf{true}\) | \(\mathsf{true}\) | \(\mathsf{true}\) | .95 |
| \(\mathsf{true}\) | \(\mathsf{true}\) | \(\mathsf{false}\) | .05 |
| \(\mathsf{true}\) | \(\mathsf{false}\) | \(\mathsf{true}\) | .05 |
| \(\mathsf{true}\) | \(\mathsf{false}\) | \(\mathsf{false}\) | .95 |
| \(\mathsf{false}\) | \(\mathsf{true}\) | \(\mathsf{true}\) | .05 |
| \(\mathsf{false}\) | \(\mathsf{true}\) | \(\mathsf{false}\) | .95 |
| \(\mathsf{false}\) | \(\mathsf{false}\) | \(\mathsf{true}\) | .05 |
| \(\mathsf{false}\) | \(\mathsf{false}\) | \(\mathsf{false}\) | .95 |
| \(X\) | \(Y\) | \(O\) | \(\theta_{o \mid x,y}\) |
|---|---|---|---|
| \(\mathsf{true}\) | \(\mathsf{true}\) | \(\mathsf{true}\) | .98 |
| \(\mathsf{true}\) | \(\mathsf{true}\) | \(\mathsf{false}\) | .02 |
| \(\mathsf{true}\) | \(\mathsf{false}\) | \(\mathsf{true}\) | .98 |
| \(\mathsf{true}\) | \(\mathsf{false}\) | \(\mathsf{false}\) | .02 |
| \(\mathsf{false}\) | \(\mathsf{true}\) | \(\mathsf{true}\) | .98 |
| \(\mathsf{false}\) | \(\mathsf{true}\) | \(\mathsf{false}\) | .02 |
| \(\mathsf{false}\) | \(\mathsf{false}\) | \(\mathsf{true}\) | .02 |
| \(\mathsf{false}\) | \(\mathsf{false}\) | \(\mathsf{false}\) | .98 |
Running VE_MAP with the order \(\pi = O, Y, X, I, J\) produces, after summing out \(O\), \(Y\) and \(X\), the factor
| \(I\) | \(J\) | \(f_1\) |
|---|---|---|
| \(\mathsf{true}\) | \(\mathsf{true}\) | .93248 |
| \(\mathsf{true}\) | \(\mathsf{false}\) | .97088 |
| \(\mathsf{false}\) | \(\mathsf{true}\) | .07712 |
| \(\mathsf{false}\) | \(\mathsf{false}\) | .97088 |
together with the priors \(f_2(I)\) and \(f_3(J)\), and the algorithm reports the MAP instantiation \(I = \mathsf{true}, J = \mathsf{false}\) with MAP probability \(.242720\).
\(I = \mathsf{false}, J = \mathsf{false}\) is a second MAP instantiation of probability \(.242720\). VE_MAP with the order \(O, Y, X, I, J\) leaves \(f_1(I,J)\) together with the uniform priors \(f_2(I) \equiv f_3(J) \equiv .5\), so that
\begin{equation*} Pr(I, J, O = \mathsf{true}) \;=\; f_1(I,J)\, f_2(I)\, f_3(J) \;=\; .25 \cdot f_1(I,J). \end{equation*}
Reading off all four entries:
| \(I\) | \(J\) | \(Pr(I,J,O = \mathsf{true})\) |
|---|---|---|
| \(\mathsf{true}\) | \(\mathsf{true}\) | \(.25 \times .93248 = .233120\) |
| \(\mathsf{true}\) | \(\mathsf{false}\) | \(.25 \times .97088 = .242720\) |
| \(\mathsf{false}\) | \(\mathsf{true}\) | \(.25 \times .07712 = .019280\) |
| \(\mathsf{false}\) | \(\mathsf{false}\) | \(.25 \times .97088 = .242720\) |
so the maximum \(.242720\) is attained twice and
\begin{equation*} \mathit{MAP}(\{I,J\}, O = \mathsf{true}) \;=\; \{\, (I = \mathsf{true}, J = \mathsf{false}),\ (I = \mathsf{false}, J = \mathsf{false}) \,\}. \end{equation*}
The tie is structural. The CPT of \(O\) is the noisy or \(Pr(O = \mathsf{true} \mid x,y) = .98 - .96 \cdot [\, x = \mathsf{false} \text{ and } y = \mathsf{false} \,]\), and \(X \perp\!\!\!\perp Y \mid I, J\) in this network, so
\begin{equation*} f_1(i,j) \;=\; Pr(O = \mathsf{true} \mid i,j) \;=\; .98 - .96 \cdot Pr(x_f \mid i,j)\, Pr(y_f \mid j), \end{equation*}
writing \(x_f\) for \(X = \mathsf{false}\) and \(y_f\) for \(Y = \mathsf{false}\). At \(J = \mathsf{false}\) the CPT of \(X\) has \(\theta_{X = \mathsf{true} \mid i, \mathsf{false}} = .05\) for both values of \(i\), so \(Pr(x_f \mid i, \mathsf{false}) = .95\) whatever \(i\) is, and \(Y\) never depended on \(I\); hence \(f_1(i,\mathsf{false}) = .98 - .96 \times .95 \times .01 = .97088\) for both \(i\), and the uniform prior on \(I\) carries the tie through. In the book’s trace it surfaces as \(\big(\max_I f_1 f_2\big)(J = \mathsf{false}) = \max(.485440, .485440)\), where Definition 10.2 permits recording either maximizer; recording \(I = \mathsf{false}\) returns the second instantiation.
Construct a factor \(f\) over variables \(X\) and \(Y\) such that
\begin{equation*} \sum_Y \max_X f \;\neq\; \max_X \sum_Y f . \end{equation*}
Take \(X\) and \(Y\) binary with values \(x_1,x_2\) and \(y_1,y_2\), and let \(f\) be the indicator of “\(X\) and \(Y\) take matching indices”:
| \(X\) | \(Y\) | \(f\) |
|---|---|---|
| \(x_1\) | \(y_1\) | 1 |
| \(x_1\) | \(y_2\) | 0 |
| \(x_2\) | \(y_1\) | 0 |
| \(x_2\) | \(y_2\) | 1 |
Maximizing out \(X\) first (Definition 10.1) gives \(\big(\max_X f\big)(y_1) = \big(\max_X f\big)(y_2) = 1\), hence \(\sum_Y \max_X f = 2\); summing out \(Y\) first gives \(\big(\sum_Y f\big)(x_1) = \big(\sum_Y f\big)(x_2) = 1\), hence \(\max_X \sum_Y f = 1\). No single \(x\) maximizes \(f(\cdot,y)\) at both values of \(y\), which is exactly what defeats equality in Theorem 10.4.
Construct a factor \(f\) over variables \(X\) and \(Y\) such that
\begin{equation*} \sum_Y \max_X f \;=\; \max_X \sum_Y f . \end{equation*}
Take \(X\) and \(Y\) binary with values \(x_1, x_2\) and \(y_1, y_2\), and let
| \(X\) | \(Y\) | \(f\) |
|---|---|---|
| \(x_1\) | \(y_1\) | 2 |
| \(x_1\) | \(y_2\) | 3 |
| \(x_2\) | \(y_1\) | 1 |
| \(x_2\) | \(y_2\) | 0 |
whose row \(x_1\) dominates row \(x_2\) pointwise, so that the single value \(x_1\) maximizes \(f(\cdot,y)\) at every \(y\). Then \(\max_X f\) takes the values \(\max(2,1) = 2\) at \(y_1\) and \(\max(3,0) = 3\) at \(y_2\), giving \(\sum_Y \max_X f = 5\); and \(\sum_Y f\) takes the values \(2+3 = 5\) at \(x_1\) and \(1+0 = 1\) at \(x_2\), giving \(\max_X \sum_Y f = 5\) as well.
Prove Theorem 10.1: if \(f_1\) and \(f_2\) are factors and if variable \(X\) appears only in \(f_2\), then
\begin{equation*} \max_X f_1 f_2 \;=\; f_1 \max_X f_2 . \end{equation*}
Here \(\max_X f\) is the factor of Definition 10.1: if \(f\) is a factor over variables \(\mathbf{X}\) and \(X \in \mathbf{X}\), then \(\max_X f\) is the factor over \(\mathbf{Y} = \mathbf{X} \setminus \{X\}\) defined by \(\big(\max_X f\big)(\mathbf{y}) = \max_x f(x, \mathbf{y})\).
Both sides are factors over \(\mathbf{W} = (\mathbf{Y} \cup \mathbf{Z}) \setminus \{X\}\), where \(f_1\) is over \(\mathbf{Y}\) and \(f_2\) over \(\mathbf{Z}\) with \(X \in \mathbf{Z}\), \(X \notin \mathbf{Y}\): on the right \(\max_X f_2\) is a factor over \(\mathbf{Z} \setminus \{X\}\), and \(\mathbf{Y} \cup (\mathbf{Z} \setminus \{X\}) = \mathbf{W}\) because \(X \notin \mathbf{Y}\). Fix an instantiation \(\mathbf{w}\) of \(\mathbf{W}\) and let \(\mathbf{y}\), \(\mathbf{z}^{\prime}\) be its restrictions to \(\mathbf{Y}\) and \(\mathbf{Z} \setminus \{X\}\); the instantiation \(\mathbf{y}\) is free of \(X\) precisely because \(X\) appears only in \(f_2\), so \((f_1 f_2)(x\mathbf{w}) = f_1(\mathbf{y})\, f_2(x\mathbf{z}^{\prime})\) for each value \(x\), and Definition 10.1 gives
\begin{equation*} \begin{aligned} \Big(\max_X f_1 f_2\Big)(\mathbf{w}) &= \max_x \, f_1(\mathbf{y})\, f_2(x \mathbf{z}^{\prime})\\ &= f_1(\mathbf{y}) \cdot \max_x f_2(x \mathbf{z}^{\prime})\\ &= \Big(f_1 \max_X f_2\Big)(\mathbf{w}). \end{aligned} \end{equation*}
The middle step pulls out \(f_1(\mathbf{y})\), which is constant in \(x\) and nonnegative by Definition 6.1: for \(c \ge 0\) one has \(\max_x c\, v_x = c \max_x v_x\), both sides vanishing when \(c = 0\). Since \(\mathbf{w}\) was arbitrary, the factors are equal. \(\blacksquare\)
Consider a naive Bayes structure with edges \(C \to A_1, \ldots, C \to A_n\). What is the complexity of computing the MPE probability for this network using Algorithm 27, VE_MPE? What is the complexity of computing the MAP probability for MAP variables \(A_1, \ldots, A_n\) using Algorithm 30, VE_MAP? How does the complexity of these computations change when we have evidence on variable \(C\)?
MPE costs \(O(n \exp(1))\), MAP with \(\mathbf{M} = \{A_1,\ldots,A_n\}\) costs \(O(n \exp(n))\), and evidence on \(C\) drops both to \(O(n \exp(0))\). Here \(d\) bounds the cardinality of a variable, and elimination of width \(w\) on \(N\) variables costs \(O(N \exp(w))\) time and space.
MPE. Under \(\pi = A_1, \ldots, A_n, C\), each \(A_i\) occurs in the single CPT \(\theta_{A_i \mid C}\), so Theorem 10.1 lets it be maximized out on its own, leaving \(\lambda_i( C) = \max_{a_i} \theta_{a_i \mid C}\); eliminating \(C\) then multiplies \(\theta_C, \lambda_1, \ldots, \lambda_n\) and maximizes:
\begin{equation*} \mathit{MPE}_{Pr} \;=\; \max_{c}\ \theta_c \prod_{i=1}^{n} \max_{a_i} \theta_{a_i \mid c}. \end{equation*}
Every cluster has two variables, so \(w = 1\) and the cost is \(O\big((n+1)\exp(1)\big) = O(n)\), or \(O(n d^2)\) counting table entries.
MAP. Definition 10.4 puts the MAP variables last, so \(C\), the only non-MAP variable, is eliminated first; nothing prunes away beforehand, pruneNetwork removing only leaves outside \(\mathbf{M} \cup \mathbf{E}\) and every leaf \(A_i\) being a MAP variable. That step multiplies all \(n+1\) CPTs into a factor over \(\{C, A_1,\ldots,A_n\}\) and sums \(C\) out to
\begin{equation*} h(A_1,\ldots,A_n) \;=\; Pr(A_1,\ldots,A_n) \;=\; \sum_c \theta_c \prod_{i=1}^n \theta_{a_i \mid c}, \end{equation*}
out of which the \(A_i\) are then maximized one at a time. The width is \(n\), and as every admissible order has this shape the \(\mathbf{M}\)-constrained treewidth is exactly \(n\) against an unconstrained treewidth of \(1\); so VE_MAP costs \(O\big((n+1)\exp(n)\big) = O(n\, d^{\,n})\).
Evidence \(e : C = c\). Pruning deletes all \(n\) edges out of \(C\) and reduces the CPTs, leaving an isolated \(C\) with \(\theta_C^{e}\) and isolated roots \(A_i\) with \(\lambda_i(A_i) = \theta_{A_i \mid c}\). No factor now mentions two variables, so every order, constrained or not, has width \(0\), and both algorithms return
\begin{equation*} \theta_c \prod_{i=1}^{n} \max_{a_i}\, \theta_{a_i \mid c}, \end{equation*}
with \(a_i^{\star} = \arg\max_{a_i} \theta_{a_i \mid c}\) for each \(i\), together with \(C = c\) for MPE. MPE stays linear, its constant improving to \(O(nd)\), while MAP falls from exponential to \(O(n)\), the evidence d-separating the attributes from one another. In summary:
| query | evidence | constrained order needed | width | complexity |
|---|---|---|---|---|
| MPE | none | no | 1 | \(O(n \exp(1))\) |
| MAP | none | yes | \(n\) | \(O(n \exp(n))\) |
| MPE | \(C = c\) | no | 0 | \(O(n \exp(0))\) |
| MAP | \(C = c\) | yes | 0 | \(O(n \exp(0))\) |
Exercises 10.8–10.14
True or false: We can compute a MAP instantiation \(\mathrm{MAP}(\mathbf{M}, \mathbf{e})\) by computing the MAP instantiations \(\mathbf{m}_x = \mathrm{MAP}(\mathbf{M}, \mathbf{e}x)\) for every value \(x\) of some variable \(X \notin \mathbf{M}\) and then returning \(\operatorname{argmax}_{\mathbf{m}_x} Pr(\mathbf{m}_x, \mathbf{e})\). What if \(X \in \mathbf{M}\)? For each case, either prove or provide a counterexample.
False when \(X \notin \mathbf{M}\), true when \(X \in \mathbf{M}\).
(i) \(X \notin \mathbf{M}\). The scheme searches only the candidate set \(\{\mathbf{m}_x : x\}\), which has at most as many elements as \(X\) has values, whereas the true MAP maximizes \(Pr(\mathbf{m}, \mathbf{e}) = \sum_x Pr(\mathbf{m}, \mathbf{e}, x)\), and the maximizer of a sum need maximize no single summand — the failure of maximization to commute with summation recorded in Theorem 10.4. For a counterexample let \(X\) be a root with values \(x_1, x_2\), let \(A\) be its only child with values \(a_1, a_2, a_3\), take \(\mathbf{M} = \{A\}\) and \(\mathbf{e}\) empty, and use the CPTs
| \(X\) | \(\Theta_X\) |
|---|---|
| \(x_1\) | .5 |
| \(x_2\) | .5 |
| \(X\) | \(A\) | \(\Theta_{A \mid X}\) |
|---|---|---|
| \(x_1\) | \(a_1\) | .6 |
| \(x_1\) | \(a_2\) | 0 |
| \(x_1\) | \(a_3\) | .4 |
| \(x_2\) | \(a_1\) | 0 |
| \(x_2\) | \(a_2\) | .6 |
| \(x_2\) | \(a_3\) | .4 |
whose joint is
| \(A\) | \(Pr(A, x_1)\) | \(Pr(A, x_2)\) | \(Pr(A)\) |
|---|---|---|---|
| \(a_1\) | .3 | 0 | .3 |
| \(a_2\) | 0 | .3 | .3 |
| \(a_3\) | .2 | .2 | .4 |
Then \(\mathbf{m}_{x_1} = a_1\) and \(\mathbf{m}_{x_2} = a_2\), both of probability \(.3\), while \(\mathrm{MAP}(\mathbf{M}, \mathbf{e}) = a_3\) has probability \(.4\); being second best under each value of \(X\) and best overall, \(a_3\) is never generated as a candidate.
(ii) \(X \in \mathbf{M}\). Write \(\mathbf{m} \sim x\) when \(\mathbf{m}\) assigns \(X = x\). Since \(\mathbf{e}x\) contains \(X = x\), \(Pr(\mathbf{m}, \mathbf{e}, x)\) equals \(Pr(\mathbf{m}, \mathbf{e})\) for \(\mathbf{m} \sim x\) and \(0\) otherwise, so \(\mathbf{m}_x = \operatorname*{argmax}_{\mathbf{m} \sim x} Pr(\mathbf{m}, \mathbf{e})\), ties broken toward an \(\mathbf{m}\) compatible with \(x\) (an incompatible one can be the argmax only when the whole column is \(0\), and the final comparison by \(Pr(\mathbf{m}_x, \mathbf{e})\) then still returns a correct answer). The instantiations of \(\mathbf{M}\) are partitioned by the value they assign \(X\), so the maximization splits blockwise:
\begin{equation*} \begin{aligned} \max_{\mathbf{m}} Pr(\mathbf{m}, \mathbf{e}) &= \max_x \; \max_{\mathbf{m} \sim x} Pr(\mathbf{m}, \mathbf{e}) \\ &= \max_x \; Pr(\mathbf{m}_x, \mathbf{e}), \end{aligned} \end{equation*}
which \(\operatorname{argmax}_{\mathbf{m}_x} Pr(\mathbf{m}_x, \mathbf{e})\) attains. \(\blacksquare\)
Suppose that we have a jointree with \(n\) clusters and width \(w\). Show that MAP can be solved in \(O(n \exp(w))\) time and space if all MAP variables are contained in some jointree cluster.
Compute the cluster marginal at a cluster \(r\) with \(\mathbf{M} \subseteq \mathbf{C}_r\), project, and scan. Run the jointree algorithm of Chapter 7 with evidence \(\mathbf{e}\), rooted at \(r\) and performing only the inward pass, so that cluster \(i\) sends its neighbour \(j\) on the path to \(r\)
\begin{equation*} M_{ij} \;=\; \sum_{\mathbf{C}_i \setminus \mathbf{S}_{ij}} \Big( \prod_{f \in \Phi_i} f^{\mathbf{e}} \Big) \prod_{k \ne j} M_{ki}, \end{equation*}
with \(\Phi_i\) the CPTs assigned to \(i\) and \(\mathbf{S}_{ij}\) the separator, leaving at the root
\begin{equation*} Pr(\mathbf{C}_r, \mathbf{e}) \;=\; \Big( \prod_{f \in \Phi_r} f^{\mathbf{e}} \Big) \prod_{k} M_{kr}. \end{equation*}
Each message is a factor over a separator \(\mathbf{S}_{ij} \subseteq \mathbf{C}_i\), hence has at most \(\exp(w)\) entries and costs \(O(\exp(w))\) after the standard amortization of the message products; there are \(n-1\) of them, for \(O(n \exp(w))\) time and space. Since \(\mathbf{M} \subseteq \mathbf{C}_r\),
\begin{equation*} Pr(\mathbf{M}, \mathbf{e}) \;=\; \sum_{\mathbf{C}_r \setminus \mathbf{M}} Pr(\mathbf{C}_r, \mathbf{e}) \end{equation*}
is a single sum-out over at most \(\exp(w)\) rows, and \(\operatorname*{argmax}_{\mathbf{m}} Pr(\mathbf{m}, \mathbf{e})\) with its value is one further scan of at most \(\exp(w)\) rows, both \(O(\exp(w))\). Adding the three gives \(O(n \exp(w))\) time and space. All summation is completed before any maximization, so Theorem 10.4 poses no obstacle, and the inward pass is exact. \(\blacksquare\)
Show that Algorithm 27, VE MPE, is correct when run with extended factors. In particular, prove the following invariant for this algorithm. Let \(\mathbf{X}\) be the variables appearing in the set \(S\) maintained by VE MPE, \(\mathbf{Y}\) be all other (eliminated) variables, and \(f\) be the product of factors in \(S\). Then \(f(\mathbf{x}) = Pr(\mathbf{x}, f[\mathbf{x}], \mathbf{e})\) and \(f(\mathbf{x}) = \max_{\mathbf{y}} Pr(\mathbf{x}, \mathbf{y}, \mathbf{e})\). Show that this invariant holds before the algorithm reaches Line 5 and remains true after each iteration of Lines 6–8.
For reference, Algorithm 27 is:
VE MPE(\(\mathcal{N}\), \(\mathbf{e}\))
- \(\mathcal{N}^{\prime} \leftarrow \mathrm{pruneEdges}(\mathcal{N}, \mathbf{e})\)
- \(\mathbf{Q} \leftarrow\) variables in network \(\mathcal{N}^{\prime}\)
- \(\pi \leftarrow\) elimination order of variables \(\mathbf{Q}\)
- \(S \leftarrow \{f^{\mathbf{e}} : f\) is a CPT of network \(\mathcal{N}^{\prime}\}\)
- for \(i = 1\) to \(|\mathbf{Q}|\) do
- \(\quad\) \(f \leftarrow \prod_k f_k\), where \(f_k\) belongs to \(S\) and mentions variable \(\pi(i)\)
- \(\quad\) \(f_i \leftarrow \max_{\pi(i)} f\)
- \(\quad\) replace all factors \(f_k\) in \(S\) by factor \(f_i\)
- end for
- return trivial factor \(\prod_{f \in S} f\)
Extended factors and their operations are as in Definition 10.2: \(\max_X f[\mathbf{y}] = x^\star f[x^\star, \mathbf{y}]\) where \(x^\star = \operatorname{argmax}_x f(x, \mathbf{y})\), and \((f_1 f_2)[\mathbf{z}] = f_1[\mathbf{x}] f_2[\mathbf{y}]\) for \(\mathbf{x} \sim \mathbf{z}\) and \(\mathbf{y} \sim \mathbf{z}\). The algorithm starts with \(f[\cdot] = \top\) for every row of every CPT.
The invariant holds before Line 5 and survives each iteration, so the returned trivial factor carries \(f(\top) = \max_{\mathbf{q}} Pr(\mathbf{q}, \mathbf{e})\) with witness \(f[\top]\). Let \(\mathbf{Q}\) be all network variables, \(\mathbf{X}\) those mentioned by \(S\), \(\mathbf{Y} = \mathbf{Q} \setminus \mathbf{X}\), and \(f = \prod_{g \in S} g\); the invariant is
(I1) \(f[\mathbf{x}]\) instantiates exactly \(\mathbf{Y}\), with \(f(\mathbf{x}) = Pr(\mathbf{x}, f[\mathbf{x}], \mathbf{e})\);
(I2) \(f(\mathbf{x}) = \max_{\mathbf{y}} Pr(\mathbf{x}, \mathbf{y}, \mathbf{e})\).
Each variable is recorded into exactly one factor, the \(f_i\) built on Line 7 of the iteration where it is the pivot, and is never mentioned afterwards, so the instantiations attached to distinct factors of \(S\) mention disjoint variables and the product rule of Definition 10.2 is well defined.
Before Line 5. Here \(\mathbf{X} = \mathbf{Q}\), \(\mathbf{Y} = \emptyset\), and every row carries \(\top\), an instantiation of \(\emptyset\). Reduction gives \(h^{\mathbf{e}}(\mathbf{x}) = h(\mathbf{x})\) for \(\mathbf{x} \sim \mathbf{e}\) and \(0\) otherwise, so the chain rule makes \(f(\mathbf{x}) = Pr^{\prime}(\mathbf{x}, \mathbf{e})\) for the pruned network \(\mathcal{N}^{\prime}\), and Theorem 6.5 with query variables \(\mathbf{Q}\) gives \(Pr^{\prime}(\mathbf{x}, \mathbf{e}) = Pr(\mathbf{x}, \mathbf{e})\). Both (I1) and (I2) reduce to this, \(\mathbf{Y}\) being empty.
One iteration of Lines 6–8. Let \(Z = \pi(i)\), \(\mathbf{X}^{\prime} = \mathbf{X}\setminus\{Z\}\) and \(\mathbf{Y}^{\prime} = \mathbf{Y}\cup\{Z\}\); let \(f^{\prime}\) be the Line 6 product of the factors mentioning \(Z\) and \(g\) the product of the rest, so \(f = f^{\prime} g\) with \(g\) free of \(Z\), and \(f_{\mathrm{new}} = (\max_Z f^{\prime}) g = \max_Z f\) by Theorem 10.1. Hence by (I2),
\begin{equation*} \begin{aligned} f_{\mathrm{new}}(\mathbf{x}^{\prime}) &= \max_z \; \max_{\mathbf{y}} Pr(z, \mathbf{x}^{\prime}, \mathbf{y}, \mathbf{e}) \\ &= \max_{\mathbf{y}^{\prime}} Pr(\mathbf{x}^{\prime}, \mathbf{y}^{\prime}, \mathbf{e}), \end{aligned} \end{equation*}
the instantiations of \(\mathbf{Y}^{\prime}\) being exactly the pairs \((z,\mathbf{y})\); this is (I2) for \(f_{\mathrm{new}}\). Definition 10.2 at Line 7 and the product rule at Line 8 give
\begin{equation*} \begin{aligned} f_{\mathrm{new}}[\mathbf{x}^{\prime}] &= z^\star \, f^{\prime}[z^\star, \mathbf{x}^{\prime}] \, g[\mathbf{x}^{\prime}] \;=\; z^\star \, f[z^\star, \mathbf{x}^{\prime}], \end{aligned} \end{equation*}
where \(z^\star = \operatorname*{argmax}_z f^{\prime}(z, \mathbf{x}^{\prime})\); by induction \(f[z^\star,\mathbf{x}^{\prime}]\) instantiates \(\mathbf{Y}\), and \(Z \notin \mathbf{Y}\), so this instantiates exactly \(\mathbf{Y}^{\prime}\). For the numeric half of (I1), two cases.
(i) \(g(\mathbf{x}^{\prime}) > 0\): multiplying by the \(z\)-constant \(g(\mathbf{x}^{\prime})\) does not move the argmax, so \(z^\star = \operatorname*{argmax}_z f(z,\mathbf{x}^{\prime})\), and (I1) for \(f\) at the row \((z^\star,\mathbf{x}^{\prime})\) gives
\begin{equation*} \begin{aligned} Pr(\mathbf{x}^{\prime}, f_{\mathrm{new}}[\mathbf{x}^{\prime}], \mathbf{e}) &= Pr\big(\mathbf{x}^{\prime}, z^\star, f[z^\star, \mathbf{x}^{\prime}], \mathbf{e}\big) \;=\; f(z^\star, \mathbf{x}^{\prime}) \\ &= \max_z f(z, \mathbf{x}^{\prime}) \;=\; f_{\mathrm{new}}(\mathbf{x}^{\prime}). \end{aligned} \end{equation*}
(ii) \(g(\mathbf{x}^{\prime}) = 0\): then \(f(z,\mathbf{x}^{\prime}) = 0\) for every \(z\), so \(f_{\mathrm{new}}(\mathbf{x}^{\prime}) = 0\), and by the (I2) part just proved every extension of \(\mathbf{x}^{\prime}\mathbf{e}\) has probability \(0\), the recorded witness included.
On return. After \(|\mathbf{Q}|\) iterations \(\mathbf{X} = \emptyset\) and \(\mathbf{Y} = \mathbf{Q}\), so the returned factor is trivial and the invariant at \(\top\) reads \(f(\top) = \max_{\mathbf{q}} Pr(\mathbf{q}, \mathbf{e}) = Pr(f[\top], \mathbf{e})\), with \(f[\top]\) an instantiation of all of \(\mathbf{Q}\): an MPE instantiation for \(\mathbf{e}\), of the returned probability. \(\blacksquare\)
Extend Algorithm VE MPE so it returns a structure \(\Delta\) from which all MPE solutions can be enumerated in time linear in their count and linear in the size of \(\Delta\). The extended algorithm should have the same complexity as VE MPE. Hint: Appeal to NNF circuits.
Replace the single witness \(f[\mathbf{x}]\) of Definition 10.2 by a pointer \(\alpha_f(\mathbf{x})\) into a shared NNF circuit \(\Delta\) over the literals \(X = x\), built by three rules: at Line 4 set \(\alpha_{h^{\mathbf{e}}}(\mathbf{x}) = \top\) for every reduced CPT; at Line 6 set \(\alpha_{f_1 f_2}(\mathbf{z}) = \alpha_{f_1}(\mathbf{x}) \wedge \alpha_{f_2}(\mathbf{y})\) for the rows \(\mathbf{x}, \mathbf{y} \sim \mathbf{z}\); and at Line 7, with \(m = \max_z f(z,\mathbf{x}^{\prime})\) and \(Z^\star = \{z : f(z,\mathbf{x}^{\prime}) = m\}\) the set of all maximizers,
\begin{equation*} \alpha_{f_i}(\mathbf{x}^{\prime}) \;=\; \bigvee_{z \in Z^\star} \Big( (Z = z) \wedge \alpha_{f}(z, \mathbf{x}^{\prime}) \Big). \end{equation*}
Return \(\Delta = \alpha_f(\top)\) for the trivial factor of Line 10.
\(\Delta\) is a smooth d-DNNF. As in Exercise 10.10 each variable is recorded into exactly one factor when eliminated, so the variables mentioned by \(\alpha_f(\mathbf{x})\) are exactly those eliminated into \(f\), the same set for every row of \(f\). Decomposability: \(\alpha_{f_1}\) and \(\alpha_{f_2}\) mention the disjoint sets eliminated into \(f_1\) and \(f_2\), while \((Z=z)\) mentions \(Z\) and \(\alpha_f(z,\mathbf{x}^{\prime})\) only variables eliminated before \(Z\). Determinism: distinct disjuncts fix \(Z\) to distinct values. Smoothness: every disjunct mentions \(\{Z\}\) together with the variables eliminated into \(f\).
Invariant. For every row with \(f(\mathbf{x}) > 0\),
\begin{equation*} \mathrm{models}\big(\alpha_f(\mathbf{x})\big) \;=\; \{\mathbf{y} : Pr(\mathbf{x}, \mathbf{y}, \mathbf{e}) = f(\mathbf{x})\}, \end{equation*}
where \(f(\mathbf{x}) = \max_{\mathbf{y}} Pr(\mathbf{x},\mathbf{y},\mathbf{e})\) by Exercise 10.10. Initially \(\mathbf{Y} = \emptyset\) and \(\alpha_f(\mathbf{x}) = \top\), so both sides are the singleton empty instantiation. For the step, let \(Z\) be the pivot, \(f = f^{\prime} g\) with \(g\) free of \(Z\) and \(f_{\mathrm{new}} = (\max_Z f^{\prime})g\), and suppose \(f_{\mathrm{new}}(\mathbf{x}^{\prime}) > 0\); then \(g(\mathbf{x}^{\prime}) > 0\), so scaling by it preserves maximizers, \(Z^\star = \operatorname*{argmax}_z f(z,\mathbf{x}^{\prime})\), and the two rules give
\begin{equation*} \alpha_{f_{\mathrm{new}}}(\mathbf{x}^{\prime}) \;=\; \bigvee_{z \in Z^\star} \Big( (Z=z) \wedge \alpha_{f}(z,\mathbf{x}^{\prime}) \Big). \end{equation*}
For \(z \in Z^\star\) we have \(f(z,\mathbf{x}^{\prime}) = f_{\mathrm{new}}(\mathbf{x}^{\prime}) > 0\) and the hypothesis applies; for \(z \notin Z^\star\), \(\max_{\mathbf{y}} Pr(z,\mathbf{x}^{\prime},\mathbf{y},\mathbf{e}) = f(z,\mathbf{x}^{\prime}) < f_{\mathrm{new}}(\mathbf{x}^{\prime})\), so no extension through such a \(z\) attains the maximum and the omitted disjuncts lose nothing. The union over \(Z^\star\) is thus exactly the set of instantiations \(\mathbf{y}^{\prime}\) of \(\mathbf{Y}\cup\{Z\}\) attaining \(f_{\mathrm{new}}(\mathbf{x}^{\prime})\). At Line 10, where \(\mathbf{X} = \emptyset\) and \(\mathbf{Y}\) is every network variable, the models of \(\Delta\) are therefore precisely the MPE instantiations, provided \(Pr(\mathbf{e}) > 0\).
Cost and enumeration. A multiplication adds one \(\wedge\)-node per row of the product and a maximization at most \(|Z|\) \(\wedge\)-nodes and one \(\vee\)-node per row of the result, matching the row-touches the numeric algorithm already makes; so \(|\Delta| = O(n \exp(w))\) and the running time stays \(O(n \exp(w))\), the complexity of VE MPE. To enumerate, recurse: a literal and \(\top\) yield themselves, an \(\wedge\)-node concatenates the models of its children, always consistently by decomposability, and a \(\vee\)-node unions them, disjointly by determinism and with every variable of the node already assigned by smoothness. The traversal never backtracks and never repeats a model, so it costs \(O(|\Delta| \cdot \#\mathrm{MPE})\). \(\blacksquare\)
Prove Lemma 10.1 on Page 267, which states: Let \(\mathcal{N}^{\prime}\) be the network resulting from splitting variables in network \(\mathcal{N}\). Let \(Pr^{\prime}\) and \(Pr\) be their corresponding distributions. We then have
\begin{equation*} Pr(\mathbf{x}) \;=\; \beta \cdot Pr^{\prime}(\mathbf{x}, \hat{\mathbf{x}}), \end{equation*}
where \(\mathbf{X}\) are the variables of network \(\mathcal{N}\), \(\hat{\mathbf{x}}\) is an instantiation of all clone variables that is implied by \(\mathbf{x}\), and \(\beta\) is the split cardinality.
Recall Definition 10.3: splitting node \(X\) according to children \(\mathbf{Z} \subseteq\) \(\mathrm{children}(X)\) removes the edges \(X \to Z\) for \(Z \in \mathbf{Z}\), adds a new root node \(\hat{X}\) with the same values as \(X\) and with the nodes \(\mathbf{Z}\) as children, assigns \(\hat{X}\) a uniform CPT, and replaces \(X\) by \(\hat{X}\) in the CPT of each node in \(\mathbf{Z}\). The split cardinality \(\beta\) is the number of instantiations of the split (clone) variables. The instantiation \(\hat{\mathbf{x}}\) implied by \(\mathbf{x}\) assigns each clone \(\hat{X}\) the value that \(\mathbf{x}\) assigns to \(X\).
In the chain rule for \(\mathcal{N}^{\prime}\) every factor but the clone prior is literally a factor of \(\mathcal{N}\), and the clone prior is \(1/\beta\).
One split. Let \(\mathcal{N}^{\prime}\) split \(X\) according to \(\mathbf{Z}\), with clone \(\hat{X}\), so \(\beta = |\mathrm{val}(X)|\). Fix \(\mathbf{x}\), let \(x\) be the value it assigns \(X\), so that \(\hat{\mathbf{x}} : \hat{X} = x\). The chain rule in \(\mathcal{N}^{\prime}\) gives
\begin{equation*} Pr^{\prime}(\mathbf{x}, \hat{\mathbf{x}}) \;=\; \theta^{\prime}_{\hat{x}} \cdot \prod_{V \in \mathbf{X}} \theta^{\prime}_{v \mid \mathbf{u}^{\prime}_V}, \end{equation*}
with \(v, \mathbf{u}^{\prime}_V\) the values \(\mathbf{x}\hat{\mathbf{x}}\) assigns \(V\) and its parents in \(\mathcal{N}^{\prime}\). Here \(\theta^{\prime}_{\hat{x}} = 1/\beta\), the clone being a root with a uniform CPT over \(|\mathrm{val}(X)|\) values; and every other factor is unchanged. Indeed for \(V \notin \mathbf{Z}\) Definition 10.3 touches neither the parents nor the CPT of \(V\), the case \(V = X\) included, splitting removing only outgoing edges of \(X\); and for \(V \in \mathbf{Z}\) the parents become \((\mathbf{U}_V \setminus \{X\}) \cup \{\hat{X}\}\) with the old CPT column \(X\) renamed \(\hat{X}\), while \(\mathbf{x}\hat{\mathbf{x}}\) assigns \(\hat{X}\) the same value \(x\), so the selected row is the same one as before. Hence \(Pr^{\prime}(\mathbf{x},\hat{\mathbf{x}}) = \frac{1}{\beta} Pr(\mathbf{x})\) by the chain rule in \(\mathcal{N}\).
Several splits. Induct on the number \(k\) of splits; \(k = 0\) is trivial, with \(\beta = 1\), and \(k = 1\) is the above. Let \(\mathcal{N}^{\prime\prime}\) be the network after the first \(k-1\) splits, with clones \(\hat{\mathbf{C}}\) and split cardinality \(\beta^{\prime\prime}\), so that \(Pr(\mathbf{x}) = \beta^{\prime\prime} Pr^{\prime\prime}(\mathbf{x}, \hat{\mathbf{c}})\) for the implied \(\hat{\mathbf{c}}\). The last split is of some node \(Y\) of \(\mathcal{N}^{\prime\prime}\), so \(\beta = \beta^{\prime\prime}\,|\mathrm{val}(Y)|\), and the single-split case applied at the instantiation \(\mathbf{x}\hat{\mathbf{c}}\) gives
\begin{equation*} Pr^{\prime\prime}(\mathbf{x}, \hat{\mathbf{c}}) \;=\; |\mathrm{val}(Y)| \cdot Pr^{\prime}\big(\mathbf{x}, \hat{\mathbf{c}}, \hat{Y} = y\big), \end{equation*}
\(y\) being the value \(\mathbf{x}\hat{\mathbf{c}}\) assigns \(Y\). Finally \((\hat{\mathbf{c}}, \hat{Y} = y)\) is exactly the clone instantiation \(\hat{\mathbf{x}}\) of \(\mathcal{N}^{\prime}\) implied by \(\mathbf{x}\): immediate if \(Y\) is an original variable, and if \(Y\) is itself a clone of an original \(C\) then \(\hat{\mathbf{c}}\) already sets \(Y\) to the value \(\mathbf{x}\) gives \(C\), which \(\hat{Y}\) inherits. Multiplying the two displays, \(Pr(\mathbf{x}) = \beta \cdot Pr^{\prime}(\mathbf{x}, \hat{\mathbf{x}})\). \(\blacksquare\)
Let \(\mathcal{N}\) be a network with treewidth \(w\) and let \(\mathcal{N}^{\prime}\) be another network that results from splitting \(m\) variables in \(\mathcal{N}\). Show that \(w^{\prime} \ge w - m\), where \(w^{\prime}\) is the treewidth of network \(\mathcal{N}^{\prime}\). This means that to reduce the treewidth of network \(\mathcal{N}\) by \(m\), we must split at least \(m\) variables.
Equivalently \(w \le w^{\prime} + m\), which follows by turning an optimal jointree for \(\mathcal{N}^{\prime}\) into one for \(\mathcal{N}\) at a cost of \(m\) nodes per cluster; treewidth is the width of the best jointree by Definitions 9.2 and 9.13. Let \(X_1,\dots,X_m\) be the split variables with clones \(\hat{X}_1,\dots,\hat{X}_m\), let \((T,\mathbf{C}^{\prime})\) be a jointree for \(\mathcal{N}^{\prime}\) of width \(w^{\prime}\), and on the same tree put
\begin{equation*} \mathbf{C}_i \;=\; \big(\mathbf{C}^{\prime}_i \setminus \{\hat{X}_1, \dots, \hat{X}_m\}\big) \;\cup\; \{X_1, \dots, X_m\} : \end{equation*}
delete every clone from every cluster, add every split variable to every cluster. For cascaded splits, where a split variable may itself be a clone, read \(\{X_1,\dots,X_m\}\) as \(\varphi(\{X_1,\dots,X_m\})\) with \(\varphi\) sending a clone to the node of \(\mathcal{N}\) it ultimately clones, a set of at most \(m\) nodes; everything below survives that reading, since a clone parent \(\hat{X}\) of \(V\) in \(\mathcal{N}^{\prime}\) always has \(\varphi(\hat{X}) \in \mathbf{U}_V\). Either way \(|\mathbf{C}_i| \le |\mathbf{C}^{\prime}_i| + m \le w^{\prime}+1+m\).
The three conditions of Definition 9.13 hold for \((T,\mathbf{C})\). Condition 1 is immediate, the clones having been deleted and the \(X_j\) being nodes of \(\mathcal{N}\). For condition 2, splitting replaces a parent only by that parent’s clone and adds no non-clone parent, so
\begin{equation*} \mathrm{family}_{\mathcal{N}^{\prime}}(V) \;\subseteq\; \big(\mathrm{family}_{\mathcal{N}}(V) \setminus \{X_1,\dots,X_m\}\big) \cup \{\hat{X}_1, \dots, \hat{X}_m\}, \end{equation*}
and a cluster \(\mathbf{C}^{\prime}_i\) covering the left-hand side therefore contains \(\mathrm{family}_{\mathcal{N}}(V) \setminus \{X_1,\dots,X_m\}\), to which \(\mathbf{C}_i\) adds back every \(X_j\); hence \(\mathbf{C}_i \supseteq \mathrm{family}_{\mathcal{N}}(V)\), the case \(V = X_j\) included, splitting removing only outgoing edges of \(X_j\) and so leaving its family alone. For condition 3: (i) each \(X_j\) lies in every cluster, and the whole of \(T\) is connected; (ii) any other \(V\) is neither a split variable nor a clone, so \(V \in \mathbf{C}_i\) exactly when \(V \in \mathbf{C}^{\prime}_i\), and connectedness is the jointree property of \((T,\mathbf{C}^{\prime})\).
So \(\mathcal{N}\) has a jointree of width at most \(w^{\prime}+m\), whence \(w \le w^{\prime}+m\) and \(w^{\prime} \ge w - m\). \(\blacksquare\)
Let \(\mathcal{N}\) be a Bayesian network and let \(\mathbf{C}\) be a corresponding loop cutset. Provide tight lower and upper bounds on the treewidth of a network that results from splitting variables \(\mathbf{C}\) in \(\mathcal{N}\). Note: A variable \(C \in \mathbf{C}\) can be split according to any number of children.
Recall Definition 8.1: a set of nodes \(\mathbf{C}\) is a loop cutset for \(\mathcal{N}\) if removing the edges outgoing from nodes \(\mathbf{C}\) renders the network a polytree.
\(k \le w^{\prime} \le w + c\), where \(k\) is the largest number of parents of a node of \(\mathcal{N}\), \(w\) its treewidth and \(c\) the number of clones introduced; and \(w^{\prime} \le w\) when every split is an edge deletion or an all-children split, in any sequence. Both pairs are tight. Note \(k \le w\) always, the family of a node with \(k\) parents being a clique of size \(k+1\) in the moral graph (Definitions 9.1 and 9.2), so Theorem 9.1 applies.
Lower bound. Splitting changes nobody’s parent count: Definition 10.3 replaces each edge \(C \to Z\), \(Z \in \mathbf{Z}\), by \(\hat{C} \to Z\), leaves the parents of \(C\) alone and makes \(\hat{C}\) a root. So the moral graph of \(\mathcal{N}^{\prime}\) still holds a clique of size \(k+1\) and \(w^{\prime} \ge k\), for any split of any network.
It is attained. Split each \(C \in \mathbf{C}\) according to each of its children separately, one clone \(\hat{C}_Y\) per child \(Y\). The result is \(\mathcal{N}_{\mathbf{C}}\), which is a polytree because \(\mathbf{C}\) is a loop cutset (Definition 8.1), with the clones added one at a time as fresh degree-one nodes, which cannot create an undirected cycle; so \(\mathcal{N}^{\prime}\) is a polytree. Its family clusters form a jointree — one tree node per network node \(V\) with cluster \(\{V\} \cup \mathbf{U}_V\), joined to the clusters of the children of \(V\), disconnected components joined arbitrarily since they share no variable — because the clusters containing \(V\) are that of \(V\) together with those of its children, all adjacent to it. Its width is the largest family size minus one, still \(k\), so \(w^{\prime} = k\).
\(w^{\prime} \le w\) for the two standard shapes. One split of either shape maps a jointree into a jointree of no larger width, and since both constructions accept an arbitrary jointree of an arbitrary network they compose. Let \((T,\mathbf{K})\) be a jointree of \(\mathcal{N}\) of width \(w\).
(a) \(C\) split according to a single child \(Y\). Pick \(i\) with \(\mathrm{family}_{\mathcal{N}}(Y) \subseteq \mathbf{K}_i\) and hang a new node \(i^{\ast}\) off \(i\) with
\begin{equation*} \mathbf{K}_{i^{\ast}} \;=\; \big(\mathrm{family}_{\mathcal{N}}(Y) \setminus \{C\}\big) \cup \{\hat{C}\}, \end{equation*}
of size \(|\mathrm{family}_{\mathcal{N}}(Y)| \le w+1\). It is exactly \(\mathrm{family}_{\mathcal{N}^{\prime}}(Y)\) and contains \(\mathrm{family}_{\mathcal{N}^{\prime}}(\hat{C}) = \{\hat{C}\}\), every other family being unchanged. The jointree property survives: \(\hat{C}\) lies in \(i^{\ast}\) alone, every other member of \(\mathbf{K}_{i^{\ast}}\) lies also in the adjacent \(\mathbf{K}_i\), and \(C \notin \mathbf{K}_{i^{\ast}}\).
(b) \(C\) split according to all its children with one clone. Rename \(C\) to \(\hat{C}\) in every cluster, which covers every family of \(\mathcal{N}^{\prime}\) except \(\{C\} \cup \mathbf{U}_C\), each child of \(C\) keeping exactly its renamed old family. Hang \(\{C\} \cup \mathbf{U}_C\), of size \(\le w+1\), off a cluster containing \(\{\hat{C}\} \cup \mathbf{U}_C\), which exists because that cluster covered \(\mathrm{family}_{\mathcal{N}}( C)\) before the renaming; the jointree property survives as in (a).
It is attained. When the cutset consists of roots and each \(C\) is split by shape (b), \(\mathcal{N}^{\prime}\) is \(\mathcal{N}\) with each \(C\) renamed \(\hat{C}\) plus \(|\mathbf{C}|\) isolated nodes, which do not affect treewidth, so \(w^{\prime} = w\): for instance the diamond \(A \to B\), \(A \to C\), \(B \to D\), \(C \to D\), whose loop cutset is \(\{A\}\) and whose treewidth is \(2\) before and after.
Why \(w\) fails in general. Definition 10.3 also allows a clone to inherit a proper subset of two or more children. For
\begin{equation*} \mathcal{N}: \quad A \to B, \quad A \to C, \quad B \to C, \quad A \to D, \quad C \to D, \quad A \to E, \quad D \to E, \end{equation*}
deleting the edges out of \(A\) leaves the chain \(B \to C \to D \to E\), so \(\{A\}\) is a loop cutset; the families \(\{B,A\}, \{C,A,B\}, \{D,A,C\}, \{E,A,D\}\) moralize to three triangles glued at \(A\), and the jointree \(ABC - ACD - ADE\) gives \(w = 2\). Splitting \(A\) according to \(\{B,D\}\) leaves the families \(\{B,\hat{A}\}, \{C,A,B\}, \{D,\hat{A},C\}, \{E,A,D\}\), whose moral graph contains the four-cycle \(B - \hat{A} - D - A - B\) (neither \(B-D\) nor \(A-\hat{A}\) is an edge) with \(C\) adjacent to all four of its nodes: a four-spoke wheel of minimum degree \(3\). A graph of minimum degree \(d\) has treewidth at least \(d\), the first node eliminated contributing a cluster of itself and all its neighbours (Definition 9.4), and treewidth never increases when nodes or edges are deleted, so \(w^{\prime} \ge 3 > w\); the order \(E, B, \hat{A}, A, C, D\) has width \(3\), so \(w^{\prime} = 3\) exactly.
\(w^{\prime} \le w + c\). A single split raises the treewidth by at most one: add \(\hat{X}\) to every cluster containing \(X\). Those clusters form a connected subtree, so the jointree property holds for \(\hat{X}\); each new family \((\mathrm{family}_{\mathcal{N}}(Y) \setminus \{X\}) \cup \{\hat{X}\}\), \(Y \in \mathbf{Z}\), is covered at the cluster that covered \(\mathrm{family}_{\mathcal{N}}(Y)\), which contains \(X\); and no cluster grew by more than one node. Iterating over the \(c\) clones gives the bound, for every split of every network.
It is attained for every \(c\). First a tool: if disjoint connected sets \(\mathbf{S}_1,\dots,\mathbf{S}_r\) of moral-graph nodes are pairwise linked by a moral edge, the treewidth is at least \(r-1\). Take an optimal jointree, whose clusters cover every family and hence every moral edge, and replace in every cluster each node of \(\mathbf{S}_i\) by one token \(s_i\); clusters do not grow. The clusters holding \(s_i\) are the union of the subtrees of the nodes of \(\mathbf{S}_i\), itself a subtree, since for each edge inside \(\mathbf{S}_i\) the two endpoint subtrees share the cluster covering that edge and \(\mathbf{S}_i\) is connected; and each linking edge puts \(s_i\) and \(s_j\) in one cluster. The result is a jointree of no larger width for a graph in which \(s_1,\dots,s_r\) is a clique, so Theorem 9.1 gives width \(\ge r-1\).
Now fix \(t \ge 1\), let \(n = (t+1)(t+3)\), and let \(\mathcal{F}_t\) have nodes \(A, B_1,\dots,B_n\) with edges \(A \to B_j\) for all \(j\) and \(B_j \to B_{j+1}\) for \(j < n\). Deleting the edges out of \(A\) leaves the chain, so \(\{A\}\) is a loop cutset; moralization adds no edge, the parents \(\{A,B_j\}\) of \(B_{j+1}\) being already adjacent, and \(w = 2\) — the triangle \(A,B_1,B_2\) below, the order \(B_1,\dots,B_n,A\) with clusters \(\{B_j,B_{j+1},A\}\) above. Split \(A\) according to \(\mathbf{Z}_i = \{B_j : j \equiv i \pmod{t+1}\}\) with clone \(\hat{A}_i\), for \(i = 1,\dots,t\) in turn; this is legal, since before the \(i\)-th split the children of \(A\) are the classes \(i,\dots,t,0\), of which \(\mathbf{Z}_i\) is a proper subset. Each \(B_j\) then has two parents, its owner (\(\hat{A}_i\) when \(j \equiv i\) for \(1 \le i \le t\), else \(A\)) and its predecessor \(B_{j-1}\), so the moral graph is the chain \(B_1 - \cdots - B_n\) together with, for each \(j\), the edges from the owner of \(B_j\) to \(B_j\) and to \(B_{j-1}\); no two owners are adjacent, sharing no child. Cut the chain into \(t+3\) consecutive blocks \(\mathbf{P}_1,\dots,\mathbf{P}_{t+3}\) of \(t+1\) nodes, each meeting every residue class, so every owner has a neighbour in every block. The sets
\begin{equation*} \mathbf{S}_i = \{\hat{A}_i\} \cup \mathbf{P}_i \;(i = 1, \ldots, t), \qquad \mathbf{S}_{t+1} = \{A\} \cup \mathbf{P}_{t+1}, \qquad \mathbf{S}_{t+2} = \mathbf{P}_{t+2}, \qquad \mathbf{S}_{t+3} = \mathbf{P}_{t+3} \end{equation*}
are disjoint and connected, blocks being subpaths and each owner adjoining its own block, and pairwise linked: a set holding an owner links to every other through that owner’s neighbour there, and \(\mathbf{S}_{t+2}\) links to \(\mathbf{S}_{t+3}\) by the chain edge between consecutive blocks. Hence \(w^{\prime} \ge (t+3)-1 = t+2\), while \(c = t\) clones and the unconditional bound give \(w^{\prime} \le w + c = t+2\): equality for every \(c \ge 1\). \(\blacksquare\)
Exercises 10.15–10.21
Suppose that we have a Bayesian network \(N\) with a corresponding jointree \(J\). Let \(N^{\prime}\) be a network that results from splitting some variable \(X\) in \(N\) according to its children (i.e., one clone is introduced). Show how we can obtain a jointree for network \(N^{\prime}\) by modifying the clusters of jointree \(J\). Aim for the best jointree possible (minimize its width). Show how this technique can be used to develop a greedy method for obtaining a split network that has a particular width.
Keep \(X\) only where its own CPT is hosted, rename it to \(\hat X\) on a smallest subtree carrying the hosts of the children’s CPTs, and hang \(XU\) off as a fresh leaf; the width never increases. Let \(U\) be the parents of \(X\) and \(Y_1,\dots,Y_k\) its children, so by Definition 10.3 the families of \(N^{\prime}\) are \(XU\), the singleton \(\{\hat X\}\), the \((\mathrm{fam}_N(Y_i) \setminus \{X\}) \cup \{\hat X\}\), and \(\mathrm{fam}_N(V)\) for every other \(V\).
Construction. Let \(T_X\) be the clusters of \(J\) containing \(X\); it is a connected subtree hosting each of \(XU\) and the \(\mathrm{fam}_N(Y_i)\).
- For each \(Y_i\) pick a host \(h(Y_i) \in T_X\) with \(\mathrm{fam}_N(Y_i) \subseteq h(Y_i)\), and put \(H = \{h(Y_1),\dots,h(Y_k)\}\).
- Let \(\hat T\) be the smallest connected subtree containing \(H\), the union of the paths between members of \(H\); it lies inside \(T_X\), which is itself connected and contains \(H\).
- Replace \(X\) by \(\hat X\) in every cluster of \(\hat T\), and delete \(X\) from every cluster of \(T_X \setminus \hat T\).
- Attach a fresh leaf \(C_{\mathrm{new}} = XU\) to any cluster \(C_a \supseteq XU\) of \(J\), which exists since \(J\) hosts the CPT of \(X\); the separator is \(U\).
Validity. \(X\) now occupies \(C_{\mathrm{new}}\) alone and \(\hat X\) the connected \(\hat T\); any other variable \(V\) keeps exactly its old clusters, plus the leaf \(C_{\mathrm{new}}\) when \(V \in U \subseteq C_a\), and a leaf hung on a member of a connected subtree leaves it connected. As for families, \(XU = C_{\mathrm{new}}\); \(\{\hat X\}\) lies in any cluster of \(\hat T\), which is nonempty as \(X\) has a child; \(\mathrm{fam}_{N^{\prime}}(Y_i)\) lies in the relabelled \(h(Y_i) \in \hat T\); and every remaining family lost only \(X\), which belongs to no other family of \(N^{\prime}\).
Width. Step 3 only renames or deletes, so no old cluster grows, and \(|C_{\mathrm{new}}| = |U|+1 \le w+1\) because \(C_a \supseteq XU\) already; hence \(\mathrm{width}(J^{\prime}) \le \mathrm{width}(J)\), strictly so exactly when every maximum-size cluster of \(J\) lies in \(T_X \setminus \hat T\) and \(|U|+1 \le w\). Taking the Steiner subtree \(\hat T\) rather than all of \(T_X\) is what strips \(\hat X\) out of as many clusters as the jointree property permits; the one remaining freedom is the choice of hosts in step 1, which can be searched greedily so that \(\hat T\) avoids the large clusters.
Greedy method. Fix an affordable width \(w^{\star}\), build any jointree \(J\) for \(N\) and set \(N^{\prime} \leftarrow N\). While \(\mathrm{width}(J) > w^{\star}\): for each variable \(X\) of \(N^{\prime}\) occurring in a maximum-size cluster of \(J\) but not heading the family that fills it, compute \(J_X\) by the construction above; score \(X\) by \(\Delta(X)/\log|X|\) with \(\Delta(X) = \mathrm{width}(J) - \mathrm{width}(J_X)\), breaking \(\Delta = 0\) ties by the drop in the number of maximum-size clusters; then commit the best candidate, splitting it in \(N^{\prime}\) and setting \(J \leftarrow J_X\). Return \(N^{\prime}\) with \(J\). Each iteration is local — find \(T_X\), take the Steiner subtree, relabel, prune, add one leaf — so no jointree is ever rebuilt and the new width is read off directly, while the \(\log|X|\) divisor charges each candidate the factor \(|X|\) it contributes to the split cardinality \(\beta\) of Theorem 10.2. The loop terminates, every committed split lowering either the width or the number of maximum-size clusters, both nonnegative integers; it may also halt short of \(w^{\star}\), since splitting changes no family size and so cannot push the width below \(\max_V |\mathrm{fam}_N(V)| - 1\).
Consider a Bayesian network \(N\), a corresponding jointree \(J\), and assume that the CPTs for network \(N\) have been assigned to clusters in \(J\). Consider a separator \(S_{ij}\) that contains variable \(X\) and suppose that the CPT of variable \(X\) has been assigned to a cluster on the \(j\)-side of edge \(i\!-\!j\). Consider now a transformation that produces a new jointree \(J^{\prime}\) as follows:
- Replace all occurrences of variable \(X\) by \(\hat X\) on the \(i\)-side of edge \(i\!-\!j\) in the jointree.
- Remove all occurrences of \(X\) and \(\hat X\) from clusters that have not been assigned CPTs mentioning \(X\), as long as the removal will not destroy the jointree property.
Describe a network \(N^{\prime}\) that results from splitting variables in \(N\) for which \(J^{\prime}\) would be a valid jointree.
\(J^{\prime}\) is a valid jointree for the network \(N^{\prime}\) obtained from \(N\) by splitting \(X\) according to the children
\begin{equation*} Z = \{\, Y \in \mathbf{Y} : \text{the CPT of } Y \text{ is assigned to an } i\text{-side cluster} \,\}, \end{equation*}
in the sense of Definition 10.3; the split cardinality is \(\beta = |X|\), so Theorem 10.2 reads \(\mathrm{MPE}_P(e) \le |X| \cdot \mathrm{MPE}^{\prime}_P(e,\hat e)\). Write \(U\) for the parents of \(X\) and \(\mathbf{Y}\) for its children, and call the two components of the jointree minus the edge \(i\!-\!j\) the \(i\)-side and the \(j\)-side; each CPT sits in exactly one cluster, so \(Z\) is well defined.
Why. Let \(T_X\) be the clusters containing \(X\), connected by the jointree property, and let \(T_X^{\,i}\), \(T_X^{\,j}\) be its intersections with the two sides; intersections of connected subtrees are connected, and both are nonempty because \(X \in S_{ij} = C_i \cap C_j\) puts \(C_i\) and \(C_j\) in \(T_X\). The first bullet renames \(X\) to \(\hat X\) in exactly the clusters of \(T_X^{\,i}\), so afterwards \(X\) occupies \(T_X^{\,j}\) and \(\hat X\) occupies \(T_X^{\,i}\), both connected, and no other variable is touched. The families of \(N^{\prime}\) are covered: \(XU\) by the \(j\)-side cluster hosting the CPT of \(X\), which the rename leaves alone; for \(Y \in Z\), by the \(i\)-side host \(C \supseteq \mathrm{fam}_N(Y)\), which has \(X \in C\), hence \(C \in T_X^{\,i}\), so the rename turns it into a cluster containing \((\mathrm{fam}_N(Y) \setminus \{X\}) \cup \{\hat X\}\); for \(Y \in \mathbf{Y} \setminus Z\), by its untouched \(j\)-side host; \(\{\hat X\}\) by \(C_i\), renamed since \(X \in S_{ij} \subseteq C_i\); and every remaining family by its old host, those families not mentioning \(X\) at all. The second bullet deletes \(X\) or \(\hat X\) only from clusters hosting no CPT that mentions \(X\), and only when connectivity survives, so it breaks neither property; as deletions only shrink clusters, \(\mathrm{width}(J^{\prime}) \le \mathrm{width}(J)\).
Degenerate case. If \(Z = \emptyset\), then \(N^{\prime}\) is \(N\) with a barren root \(\hat X\) added. The second bullet cannot strip \(\hat X\) from every \(i\)-side cluster, since the family \(\{\hat X\}\) would lose its host and the jointree property would fail; one cluster keeps the clone.
Let \(N^{\prime}\) be a network that results from splitting nodes in network \(N\), and let \(\mathrm{Pr}^{\prime}\) and \(\mathrm{Pr}\) be their corresponding distributions. Show that
\begin{equation*} \mathrm{Pr}(e) \le \beta \cdot \mathrm{Pr}^{\prime}(e, \hat e), \end{equation*}
where \(\hat e\) is the instantiation of clone variables that is implied by evidence \(e\) and \(\beta\) is the split cardinality.
Lemma 10.1, proved in Exercise 10.12, gives \(\mathrm{Pr}^{\prime}(x,\hat x) = \mathrm{Pr}(x)/\beta\) for every instantiation \(x\) of the variables \(X\) of \(N\), where \(\hat x\) is the clone instantiation agreeing with \(x\) and \(\beta = \prod_{i=1}^m |X_i|\) over the split variables. Hence
\begin{equation*} \mathrm{Pr}(e) \;=\; \sum_{x \,\sim\, e} \mathrm{Pr}(x) \;=\; \beta \sum_{x \,\sim\, e} \mathrm{Pr}^{\prime}(x, \hat x). \end{equation*}
Every term of that sum is a term of
\begin{equation*} \mathrm{Pr}^{\prime}(e,\hat e) \;=\; \sum_{(x,\hat s)\,\sim\, e\hat e} \mathrm{Pr}^{\prime}(x,\hat s). \end{equation*}
Indeed \((x,\hat x) \sim e\hat e\) whenever \(x \sim e\): for a split variable \(X_i\) instantiated by \(e\), both \(\hat e\) and \(\hat x\) assign \(\hat X_i\) the value \(e\) gives \(X_i\), since \(x \sim e\), while clones left free by \(\hat e\) constrain nothing. The map \(x \mapsto (x,\hat x)\) is injective, so distinct terms stay distinct, and all terms are nonnegative; therefore \(\sum_{x \sim e} \mathrm{Pr}^{\prime}(x,\hat x) \le \mathrm{Pr}^{\prime}(e,\hat e)\) and
\begin{equation*} \mathrm{Pr}(e) \;\le\; \beta \cdot \mathrm{Pr}^{\prime}(e,\hat e). \qquad \blacksquare \end{equation*}
Prove Theorem 10.3.
For reference, Theorem 10.2 reads: let \(N^{\prime}\) be the network that results from splitting variables in network \(N\) and let \(\beta\) be the split cardinality; for evidence \(e\) on network \(N\), let \(\hat e\) be the instantiation of split variables that is implied by \(e\); then \(\mathrm{MPE}_P(e) \le \beta \cdot \mathrm{MPE}^{\prime}_P(e,\hat e)\), where \(\mathrm{MPE}_P(e)\) and \(\mathrm{MPE}^{\prime}_P(e,\hat e)\) are MPE probabilities with respect to the networks \(N\) and \(N^{\prime}\).
Theorem 10.3 reads: consider Theorem 10.2 and suppose that distributions \(\mathrm{Pr}\) and \(\mathrm{Pr}^{\prime}\) are induced by networks \(N\) and \(N^{\prime}\), respectively. If the evidence \(e\) includes all split variables and if \(Q\) are the variables of \(N\) not in \(E\), then
\begin{equation*} \mathrm{Pr}(Q, e) \;=\; \beta \cdot \mathrm{Pr}^{\prime}(Q, e, \hat e). \end{equation*}
When \(e\) instantiates every split variable, the clone instantiation is forced to agree with the original and Lemma 10.1 applies term by term. Fix an instantiation \(q\) of \(Q = X \setminus E\), where \(X\) are the variables of \(N\). Since \(Q\) and \(E\) partition \(X\), the instantiation \(x = qe\) is full and \(\mathrm{Pr}(q,e) = \mathrm{Pr}(x)\) is a single term of the joint rather than a sum. Since \(S \subseteq E\), the instantiation \(\hat e\) fixes every clone, to the value \(e\) gives the corresponding split variable; as \(x\) extends \(e\), that is the value \(x\) gives it, so \(\hat e = \hat x\) in the notation of Lemma 10.1. Hence \((q,e,\hat e) = (x,\hat x)\) is a full instantiation of the variables \(X \cup \hat S\) of \(N^{\prime}\), and Lemma 10.1 — proved in Exercise 10.12, with \(\beta = \prod_{i=1}^m |X_i|\) — gives
\begin{equation*} \mathrm{Pr}^{\prime}(q,e,\hat e) \;=\; \mathrm{Pr}^{\prime}(x,\hat x) \;=\; \frac{1}{\beta}\,\mathrm{Pr}(x) \;=\; \frac{1}{\beta}\,\mathrm{Pr}(q,e). \end{equation*}
As \(q\) was arbitrary, \(\mathrm{Pr}(Q,e) = \beta \cdot \mathrm{Pr}^{\prime}(Q,e,\hat e)\) as factors over \(Q\). \(\blacksquare\)
Consider the classical jointree algorithm as defined by Equations 7.4 and 7.5 in Chapter 7:
\begin{equation*} M_{ij} \;=\; \sum_{C_i \setminus S_{ij}} \Phi_i \prod_{k \ne j} M_{ki}, \qquad f_i(C_i) \;=\; \Phi_i \prod_{k} M_{ki}. \end{equation*}
Suppose that we replace all summations by maximization when computing messages,
\begin{equation*} M_{ij} \;=\; \max_{C_i \setminus S_{ij}} \Phi_i \prod_{k \ne j} M_{ki}. \end{equation*}
What are the semantics of the factor \(f_i(C_i)\) in this case? In particular, can we use it to recover answers to MPE queries?
The factor \(f_i(C_i)\) becomes the max-marginal \(\mathrm{MPE}_P(C_i e)\) in place of the marginal \(\mathrm{Pr}(C_i,e)\), and yes: the MPE probability, the per-variable max-marginals and an MPE instantiation all follow from one propagation.
Notation. Let \(\Phi_i\) be the product of the CPTs and evidence indicators assigned to cluster \(i\), so \(\prod_i \Phi_i = \mathrm{Pr}(X)\lambda_e(X)\) over the network variables \(X = \bigcup_i C_i\); for an edge \(i\!-\!j\) let \(T_{i \to j}\) be the component of \(i\) when it is deleted, and put \(V_{i \to j} = \bigcup_{k \in T_{i \to j}} C_k\) and \(\Phi_{i \to j} = \prod_{k \in T_{i \to j}} \Phi_k\). The jointree property gives the separation fact \(V_{k \to i} \cap C_i = S_{ki}\): a variable of \(V_{k \to i}\) occurring also outside \(T_{k \to i}\) has its connected cluster subtree crossing the edge \(k\!-\!i\), so it lies in \(C_k \cap C_i\). Hence the variables of \(V_{k \to i} \setminus S_{ki}\) occur in no factor outside that branch, and distinct branches at \(i\) are variable-disjoint outside \(C_i\).
Messages. \(M_{ij} = \max_{V_{i \to j} \setminus S_{ij}} \Phi_{i \to j}\), by induction on \(|T_{i \to j}|\). For \(T_{i \to j} = \{i\}\) this is the definition. Otherwise \(\Phi_{i \to j} = \Phi_i \prod_{k \ne j} \Phi_{k \to i}\) and, by the separation fact,
\begin{equation*} V_{i \to j} \setminus S_{ij} \;=\; (C_i \setminus S_{ij}) \;\uplus\; \biguplus_{k \ne j} \bigl(V_{k \to i} \setminus S_{ki}\bigr), \end{equation*}
so, maximization being commutative (Definition 10.1),
\begin{equation*} \begin{aligned} \max_{V_{i \to j} \setminus S_{ij}} \Phi_{i \to j} &= \max_{C_i \setminus S_{ij}} \Phi_i \prod_{k \ne j} \Bigl( \max_{V_{k \to i} \setminus S_{ki}} \Phi_{k \to i} \Bigr) \\ &= \max_{C_i \setminus S_{ij}} \Phi_i \prod_{k \ne j} M_{ki} \;=\; M_{ij}, \end{aligned} \end{equation*}
the first equality by Theorem 10.1 applied repeatedly, each variable of \(V_{k \to i} \setminus S_{ki}\) occurring in \(\Phi_{k \to i}\) and in no other factor of the product, and the second by the inductive hypothesis.
Semantics. The same computation at cluster \(i\) with every neighbour included gives
\begin{equation*} f_i(C_i) \;=\; \Phi_i \prod_k M_{ki} \;=\; \max_{X \setminus C_i} \mathrm{Pr}(X)\lambda_e(X), \end{equation*}
that is, \(f_i(c_i) = \max_{x \sim c_i e} \mathrm{Pr}(x) = \mathrm{MPE}_P(c_i e)\) when \(c_i \sim e\) and \(0\) otherwise. This is not a marginal: in general \(\sum_{c_i} f_i(c_i) \ne \mathrm{Pr}(e)\), and normalizing \(f_i\) means nothing.
Recovery. (i) \(\max_{c_i} f_i(c_i) = \max_{x \sim e} \mathrm{Pr}(x) = \mathrm{MPE}_P(e)\), the same value at every cluster. (ii) Maximizing \(f_i\) over \(C_i \setminus \{V\}\), at any cluster containing \(V\), gives the factor \(\mathrm{MPE}_P(V,e)\), so one propagation answers this for every variable at once. (iii) If the MPE instantiation \(x^{\star}\) is unique then \(f_i(c_i) = \mathrm{MPE}_P(e)\) exactly when \(c_i = x^{\star}\!\downarrow\!C_i\), so the local \(\arg\max\) at each cluster is unique, the choices agree on separators, and \(x^{\star} = \bigcup_i c_i^{\star}\). Under ties independent local choices may lock onto projections of different MPE instantiations and need not even cohere, so trace back instead: root at any \(r\), pick \(c_r^{\star} \in \arg\max_{c_r} f_r(c_r)\), and at a cluster \(j\) whose parent \(i\) is already fixed pick \(c_j^{\star}\) maximizing \(f_j\) among the \(c_j\) agreeing with \(c_i^{\star}\) on \(S_{ij}\). These are consistent by construction and attain \(\mathrm{MPE}_P(e)\): writing \(s_{ij} = c_i^{\star}\!\downarrow\!S_{ij}\), the message formula gives \(f_j(c_j) = M_{ij}(s_{ij}) \cdot \Phi_j(c_j) \prod_{k \ne i} M_{kj}(c_j)\) for every candidate \(c_j\), so the constant \(M_{ij}(s_{ij})\) drops out and the local choice realises \(M_{ji}(s_{ij})\), the branch maximum the running total already charges; and by the separation fact the clusters fixed so far share with the \(j\)-branch only the variables of \(S_{ij}\), so no earlier commitment is disturbed. Alternatively run the propagation on extended factors (Definition 10.2), so that each \(c_i\) carries an instantiation of \(X \setminus C_i\) attaining \(\mathrm{MPE}_P(c_i e)\) and the best entry of any single cluster yields an MPE instantiation outright.
Consider the classical jointree algorithm as defined by Equations 7.4 and 7.5 in Chapter 7:
\begin{equation*} M_{ij} \;=\; \sum_{C_i \setminus S_{ij}} \Phi_i \prod_{k \ne j} M_{ki}, \qquad f_i(C_i) \;=\; \Phi_i \prod_{k} M_{ki}. \end{equation*}
Suppose that we replace all summations over MAP variables \(M\) by maximization when computing messages as follows:
\begin{equation*} M_{ij} \;=\; \max_{(C_i \setminus S_{ij}) \cap M} \;\; \sum_{(C_i \setminus S_{ij}) \setminus M} \Phi_i \prod_{k \ne j} M_{ki}. \end{equation*}
What are the semantics of the factor \(f_i(C_i)\) in this case? In particular, can we use it to recover answers relating to MAP queries?
\(f_i(C_i)\) is not the MAP marginal but an upper bound on it: for every instantiation \(c_i\) of \(C_i\),
\begin{equation*} \mathrm{MAP}_P(M \setminus C_i,\; c_i e) \;\le\; f_i(c_i) \;\le\; \mathrm{Pr}(c_i, e). \end{equation*}
For \(f_i = \Phi_i \prod_k M_{ki}\) is exactly the factor VE_MAP (Algorithm 30) returns with MAP variables \(M \setminus C_i\), evidence \(c_i e\), and the elimination order \(\pi_i\) that the jointree rooted at cluster \(i\) induces (Section 9.3.5), each variable being eliminated in the cluster nearest the root that contains it; the message \(M_{ki}\) localises the eliminations of its own branch, legitimately, by the separation fact of Exercise 10.19. That order is in general not \(M\)-constrained (Definition 10.4): a MAP variable in a leaf cluster is maximized out before non-MAP variables nearer the root. So both inequalities are Theorem 10.5 with \(c_i\) folded into the evidence – the left one because \(\pi_i\) has moved maximizations inward past summations relative to a constrained order, which by Theorem 10.4 can only increase the value; the right one because \(\max_Y g \le \sum_Y g\) for nonnegative \(g\), and the all-summation computation returns \(\mathrm{Pr}(c_i,e)\) by Equation 7.5. It is exact exactly when \(\pi_i\) is \(M\)-constrained on \(X \setminus C_i\), in particular when \(M \subseteq C_i\) or \(X \setminus C_i \subseteq M\).
For a concrete gap, take the chain \(A \to B \to C \to D\) over binary variables with the parameters
| parent value | \(\mathrm{Pr}(A{=}\text{true})\) | \(\mathrm{Pr}(B{=}\text{true} \mid A)\) | \(\mathrm{Pr}(C{=}\text{true} \mid B)\) | \(\mathrm{Pr}(D{=}\text{true} \mid C)\) |
|---|---|---|---|---|
| true | .6 | .2 | .9 | .3 |
| false | – | .7 | .4 | .8 |
(the root \(A\) has no parent, so its single parameter is written in the first row) and the chain of clusters \(C_1 = AB\), \(C_2 = BC\), \(C_3 = CD\), with \(M = \{A, C\}\) and \(e : D = \text{true}\). Enumeration gives \(\mathrm{Pr}(e) = .5\) and \(\mathrm{MAP}_P(M, e) = .24\) at \(A = \text{true}, C = \text{false}\), while rooting at \(C_1\) (order \(C,B,A\)) returns \(q_1 = .2628\) and rooting at \(C_2\) or \(C_3\) (order \(A,B,C\)) returns \(q_2 = q_3 = .2528\) (Check!), so
\begin{equation*} \mathrm{MAP}_P(M,e) = .24 \;\le\; .2528 \;\le\; .2628 \;\le\; \mathrm{Pr}(e) = .5; \end{equation*}
no root is exact here, since every root maximizes a MAP variable before \(B\) is summed.
Three MAP answers do follow, all from one propagation.
(i) A global bound: \(q_i = \max_{C_i \cap M} \sum_{C_i \setminus M} f_i(C_i)\) is what VE_MAP returns for MAP variables \(M\) and evidence \(e\) under \(\pi_i\) extended by \(C_i \setminus M\) then \(C_i \cap M\), so \(\mathrm{MAP}_P(M,e) \le q_i \le \mathrm{Pr}(e)\) by Theorem 10.5. This is the \(\mathrm{MAP}^u_P(X,i)\) that Line 3 of Algorithm 31 needs, one inward-outward propagation supplies it at every cluster at cost \(O(n \exp(w))\), and \(\min_i q_i\) is therefore available too.
(ii) Per-value bounds: with \(X{=}x\) added to the evidence the same argument makes
\begin{equation*} B_x \;=\; \max_{(C_i \cap M) \setminus \{X\}} \;\sum_{C_i \setminus M} f_i(C_i) \Big|_{X = x} \end{equation*}
an upper bound on \(\mathrm{MAP}_P(M \setminus \{X\},\, e\,X{=}x)\), for every remaining MAP variable and every value at once, with \(q_i = \max_x B_x\). This is the efficiency claim used in Exercise 10.21.
(iii) Exact MAP when \(M \subseteq C_r\) for some cluster: then \(\pi_r\) is \(M\)-constrained, \(\mathrm{MAP}_P(M,e) = \max_{C_r \cap M} \sum_{C_r \setminus M} f_r(C_r)\), and the maximizing \(m\) is read off directly – possible only within the constrained treewidth of Definition 10.4.
The bound tightens under the promotion of Figure 10.11: moving a MAP variable from \(C_k\) into its root-ward neighbour \(C_i\), subject to \(|C_i| \le w+1\), preserves the jointree properties and the width but postpones that variable’s elimination past the non-MAP eliminations at \(C_i\).
Consider Line 3 of Algorithm 31 and let
\begin{equation*} B_x \;=\; \mathrm{MAP}^u_P(\mathbf{X} \setminus \{X\},\, i x). \end{equation*}
Here \(\mathbf{X}\) is the set of variables still to be instantiated at the current search node and \(X\) is a single variable of that set. For reference, Algorithm 31, BB_MAP\((N, M, e)\), takes a Bayesian network \(N\), MAP variables \(M\), and evidence \(e\) with \(E \cap M = \emptyset\), and returns a MAP instantiation for variables \(M\) and evidence \(e\). Its main body sets \(m\) to some instantiation of \(M\) and \(p\) to the probability of \(m, e\), both global, then calls BB_MAP_AUX\((e, M)\) and returns \(m\). The recursion BB_MAP_AUX\((i, \mathbf{X})\) is:
- Line 1: if \(\mathbf{X}\) is empty then (leaf node)
- Line 2: if \(\mathrm{Pr}(i) > p\), then \(m \leftarrow i\) and \(p \leftarrow \mathrm{Pr}(i)\)
- Line 3: else if \(\mathrm{MAP}^u_P(\mathbf{X}, i) > p\) then
- Line 4: \(X \leftarrow\) a variable in \(\mathbf{X}\)
- Line 5: for each value \(x\) of variable \(X\) do
- Line 6: BB_MAP_AUX\((i x, \mathbf{X} \setminus \{X\})\)
- Line 7: end for
- Line 8: end if
Consider now the following heuristics:
- On Line 4, choose variable \(X\) that maximizes \(M_X / T_X\), where
\begin{equation*} M_X = \max_x B_x, \qquad T_X = \sum_{B_x \ge p} B_x, \end{equation*}
and \(p\) is the probability on Line 2 of Algorithm 31.
- On Line 5, choose values \(x\) in decreasing order of \(B_x\).
Implement a version of Algorithm 31 that employs these heuristics and compare its performance with and without the heuristics. Note: The jointree algorithm can be used to compute the bounds \(B_x\) efficiently (see Exercise 10.20).
\(B_x\) is the pruning test that the child \((ix, \mathbf{X}\setminus\{X\})\) would run on its own Line 3, so the table \(\{B_x\}\) is a one-step lookahead over every branch. By Exercise 10.20, one inward-outward jointree propagation with evidence \(i\), MAP variables maximized out of messages and all others summed out, yields
\begin{equation*} B_x \;=\; \max_{(C_j \cap M) \setminus \{X\}} \;\sum_{C_j \setminus M} f_j(C_j)\Big|_{X=x} \end{equation*}
for every remaining MAP variable \(X \in C_j\) and every value \(x\) at once, at the \(O(n \exp(w))\) cost of the single bound the unmodified algorithm computes – so the heuristics are informationally rich but computationally free. Two things then come at no charge: \(\mathrm{MAP}^u_P(\mathbf{X},i) = \max_x B_x = M_X\) for any \(X \in \mathbf{X}\), which answers Line 3; and a child with \(B_x \le p\) may be skipped without a call, since it would return at its own Line 3 (at a leaf child no MAP variable is left, so \(B_x = \mathrm{Pr}(ix)\) and the skip agrees with Line 2).
Lines 3 to 8 become: (1) one propagation, extracting \(\{B_x\}\); (2) return if \(\max_x B_x \le p\); (3) let \(X^{\star}\) maximize \(M_X/T_X\), ties toward smaller \(T_X\); (4) visit the values of \(X^{\star}\) in decreasing \(B_x\), breaking as soon as \(B_x \le p\) – re-tested inside the loop, since \(p\) may have grown since step (1) and never falls.
Since \(M_X\) is nearly the node’s bound and so nearly independent of \(X\), maximizing \(M_X/T_X\) is minimizing the bound mass of the children that survive the incumbent \(p\): most-constrained-variable-first, measured in bound mass rather than domain size. Decreasing \(B_x\) is best-first ordering inside the depth-first search, installing a strong incumbent before any sibling is touched.
Measured on random networks – \(n\) binary variables, at most three parents per node, CPT rows from a symmetric Dirichlet with concentration \(0.5\), a random \(M\) of size \(m\), three further variables as evidence, one fixed unconstrained order per instance, the same seed instantiation for every variant, all variants returning the same MAP probability – counting BB_MAP_AUX nodes, which is also the number of propagations:
plain is Algorithm 31 verbatim; sibling adds only the free pruning of children with \(B_x \le p\); var and val add the variable and value heuristics on top of sibling; both uses all of it.
| variant | total nodes, \(n{=}16\), \(m{=}8\), 20 instances | median | total nodes, \(n{=}18\), \(m{=}10\), 12 instances | median |
|---|---|---|---|---|
| plain | 1118 | 59 | 1240 | 109 |
| sibling | 701 | 34 | 780 | 70 |
| var | 896 | 39 | 1038 | 89 |
| val | 197 | 9 | 155 | 11 |
| both | 181 | 9 | 139 | 11 |
So both is 6.2 times cheaper than plain on the smaller instances and 8.9 times cheaper on the larger ones, the advantage growing with \(m\). The medians are the sharper figure: a single root-to-leaf descent visits \(m+1\) nodes, which is exactly the heuristic median in both settings, so on a typical instance the value heuristic descends straight to an optimal leaf and the incumbent prunes every sibling with no backtracking.
Almost all of the gain is the value ordering; the \(M_X/T_X\) choice applied alone hurt (896 against 701, 1038 against 780), recovering only about ten per cent when combined. The standalone loss is the criterion’s own definition: minimizing \(T_X\) prefers variables whose surviving child has a small bound, and such a child would be pruned soon anyway, so effort goes to the least informative decisions first. Node count is a fair runtime proxy only because every variant pays one propagation per node – computing each \(B_x\) by a separate VE_MAP call would cost a factor \(2|\mathbf{X}|\) per node and turn the saving into a loss.
Exercises 10.22–10.22
We can modify Algorithm 13, RC1, from Chapter 8 to answer MPE queries by replacing summation with maximization, leading to RC MPE shown in Algorithm 33. This algorithm computes the MPE probability but not the MPE instantiations.
Recall the setting of Chapter 8. A dtree \(T\) for a Bayesian network is a full binary tree whose leaves correspond to the network CPTs (Definition 8.2); \(T^l\) and \(T^r\) denote the left and right children of node \(T\), and \(\mathrm{vars}(T)\) denotes the variables appearing at the leaves of \(T\). The cutset of a nonleaf node is
\begin{equation*} \mathrm{cutset}(T) \;=\; \bigl(\mathrm{vars}(T^l) \cap \mathrm{vars}(T^r)\bigr) \setminus \mathrm{acutset}(T), \end{equation*}
where \(\mathrm{acutset}(T)\) is the union of the cutsets of all ancestors of \(T\) (Definition 8.3). Algorithm 33 is then as follows; it is called initially on the dtree root with the given evidence \(\mathbf{e}\), and it returns the MPE probability \(\mathrm{MPE}_P(\mathbf{e}) = \max_{\mathbf{x}\sim\mathbf{e}} \Pr(\mathbf{x})\).
| RC MPE(\(T\), \(\mathbf{e}\)) |
|---|
| 1: if \(T\) is a leaf node then |
| 2: \(\quad \Theta_{X\mid\mathbf{U}} \leftarrow\) CPT associated with node \(T\) |
| 3: \(\quad \mathbf{u} \leftarrow\) instantiation of parents \(\mathbf{U}\) consistent with evidence \(\mathbf{e}\) |
| 4: \(\quad\) if \(X\) has value \(x\) in evidence \(\mathbf{e}\) then |
| 5: \(\quad\quad\) return \(\theta_{x\mid\mathbf{u}}\) |
| 6: \(\quad\) else |
| 7: \(\quad\quad\) return \(\max_x \theta_{x\mid\mathbf{u}}\) |
| 8: \(\quad\) end if |
| 9: else |
| 10: \(\quad p \leftarrow 0\) |
| 11: \(\quad \mathbf{C} \leftarrow \mathrm{cutset}(T)\) |
| 12: \(\quad\) for each instantiation \(\mathbf{c}\) consistent with evidence \(\mathbf{e}\), \(\mathbf{c} \sim \mathbf{e}\), do |
| 13: \(\quad\quad p \leftarrow \max\bigl(p,\ \mathrm{RC\,MPE}(T^l, \mathbf{e}\mathbf{c})\cdot\mathrm{RC\,MPE}(T^r, \mathbf{e}\mathbf{c})\bigr)\) |
| 14: \(\quad\) end for |
| 15: \(\quad\) return \(p\) |
| 16: end if |
(a) How can we modify Algorithm RC MPE so that it returns the number of MPE instantiations?
(b) How can we modify Algorithm RC MPE so that it returns an NNF circuit that encodes the set of MPE instantiations, that is, the circuit models are precisely the MPE instantiations?
(a) Have every call return a pair \((p, \#)\), where \(\#\) counts the maximizers.
Write \(\mathrm{free}(T,\mathbf{e}) = \mathrm{vars}(T)\setminus\mathrm{vars}(\mathbf{e})\), let \(f_T\) be the product of the CPTs at the leaves of \(T\), and let \(\mathrm{Sol}(T,\mathbf{e})\) be the set of instantiations \(\mathbf{y}\) of \(\mathrm{free}(T,\mathbf{e})\) attaining \(\mathrm{RC\,MPE}(T,\mathbf{e}) = \max_{\mathbf{y}} f_T(\mathbf{e}\mathbf{y})\), which at the root is the set of MPE instantiations for the original evidence \(\mathbf{e}_0\). Here \(\mathbf{e}\) is \(\mathbf{e}_0\) together with the cutsets of all ancestors of \(T\), so \(\mathrm{acutset}(T) \subseteq \mathrm{vars}(\mathbf{e})\). Two facts from Definition 8.3 drive both parts.
(F1) At a leaf with CPT \(\Theta_{X\mid\mathbf{U}}\) every parent \(U \in \mathbf{U}\) is already instantiated, which is what makes Line 3 well defined: \(U\) owns a CPT at some other leaf \(T^{\prime}\), so \(U \in \mathrm{vars}(A^l)\cap\mathrm{vars}(A^r)\) for the deepest common ancestor \(A\) of \(T\) and \(T^{\prime}\), whence \(U \in \mathrm{cutset}(A)\cup\mathrm{acutset}(A) \subseteq \mathrm{acutset}(T)\). Hence \(\mathrm{free}(T,\mathbf{e})\) is \(\{X\}\) or \(\emptyset\).
(F2) At a nonleaf with \(\mathbf{C} = \mathrm{cutset}(T)\) and \(\mathbf{C}^{\prime}\) its part not fixed by \(\mathbf{e}\), for every \(\mathbf{c}\sim\mathbf{e}\)
\begin{equation*} \mathrm{free}(T,\mathbf{e}) \;=\; \mathbf{C}^{\prime} \;\cup\; \mathrm{free}(T^l,\mathbf{e}\mathbf{c}) \;\cup\; \mathrm{free}(T^r,\mathbf{e}\mathbf{c}), \end{equation*}
pairwise disjointly, since \(\mathrm{vars}(T^l)\cap\mathrm{vars}(T^r) \subseteq \mathbf{C}\cup\mathrm{acutset}(T)\) is instantiated in \(\mathbf{e}\mathbf{c}\); and the two subtree sets depend on \(\mathbf{c}\) only through \(\mathrm{vars}(\mathbf{e})\cup\mathbf{C}\), hence not at all. With \(f_T = f_{T^l}f_{T^r}\), this is what licenses Line 13.
The three returns become:
- Line 5: \((\theta_{x\mid\mathbf{u}},\, 1)\), since \(\mathrm{free}(T,\mathbf{e}) = \emptyset\) by (F1).
- Line 7: \((p,\ |\{x : \theta_{x\mid\mathbf{u}} = p\}|)\) with \(p = \max_x \theta_{x\mid\mathbf{u}}\).
- Lines 10-15: with \(p_{\mathbf{c}} = p_l p_r\) and \(\#_{\mathbf{c}} = \#_l \#_r\), return
\begin{equation*} \Bigl(\,p, \ \sum_{\mathbf{c}\,:\,p_{\mathbf{c}} = p} \#_{\mathbf{c}}\Bigr), \qquad p = \max_{\mathbf{c}} p_{\mathbf{c}}, \end{equation*}
in one sweep of the loop: reset the count on a strict improvement, add on a tie.
- Whenever a call obtains \(p = 0\), discard that count and return instead \(\bigl(0,\ \prod_{X \in \mathrm{free}(T,\mathbf{e})} |X|\bigr)\), where \(|X|\) is the number of values of \(X\).
Correctness is an induction on the dtree, the leaves being (F1). At a nonleaf, (F2) factors every \(\mathbf{y}\) uniquely as \(\mathbf{c}^{\prime}\mathbf{y}_l\mathbf{y}_r\), and
\begin{equation*} f_T(\mathbf{e}\mathbf{y}) = f_{T^l}(\mathbf{e}\mathbf{c}\mathbf{y}_l)\, f_{T^r}(\mathbf{e}\mathbf{c}\mathbf{y}_r) \;\le\; p_l p_r = p_{\mathbf{c}} \;\le\; p , \end{equation*}
which is the correctness of RC MPE itself. If \(p > 0\), equality forces \(\mathbf{y}_l \in \mathrm{Sol}(T^l,\mathbf{e}\mathbf{c})\) and \(\mathbf{y}_r \in \mathrm{Sol}(T^r,\mathbf{e}\mathbf{c})\): writing \(a \le p_l\) and \(b \le p_r\) for the two factors, \(ab = p_l p_r > 0\) gives \(b > 0\), and \(a < p_l\) would give \(ab < p_l b \le p_l p_r\). Hence
\begin{equation*} \begin{aligned} \mathrm{Sol}(T,\mathbf{e}) \;&=\; \bigcup_{\mathbf{c}\,:\,p_{\mathbf{c}}=p} S_{\mathbf{c}}, \\ S_{\mathbf{c}} \;&=\; \bigl\{\mathbf{c}^{\prime}\mathbf{y}_l\mathbf{y}_r \;:\; \mathbf{y}_l \in \mathrm{Sol}(T^l,\mathbf{e}\mathbf{c}),\ \mathbf{y}_r \in \mathrm{Sol}(T^r,\mathbf{e}\mathbf{c})\bigr\}, \end{aligned} \end{equation*}
a disjoint union because distinct \(\mathbf{c}\sim\mathbf{e}\) disagree on \(\mathbf{C}^{\prime}\), and cardinalities give the recurrence. The \(p = 0\) line is not optional: the product rule undercounts there (a subtree with \(p_l = 0\) beside one with a unique maximizer), whereas in fact every \(\mathbf{y}\) has \(f_T(\mathbf{e}\mathbf{y}) = 0\), so \(\mathrm{Sol}(T,\mathbf{e})\) is all of \(\mathrm{free}(T,\mathbf{e})\) – a set read off the dtree at no search cost. Since a node with \(p > 0\) has \(p_l, p_r > 0\) for every surviving \(\mathbf{c}\), the two clauses together are exact.
The extra work is a constant per cutset instantiation, so the bounds are unchanged: \(O(n\exp(w\log n))\) time and \(O(wn)\) space by Theorem 8.2, or, caching the pair \((p,\#)\) in RC2 (Algorithm 14) under \(\mathrm{context}(T)\) (Definition 8.5), \(O(n\exp(w))\) time and space by Theorem 8.4 – caching stays sound because \(f_T\) mentions only \(\mathrm{vars}(T)\), so \(\#\) depends on \(\mathbf{e}\) exactly as \(p\) does.
(b) Have every call return \((p,\Gamma)\) instead, replacing “add counts” by an or-node and “multiply counts” by an and-node. Use the indicator variables \(\lambda_x\) of Chapter 11 and
\begin{equation*} \mathrm{term}(\mathbf{z}) \;=\; \bigwedge_{X \in \mathbf{Z}}\Bigl(\lambda_{x} \wedge \bigwedge_{x^{\prime} \ne x} \neg\lambda_{x^{\prime}}\Bigr), \qquad x \text{ the value of } X \text{ in } \mathbf{z}, \end{equation*}
so that network instantiations correspond one to one with models over the indicators.
- Line 5: \((\theta_{x\mid\mathbf{u}}, \top)\), the empty and-node; the literal for \(X\) is contributed by the root or by the ancestor whose cutset contains \(X\).
- Line 7: \(\Gamma = \bigvee_{x \,:\, \theta_{x\mid\mathbf{u}} = p} \mathrm{term}(x)\).
- Lines 10-15: \(\Gamma_{\mathbf{c}} = \mathrm{term}(\mathbf{c}^{\prime}) \wedge \Gamma_l \wedge \Gamma_r\) and \(\Gamma = \bigvee_{\mathbf{c}\,:\,p_{\mathbf{c}} = p} \Gamma_{\mathbf{c}}\).
- Zero case: \(\Gamma = \bigwedge_{X \in \mathrm{free}(T,\mathbf{e})} \bigvee_{x} \mathrm{term}(x)\).
- At the root, conjoin \(\mathrm{term}(\mathbf{e}_0)\) if the models are to be full network instantiations.
That the models of \(\Gamma\) are \(\mathrm{Sol}(T,\mathbf{e})\) is the displayed set equation of part (a) read as a recursive definition of a circuit, the or-node realizing the disjoint union and the and-node the Cartesian product over disjoint variable sets.
\(\Gamma\) is moreover a smooth d-DNNF (Section 2.7). Decomposable: the children of \(\Gamma_{\mathbf{c}}\) mention the indicators of \(\mathbf{C}^{\prime}\), \(\mathrm{free}(T^l,\mathbf{e}\mathbf{c})\) and \(\mathrm{free}(T^r,\mathbf{e}\mathbf{c})\), pairwise disjoint by (F2). Deterministic: two disjuncts of a leaf or-node contain \(\lambda_x\) and \(\neg\lambda_x\), and two disjuncts \(\Gamma_{\mathbf{c}},\Gamma_{\mathbf{d}}\) disagree on some variable of \(\mathbf{C}^{\prime}\). Smooth: every disjunct mentions the indicators of \(\mathrm{free}(T,\mathbf{e})\), the same set for every \(\mathbf{c}\) by the last clause of (F2). So the MPE instantiations enumerate from \(\Gamma\) in time linear in their number and \(|\Gamma|\) (Exercise 2.13), and the standard smooth-d-DNNF model count recovers part (a) arithmetic for arithmetic.
Writing \(\mathbf{C}^{\#}\) for the number of instantiations of \(\mathbf{C}\), each call adds one or-node, at most \(\mathbf{C}^{\#}\) and-nodes, and one \(\mathrm{term}(\mathbf{c}^{\prime})\) per and-node; since \(\sum_{X\in\mathbf{C}}|X| \le \prod_{X\in\mathbf{C}}|X| = \mathbf{C}^{\#}\), the extra factor is absorbed and \(|\Gamma| = O(n\exp(w\log n))\). Caching \((p,\Gamma)\) in RC2 shares nodes, so \(\Gamma\) becomes a DAG of size \(O(n\exp(w))\) by Theorem 8.4: the entire set of MPE instantiations costs no more than the MPE probability alone.
The Complexity of Probabilistic Inference
Exercises 11.1–11.7
Prove Theorem 11.1.
Recall the construction of Section 11.3. Given a propositional sentence \(\alpha\) over variables \(X_1,\ldots,X_n\), the Bayesian network \(N_\alpha\) has a single leaf node \(S_\alpha\) and is built inductively over the structure of \(\alpha\):
If \(\alpha\) is a single variable \(X\), its network has the single binary root node \(S_\alpha = X\) with CPT \(\theta_x = 1/2\) and \(\theta_{\bar x} = 1/2\).
If \(\alpha\) is \(\neg\beta\), the network for \(\alpha\) is obtained from the network for \(\beta\) by adding node \(S_\alpha\) with parent \(S_\beta\) and CPT (redundant rows omitted)
\(S_\beta\) \(S_\alpha\) \(\theta_{S_\alpha \mid S_\beta}\) true true 0 false true 1 If \(\alpha\) is \(\beta \vee \gamma\), the network is obtained from the networks for \(\beta\) and \(\gamma\) by adding \(S_\alpha\) with parents \(S_\beta, S_\gamma\) and CPT
\(S_\beta\) \(S_\gamma\) \(S_\alpha\) \(\theta_{S_\alpha \mid S_\beta, S_\gamma}\) true true true 1 true false true 1 false true true 1 false false true 0 If \(\alpha\) is \(\beta \wedge \gamma\), the network is obtained analogously with CPT
\(S_\beta\) \(S_\gamma\) \(S_\alpha\) \(\theta_{S_\alpha \mid S_\beta, S_\gamma}\) true true true 1 true false true 0 false true true 0 false false true 0
The networks for subsentences share the root node of a propositional variable whenever that variable occurs more than once. For instance, for \(\alpha : (X_1 \vee X_2 \vee \neg X_3) \wedge ((X_3 \wedge X_4) \vee \neg X_5)\) the network of Figure 11.1 has roots \(X_1,\ldots,X_5\); a \(\neg\) node with parent \(X_3\); a \(\vee\) node with parents \(X_1, X_2\) and that \(\neg\) node; a \(\wedge\) node with parents \(X_3, X_4\); a \(\neg\) node with parent \(X_5\); a second \(\vee\) node with parents the \(\wedge\) node and the second \(\neg\) node; and the leaf \(S_\alpha\), a \(\wedge\) node whose parents are the two \(\vee\) nodes.
Theorem 11.1 states that the distribution \(Pr\) induced by \(N_\alpha\) satisfies
\begin{equation*} Pr(x_1,\ldots,x_n, S_\alpha = \text{true}) = \begin{cases} 0, & \text{if } x_1,\ldots,x_n \models \neg\alpha \\ 1/2^n, & \text{if } x_1,\ldots,x_n \models \alpha . \end{cases} \end{equation*}
Every internal node is a logic gate. Inspecting the three CPTs, the \(\neg\) node gives parameter \(1\) to the value \(\neg S_\gamma\), the \(\vee\) node to \(S_{\gamma_1} \vee S_{\gamma_2}\), and the \(\wedge\) node to \(S_{\gamma_1} \wedge S_{\gamma_2}\), and \(0\) to the other value.
Fix an instantiation \(x_1,\ldots,x_n\) of \(\mathbf{X} = \{X_1,\ldots,X_n\}\), read also as a truth assignment, and let \(\beta_1,\ldots,\beta_m\) be the non-atomic subsentences for which the construction created a node, \(\beta_m = \alpha\). Define \(\mathbf{s}\) by
\begin{equation*} S_{\beta_j} = \text{true} \quad \text{iff} \quad x_1,\ldots,x_n \models \beta_j . \end{equation*}
Then \(\mathbf{s}\) is exactly the instantiation the gates force, by induction on subsentence structure: the atom \(X_i\) carries \(x_i\); and the \(\neg\), \(\vee\), \(\wedge\) steps are the gate identities above, using for \(\neg\) that a truth assignment is complete, so \(x_1,\ldots,x_n \not\models \gamma\) iff \(x_1,\ldots,x_n \models \neg\gamma\).
By the chain rule for Bayesian networks (Chapter 3), for any instantiation \(\mathbf{s}^{\prime}\) of the internal nodes,
\begin{equation*} Pr(x_1,\ldots,x_n,\mathbf{s}^{\prime}) = \prod_{i=1}^{n} \theta_{x_i} \cdot \prod_{j=1}^{m} \theta_{s^{\prime}_{\beta_j} \mid \mathbf{p}^{\prime}_j} = \frac{1}{2^n} \prod_{j=1}^{m} \theta_{s^{\prime}_{\beta_j} \mid \mathbf{p}^{\prime}_j}, \end{equation*}
with \(\mathbf{p}^{\prime}_j\) the parent values under \(x_1,\ldots,x_n,\mathbf{s}^{\prime}\) and each root contributing \(\theta_{x_i} = 1/2\). For \(\mathbf{s}^{\prime} = \mathbf{s}\) every remaining factor is \(1\), so \(Pr(x_1,\ldots,x_n,\mathbf{s}) = 1/2^n\). For \(\mathbf{s}^{\prime} \ne \mathbf{s}\), let \(S_{\beta_j}\) be topmost in the DAG order among the nodes of disagreement (the disagreement set is nonempty and the DAG order well founded); its parents then carry their \(\mathbf{s}\)-values, so its factor is \(0\) and the product vanishes.
Summing over the internal nodes with \(S_\alpha\) held true therefore leaves at most the one term \(\mathbf{s}\), and that term occurs iff \(s_\alpha = \text{true}\), that is iff \(x_1,\ldots,x_n \models \alpha\). Hence
\begin{equation*} Pr(x_1,\ldots,x_n, S_\alpha = \text{true}) = \begin{cases} 1/2^n, & \text{if } x_1,\ldots,x_n \models \alpha \\ 0, & \text{if } x_1,\ldots,x_n \models \neg\alpha, \end{cases} \end{equation*}
which is (11.2). \(\blacksquare\)
Prove Theorem 11.2.
Theorem 11.2 (Reducing SAT to D-MPE): let \(\alpha\) be a propositional sentence over variables \(X_1,\ldots,X_n\) and let \(N_\alpha\) be the Bayesian network constructed for it in Section 11.3 (roots \(X_1,\ldots,X_n\) with uniform CPTs, one deterministic gate node \(S_\beta\) per non-atomic subsentence \(\beta\), leaf \(S_\alpha\); see Exercise 11.1 for the construction and its CPTs). Then there is a variable instantiation \(x_1,\ldots,x_n\) that satisfies sentence \(\alpha\) if and only if there is a variable instantiation \(\mathbf{y}\) of network \(N_\alpha\) such that \(Pr(\mathbf{y}, S_\alpha = \text{true}) > 0\). (Here \(\mathbf{y}\) instantiates every variable of \(N_\alpha\) except the leaf \(S_\alpha\), so that \(\mathbf{y}, S_\alpha = \text{true}\) is a complete network instantiation.)
Both directions are Exercise 11.1, with \(\mathbf{y}\) ranging over instantiations of the roots \(\mathbf{X}\) and the gate nodes \(S_{\beta_1},\ldots,S_{\beta_{m-1}}\).
(i) If \(x_1,\ldots,x_n \models \alpha\), let \(\mathbf{s}\) be the gate instantiation it induces (\(S_{\beta_j}\) true iff \(x_1,\ldots,x_n \models \beta_j\)) and take \(\mathbf{y}\) to be \(x_1,\ldots,x_n\) together with the values \(\mathbf{s}\) gives \(S_{\beta_1},\ldots,S_{\beta_{m-1}}\). Since \(x_1,\ldots,x_n \models \alpha\) we have \(s_\alpha = \text{true}\), so \(\mathbf{y}, S_\alpha = \text{true}\) is the complete instantiation \(x_1,\ldots,x_n,\mathbf{s}\) and
\begin{equation*} Pr(\mathbf{y}, S_\alpha = \text{true}) = \frac{1}{2^n} > 0 . \end{equation*}
(ii) Conversely, suppose \(Pr(\mathbf{y}, S_\alpha = \text{true}) > 0\) and let \(x_1,\ldots,x_n\) be the restriction of \(\mathbf{y}\) to \(\mathbf{X}\). Marginalizing the gate nodes other than \(S_\alpha\) only increases the number, so
\begin{equation*} Pr(x_1,\ldots,x_n, S_\alpha = \text{true}) \ \ge\ Pr(\mathbf{y}, S_\alpha = \text{true}) \ >\ 0 , \end{equation*}
and Theorem 11.1 makes the left side \(0\) whenever \(x_1,\ldots,x_n \models \neg\alpha\). Hence \(x_1,\ldots,x_n \models \alpha\) and \(\alpha\) is satisfiable. \(\blacksquare\)
The reduction is linear time: \(N_\alpha\) has at most \(|\alpha| + n\) nodes, each gate has at most two parents, and each parameter is \(0\), \(1\), or \(1/2\).
Consider the CPT in Table 11.4. Generate a CNF encoding for this CPT according to (11.3) and (11.4). Show the weights of all variables in the encoding.
Table 11.4 is the CPT of a variable \(C\) with values \(c_1, c_2, c_3\) and parents \(A\) (values \(a_1, a_2\)) and \(B\) (values \(b_1, b_2\)):
| \(A\) | \(B\) | \(C\) | \(\theta_{C \mid A,B}\) |
|---|---|---|---|
| \(a_1\) | \(b_1\) | \(c_1\) | .2 |
| \(a_1\) | \(b_1\) | \(c_2\) | .1 |
| \(a_1\) | \(b_1\) | \(c_3\) | .7 |
| \(a_1\) | \(b_2\) | \(c_1\) | 0 |
| \(a_1\) | \(b_2\) | \(c_2\) | 0 |
| \(a_1\) | \(b_2\) | \(c_3\) | 1 |
| \(a_2\) | \(b_1\) | \(c_1\) | .5 |
| \(a_2\) | \(b_1\) | \(c_2\) | .2 |
| \(a_2\) | \(b_1\) | \(c_3\) | .3 |
| \(a_2\) | \(b_2\) | \(c_1\) | .2 |
| \(a_2\) | \(b_2\) | \(c_2\) | 0 |
| \(a_2\) | \(b_2\) | \(c_3\) | .8 |
Recall the first encoding. For each network variable \(X\) with parents \(\mathbf{U}\) there is an indicator variable \(I_x\) for each value \(x\) of \(X\) and a parameter variable \(P_{x \mid \mathbf{u}}\) for each family instantiation \(x\mathbf{u}\). The indicator clauses for a variable \(X\) with values \(x_1,\ldots,x_k\) are
\begin{equation*} I_{x_1} \vee I_{x_2} \vee \ldots \vee I_{x_k}, \qquad \neg I_{x_i} \vee \neg I_{x_j} \ \text{ for } i < j, \tag{11.3} \end{equation*}
and the parameter clauses are, for each parameter \(\theta_{x \mid u_1,\ldots,u_m}\),
\begin{equation*} I_{u_1} \wedge I_{u_2} \wedge \ldots \wedge I_{u_m} \wedge I_x \iff P_{x \mid u_1,\ldots,u_m}. \tag{11.4} \end{equation*}
Seven indicator variables,
\begin{equation*} I_{a_1},\, I_{a_2},\qquad I_{b_1},\, I_{b_2},\qquad I_{c_1},\, I_{c_2},\, I_{c_3}, \end{equation*}
and twelve parameter variables, one per row of Table 11.4,
\begin{equation*} \begin{aligned} &P_{c_1 \mid a_1 b_1},\ P_{c_2 \mid a_1 b_1},\ P_{c_3 \mid a_1 b_1},\\ &P_{c_1 \mid a_1 b_2},\ P_{c_2 \mid a_1 b_2},\ P_{c_3 \mid a_1 b_2},\\ &P_{c_1 \mid a_2 b_1},\ P_{c_2 \mid a_2 b_1},\ P_{c_3 \mid a_2 b_1},\\ &P_{c_1 \mid a_2 b_2},\ P_{c_2 \mid a_2 b_2},\ P_{c_3 \mid a_2 b_2}. \end{aligned} \end{equation*}
Indicator clauses, by (11.3), eight in all since \(A, B\) are binary and \(C\) ternary:
\begin{equation*} \begin{aligned} A:&\quad I_{a_1} \vee I_{a_2}, \qquad \neg I_{a_1} \vee \neg I_{a_2} \\ B:&\quad I_{b_1} \vee I_{b_2}, \qquad \neg I_{b_1} \vee \neg I_{b_2} \\ C:&\quad I_{c_1} \vee I_{c_2} \vee I_{c_3}, \\ &\quad \neg I_{c_1} \vee \neg I_{c_2}, \quad \neg I_{c_1} \vee \neg I_{c_3}, \quad \neg I_{c_2} \vee \neg I_{c_3}. \end{aligned} \end{equation*}
Parameter clauses, by (11.4), one equivalence per row:
\begin{equation*} \begin{aligned} I_{a_1} \wedge I_{b_1} \wedge I_{c_1} &\iff P_{c_1 \mid a_1 b_1} \\ I_{a_1} \wedge I_{b_1} \wedge I_{c_2} &\iff P_{c_2 \mid a_1 b_1} \\ I_{a_1} \wedge I_{b_1} \wedge I_{c_3} &\iff P_{c_3 \mid a_1 b_1} \\ I_{a_1} \wedge I_{b_2} \wedge I_{c_1} &\iff P_{c_1 \mid a_1 b_2} \\ I_{a_1} \wedge I_{b_2} \wedge I_{c_2} &\iff P_{c_2 \mid a_1 b_2} \\ I_{a_1} \wedge I_{b_2} \wedge I_{c_3} &\iff P_{c_3 \mid a_1 b_2} \\ I_{a_2} \wedge I_{b_1} \wedge I_{c_1} &\iff P_{c_1 \mid a_2 b_1} \\ I_{a_2} \wedge I_{b_1} \wedge I_{c_2} &\iff P_{c_2 \mid a_2 b_1} \\ I_{a_2} \wedge I_{b_1} \wedge I_{c_3} &\iff P_{c_3 \mid a_2 b_1} \\ I_{a_2} \wedge I_{b_2} \wedge I_{c_1} &\iff P_{c_1 \mid a_2 b_2} \\ I_{a_2} \wedge I_{b_2} \wedge I_{c_2} &\iff P_{c_2 \mid a_2 b_2} \\ I_{a_2} \wedge I_{b_2} \wedge I_{c_3} &\iff P_{c_3 \mid a_2 b_2} \end{aligned} \end{equation*}
Each equivalence is four CNF clauses, the IP clause
\begin{equation*} \neg I_{a_i} \vee \neg I_{b_j} \vee \neg I_{c_k} \vee P_{c_k \mid a_i b_j} \end{equation*}
and the three PI clauses
\begin{equation*} \neg P_{c_k \mid a_i b_j} \vee I_{a_i}, \quad \neg P_{c_k \mid a_i b_j} \vee I_{b_j}, \quad \neg P_{c_k \mid a_i b_j} \vee I_{c_k}, \end{equation*}
so the encoding has \(12 \times 4 + 8 = 56\) clauses over \(19\) Boolean variables.
Weights, by Theorem 11.7: \(W\!t(I_x) = W\!t(\neg I_x) = W\!t(\neg P_{x \mid \mathbf{u}}) = 1\) and \(W\!t(P_{x \mid \mathbf{u}}) = \theta_{x \mid \mathbf{u}}\), so that the family contributes \(\theta_{c_k \mid a_i b_j}\) to a model selecting \(a_i b_j c_k\), exactly the chain-rule factor.
| variable | \(W\!t(\cdot)\) | \(W\!t(\neg \cdot)\) |
|---|---|---|
| \(I_{a_1}\) | 1 | 1 |
| \(I_{a_2}\) | 1 | 1 |
| \(I_{b_1}\) | 1 | 1 |
| \(I_{b_2}\) | 1 | 1 |
| \(I_{c_1}\) | 1 | 1 |
| \(I_{c_2}\) | 1 | 1 |
| \(I_{c_3}\) | 1 | 1 |
| \(P_{c_1 \mid a_1b_1}\) | .2 | 1 |
| \(P_{c_2 \mid a_1b_1}\) | .1 | 1 |
| \(P_{c_3 \mid a_1b_1}\) | .7 | 1 |
| \(P_{c_1 \mid a_1b_2}\) | 0 | 1 |
| \(P_{c_2 \mid a_1b_2}\) | 0 | 1 |
| \(P_{c_3 \mid a_1b_2}\) | 1 | 1 |
| \(P_{c_1 \mid a_2b_1}\) | .5 | 1 |
| \(P_{c_2 \mid a_2b_1}\) | .2 | 1 |
| \(P_{c_3 \mid a_2b_1}\) | .3 | 1 |
| \(P_{c_1 \mid a_2b_2}\) | .2 | 1 |
| \(P_{c_2 \mid a_2b_2}\) | 0 | 1 |
| \(P_{c_3 \mid a_2b_2}\) | .8 | 1 |
Consider the CPT in Table 11.4. Generate a CNF encoding for this CPT according to (11.5) and (11.6). Show the weights of all variables in the encoding.
Table 11.4 is the CPT of a variable \(C\) with values \(c_1, c_2, c_3\) and parents \(A\) (values \(a_1, a_2\)) and \(B\) (values \(b_1, b_2\)):
| \(A\) | \(B\) | \(C\) | \(\theta_{C \mid A,B}\) |
|---|---|---|---|
| \(a_1\) | \(b_1\) | \(c_1\) | .2 |
| \(a_1\) | \(b_1\) | \(c_2\) | .1 |
| \(a_1\) | \(b_1\) | \(c_3\) | .7 |
| \(a_1\) | \(b_2\) | \(c_1\) | 0 |
| \(a_1\) | \(b_2\) | \(c_2\) | 0 |
| \(a_1\) | \(b_2\) | \(c_3\) | 1 |
| \(a_2\) | \(b_1\) | \(c_1\) | .5 |
| \(a_2\) | \(b_1\) | \(c_2\) | .2 |
| \(a_2\) | \(b_1\) | \(c_3\) | .3 |
| \(a_2\) | \(b_2\) | \(c_1\) | .2 |
| \(a_2\) | \(b_2\) | \(c_2\) | 0 |
| \(a_2\) | \(b_2\) | \(c_3\) | .8 |
Recall the second encoding. It assumes an ordering of the values of each variable and uses, for each network variable \(X\) with parents \(\mathbf{U}\), an indicator variable \(I_x\) for each value \(x\) of \(X\), and a parameter variable \(Q_{x \mid \mathbf{u}}\) for each family instantiation \(x\mathbf{u}\) in which \(x\) is not the last value in the ordering of \(X\). The indicator clauses are as in the first encoding,
\begin{equation*} I_{x_1} \vee I_{x_2} \vee \ldots \vee I_{x_k}, \qquad \neg I_{x_i} \vee \neg I_{x_j} \ \text{ for } i < j, \tag{11.5} \end{equation*}
and, for \(x_1 < x_2 < \cdots < x_k\) the value order of \(X\) and \(\mathbf{u} = u_1,\ldots,u_m\) an instantiation of \(\mathbf{U}\), the parameter clauses are
\begin{equation*} \begin{aligned} I_{u_1} \wedge \ldots \wedge I_{u_m} \wedge \neg Q_{x_1 \mid \mathbf{u}} \wedge \ldots \wedge \neg Q_{x_{i-1} \mid \mathbf{u}} \wedge Q_{x_i \mid \mathbf{u}} &\Longrightarrow I_{x_i}, \quad i < k \\ I_{u_1} \wedge \ldots \wedge I_{u_m} \wedge \neg Q_{x_1 \mid \mathbf{u}} \wedge \ldots \wedge \neg Q_{x_{k-1} \mid \mathbf{u}} &\Longrightarrow I_{x_k}. \end{aligned} \tag{11.6} \end{equation*}
Assume the value orders \(a_1 < a_2\), \(b_1 < b_2\), and \(c_1 < c_2 < c_3\).
The seven indicators are as in Exercise 11.3,
\begin{equation*} I_{a_1},\, I_{a_2},\qquad I_{b_1},\, I_{b_2},\qquad I_{c_1},\, I_{c_2},\, I_{c_3}, \end{equation*}
but since \(c_3\) is last in the value order of \(C\), only \(c_1\) and \(c_2\) generate parameter variables, eight rather than twelve:
\begin{equation*} \begin{aligned} &Q_{c_1 \mid a_1 b_1},\ Q_{c_2 \mid a_1 b_1},\qquad Q_{c_1 \mid a_1 b_2},\ Q_{c_2 \mid a_1 b_2},\\ &Q_{c_1 \mid a_2 b_1},\ Q_{c_2 \mid a_2 b_1},\qquad Q_{c_1 \mid a_2 b_2},\ Q_{c_2 \mid a_2 b_2}. \end{aligned} \end{equation*}
Indicator clauses, by (11.5), exactly as in Exercise 11.3:
\begin{equation*} \begin{aligned} A:&\quad I_{a_1} \vee I_{a_2}, \qquad \neg I_{a_1} \vee \neg I_{a_2} \\ B:&\quad I_{b_1} \vee I_{b_2}, \qquad \neg I_{b_1} \vee \neg I_{b_2} \\ C:&\quad I_{c_1} \vee I_{c_2} \vee I_{c_3}, \\ &\quad \neg I_{c_1} \vee \neg I_{c_2}, \quad \neg I_{c_1} \vee \neg I_{c_3}, \quad \neg I_{c_2} \vee \neg I_{c_3}. \end{aligned} \end{equation*}
Parameter clauses, by (11.6): three per parent instantiation, twelve in all. For \(\mathbf{u} = a_i b_j\),
\begin{equation*} \begin{aligned} I_{a_i} \wedge I_{b_j} \wedge Q_{c_1 \mid \mathbf{u}} &\Longrightarrow I_{c_1} \\ I_{a_i} \wedge I_{b_j} \wedge \neg Q_{c_1 \mid \mathbf{u}} \wedge Q_{c_2 \mid \mathbf{u}} &\Longrightarrow I_{c_2} \\ I_{a_i} \wedge I_{b_j} \wedge \neg Q_{c_1 \mid \mathbf{u}} \wedge \neg Q_{c_2 \mid \mathbf{u}} &\Longrightarrow I_{c_3} \end{aligned} \end{equation*}
taken over \(\mathbf{u} = a_1b_1,\, a_1b_2,\, a_2b_1,\, a_2b_2\), or in clausal form
\begin{equation*} \begin{aligned} &\neg I_{a_i} \vee \neg I_{b_j} \vee \neg Q_{c_1 \mid \mathbf{u}} \vee I_{c_1} \\ &\neg I_{a_i} \vee \neg I_{b_j} \vee Q_{c_1 \mid \mathbf{u}} \vee \neg Q_{c_2 \mid \mathbf{u}} \vee I_{c_2} \\ &\neg I_{a_i} \vee \neg I_{b_j} \vee Q_{c_1 \mid \mathbf{u}} \vee Q_{c_2 \mid \mathbf{u}} \vee I_{c_3}. \end{aligned} \end{equation*}
Weights, by Theorem 11.8: indicator literals all \(1\), and
\begin{equation*} W\!t(Q_{x \mid \mathbf{u}}) = \frac{\theta_{x \mid \mathbf{u}}} {1 - \sum_{x^{\prime} < x} \theta_{x^{\prime} \mid \mathbf{u}}}, \qquad W\!t(\neg Q_{x \mid \mathbf{u}}) = 1 - W\!t(Q_{x \mid \mathbf{u}}) , \end{equation*}
the conditional probability that \(C = x\) given that \(C\) is none of the earlier values; so \(W\!t(Q_{c_1 \mid a_1 b_1}) = .2/1 = .2\) and \(W\!t(Q_{c_2 \mid a_1 b_1}) = .1/.8 = .125\), and likewise elsewhere (Check!).
| variable | \(W\!t(\cdot)\) | \(W\!t(\neg \cdot)\) |
|---|---|---|
| \(I_{a_1}\) | 1 | 1 |
| \(I_{a_2}\) | 1 | 1 |
| \(I_{b_1}\) | 1 | 1 |
| \(I_{b_2}\) | 1 | 1 |
| \(I_{c_1}\) | 1 | 1 |
| \(I_{c_2}\) | 1 | 1 |
| \(I_{c_3}\) | 1 | 1 |
| \(Q_{c_1 \mid a_1b_1}\) | .2 | .8 |
| \(Q_{c_2 \mid a_1b_1}\) | .125 | .875 |
| \(Q_{c_1 \mid a_1b_2}\) | 0 | 1 |
| \(Q_{c_2 \mid a_1b_2}\) | 0 | 1 |
| \(Q_{c_1 \mid a_2b_1}\) | .5 | .5 |
| \(Q_{c_2 \mid a_2b_1}\) | .4 | .6 |
| \(Q_{c_1 \mid a_2b_2}\) | .2 | .8 |
| \(Q_{c_2 \mid a_2b_2}\) | 0 | 1 |
The branch weights \(q_1\), \((1-q_1)q_2\), \((1-q_1)(1-q_2)\) reproduce each row of Table 11.4, as they must:
| \(\mathbf{u}\) | \(c_1\) | \(c_2\) | \(c_3\) |
|---|---|---|---|
| \(a_1 b_1\) | .2 | \(.8 \times .125 = .1\) | \(.8 \times .875 = .7\) |
| \(a_1 b_2\) | 0 | \(1 \times 0 = 0\) | \(1 \times 1 = 1\) |
| \(a_2 b_1\) | .5 | \(.5 \times .4 = .2\) | \(.5 \times .6 = .3\) |
| \(a_2 b_2\) | .2 | \(.8 \times 0 = 0\) | \(.8 \times 1 = .8\) |
Consider Theorems 11.7 and 11.8. Provide a different weight function \(W\!t(.)\) that depends on evidence \(e\) for which the following would hold: \(Pr(e) = \mathrm{WMC}(\Delta_N)\).
Both theorems accommodate evidence \(e = e_1,\ldots,e_k\) by conjoining the indicator literals of the evidence to the CNF encoding \(\Delta_N\) of the network,
\begin{equation*} Pr(e) = \mathrm{WMC}(\Delta_N \wedge I_{e_1} \wedge \ldots \wedge I_{e_k}), \end{equation*}
with the weights of Theorem 11.7,
\begin{equation*} W\!t(I_x) = W\!t(\neg I_x) = W\!t(\neg P_{x \mid \mathbf{u}}) = 1, \qquad W\!t(P_{x \mid \mathbf{u}}) = \theta_{x \mid \mathbf{u}}, \end{equation*}
or those of Theorem 11.8,
\begin{equation*} W\!t(I_x) = W\!t(\neg I_x) = 1, \quad W\!t(Q_{x \mid \mathbf{u}}) = \frac{\theta_{x \mid \mathbf{u}}}{1 - \sum_{x^{\prime} < x} \theta_{x^{\prime} \mid \mathbf{u}}}, \quad W\!t(\neg Q_{x \mid \mathbf{u}}) = 1 - W\!t(Q_{x \mid \mathbf{u}}). \end{equation*}
The task is to move the evidence out of the sentence and into the weights, so that the plain encoding \(\Delta_N\) is left untouched.
Take \(W\!t_e\) to agree with the weight function of the relevant theorem on every parameter literal and to set
\begin{equation*} W\!t_e(I_x) = \begin{cases} 1, & \text{if } x \text{ is consistent with } e \\ 0, & \text{otherwise,} \end{cases} \qquad W\!t_e(\neg I_x) = 1 , \end{equation*}
where a value \(x\) of \(X\) is consistent with \(e\) when \(e\) does not instantiate \(X\), or instantiates it to \(x\). All weights stay nonnegative, as Definition 11.3 requires, and only the positive indicators of values ruled out by \(e\) have changed.
First encoding. The models of \(\Delta_N\) correspond one to one with network instantiations \(\mathbf{x}\) (the correspondence underlying Theorem 11.7, Table 11.2): the clauses (11.3) force one true indicator per variable, and (11.4) then forces \(P_{x \mid \mathbf{u}}\) true exactly for the family instantiations compatible with \(\mathbf{x}\), every other literal occurring negatively with weight \(1\). So, by the chain rule,
\begin{equation*} \begin{aligned} W\!t_e(\omega_{\mathbf{x}}) &= \Big[\prod_{x \in \mathbf{x}} W\!t_e(I_x)\Big] \cdot \prod_{\theta_{x \mid \mathbf{u}} \sim \mathbf{x}} \theta_{x \mid \mathbf{u}} = \Big[\prod_{x \in \mathbf{x}} W\!t_e(I_x)\Big] \cdot Pr(\mathbf{x}), \end{aligned} \end{equation*}
and the bracket is \(1\) if \(\mathbf{x} \sim e\) and \(0\) otherwise, so \(\mathrm{WMC}(\Delta_N) = \sum_{\mathbf{x} \sim e} Pr(\mathbf{x}) = Pr(e)\).
Second encoding. Here the models are not in one-to-one correspondence – the \(Q\) blocks of the unselected parent instantiations are unconstrained by (11.6) – so partition them by the instantiation \(\mathbf{x}\) they select. Since \(W\!t_e\) leaves every parameter weight unchanged, the argument for Theorem 11.8 gives each block parameter-weight total \(Pr(\mathbf{x})\), the free \(Q\) variables contributing \(W\!t(Q) + W\!t(\neg Q) = 1\) apiece. Every model of a block has the same indicator literals, hence the same extra factor \(\prod_{x \in \mathbf{x}} W\!t_e(I_x)\), again \(1\) iff \(\mathbf{x} \sim e\). So \(\mathrm{WMC}(\Delta_N) = \sum_{\mathbf{x} \sim e} Pr(\mathbf{x}) = Pr(e)\). \(\blacksquare\)
Method (2): keep \(W\!t(I_x) = 1\) everywhere and instead set \(W\!t_e(\neg I_x) = 0\) for the values \(x = e(X)\) asserted by the evidence. A model whose instantiation disagrees with \(e\) at \(X\) then contains \(\neg I_{e(X)}\) and has weight \(0\), while one agreeing with \(e\) is unaffected, and the two computations above go through unchanged.
Consider the CPT in Table 11.4. Generate a W-MAXSAT encoding for this CPT.
Table 11.4 is the CPT of a variable \(C\) with values \(c_1, c_2, c_3\) and parents \(A\) (values \(a_1, a_2\)) and \(B\) (values \(b_1, b_2\)):
| \(A\) | \(B\) | \(C\) | \(\theta_{C \mid A,B}\) |
|---|---|---|---|
| \(a_1\) | \(b_1\) | \(c_1\) | .2 |
| \(a_1\) | \(b_1\) | \(c_2\) | .1 |
| \(a_1\) | \(b_1\) | \(c_3\) | .7 |
| \(a_1\) | \(b_2\) | \(c_1\) | 0 |
| \(a_1\) | \(b_2\) | \(c_2\) | 0 |
| \(a_1\) | \(b_2\) | \(c_3\) | 1 |
| \(a_2\) | \(b_1\) | \(c_1\) | .5 |
| \(a_2\) | \(b_1\) | \(c_2\) | .2 |
| \(a_2\) | \(b_1\) | \(c_3\) | .3 |
| \(a_2\) | \(b_2\) | \(c_1\) | .2 |
| \(a_2\) | \(b_2\) | \(c_2\) | 0 |
| \(a_2\) | \(b_2\) | \(c_3\) | .8 |
Recall the reduction of MPE to W-MAXSAT of Section 11.7. It uses one indicator variable \(I_x\) per value \(x\) of each network variable \(X\), and no parameter variables. For each variable \(X\) with values \(x_1,\ldots,x_k\) it generates the hard indicator clauses
\begin{equation*} (I_{x_1} \vee I_{x_2} \vee \ldots \vee I_{x_k})^{W} \tag{11.8} \end{equation*}
\begin{equation*} (\neg I_{x_i} \vee \neg I_{x_j})^{W}, \quad \text{for } i < j, \tag{11.9} \end{equation*}
and for each network parameter \(\theta_{x \mid u_1,\ldots,u_m}\) the single soft clause
\begin{equation*} (\neg I_x \vee \neg I_{u_1} \vee \ldots \vee \neg I_{u_m})^{-\log \theta_{x \mid u_1,\ldots,u_m}}, \tag{11.10} \end{equation*}
where \(-\log 0\) is defined to be the special hard weight \(W\), and \(W\) is chosen larger than the sum of the weights of all soft clauses.
Only the seven indicators,
\begin{equation*} I_{a_1},\, I_{a_2},\qquad I_{b_1},\, I_{b_2},\qquad I_{c_1},\, I_{c_2},\, I_{c_3}, \end{equation*}
with no parameter variables at all. The hard indicator clauses, by (11.8) and (11.9), are
\begin{equation*} \begin{aligned} A:&\quad (I_{a_1} \vee I_{a_2})^{W}, \qquad (\neg I_{a_1} \vee \neg I_{a_2})^{W} \\ B:&\quad (I_{b_1} \vee I_{b_2})^{W}, \qquad (\neg I_{b_1} \vee \neg I_{b_2})^{W} \\ C:&\quad (I_{c_1} \vee I_{c_2} \vee I_{c_3})^{W}, \\ &\quad (\neg I_{c_1} \vee \neg I_{c_2})^{W}, \quad (\neg I_{c_1} \vee \neg I_{c_3})^{W}, \quad (\neg I_{c_2} \vee \neg I_{c_3})^{W}, \end{aligned} \end{equation*}
and (11.10) gives one clause per row of Table 11.4:
\begin{equation*} \begin{aligned} (\neg I_{c_1} \vee \neg I_{a_1} \vee \neg I_{b_1})^{-\log .2} &\quad (\neg I_{c_2} \vee \neg I_{a_1} \vee \neg I_{b_1})^{-\log .1} \\ (\neg I_{c_3} \vee \neg I_{a_1} \vee \neg I_{b_1})^{-\log .7} &\quad (\neg I_{c_1} \vee \neg I_{a_1} \vee \neg I_{b_2})^{W} \\ (\neg I_{c_2} \vee \neg I_{a_1} \vee \neg I_{b_2})^{W} &\quad (\neg I_{c_3} \vee \neg I_{a_1} \vee \neg I_{b_2})^{-\log 1} \\ (\neg I_{c_1} \vee \neg I_{a_2} \vee \neg I_{b_1})^{-\log .5} &\quad (\neg I_{c_2} \vee \neg I_{a_2} \vee \neg I_{b_1})^{-\log .2} \\ (\neg I_{c_3} \vee \neg I_{a_2} \vee \neg I_{b_1})^{-\log .3} &\quad (\neg I_{c_1} \vee \neg I_{a_2} \vee \neg I_{b_2})^{-\log .2} \\ (\neg I_{c_2} \vee \neg I_{a_2} \vee \neg I_{b_2})^{W} &\quad (\neg I_{c_3} \vee \neg I_{a_2} \vee \neg I_{b_2})^{-\log .8} \end{aligned} \end{equation*}
The three zero parameters give hard clauses, since \(-\log 0 = W\); the unit parameter \(\theta_{c_3 \mid a_1 b_2}\) gives weight \(-\log 1 = 0\) and may be dropped. In natural logarithms (the base only rescales every weight by a common positive factor):
| \(A\) | \(B\) | \(C\) | \(\theta_{C \mid A,B}\) | clause weight \(-\ln \theta\) |
|---|---|---|---|---|
| \(a_1\) | \(b_1\) | \(c_1\) | .2 | 1.6094 |
| \(a_1\) | \(b_1\) | \(c_2\) | .1 | 2.3026 |
| \(a_1\) | \(b_1\) | \(c_3\) | .7 | 0.3567 |
| \(a_1\) | \(b_2\) | \(c_1\) | 0 | \(W\) (hard) |
| \(a_1\) | \(b_2\) | \(c_2\) | 0 | \(W\) (hard) |
| \(a_1\) | \(b_2\) | \(c_3\) | 1 | 0 |
| \(a_2\) | \(b_1\) | \(c_1\) | .5 | 0.6931 |
| \(a_2\) | \(b_1\) | \(c_2\) | .2 | 1.6094 |
| \(a_2\) | \(b_1\) | \(c_3\) | .3 | 1.2040 |
| \(a_2\) | \(b_2\) | \(c_1\) | .2 | 1.6094 |
| \(a_2\) | \(b_2\) | \(c_2\) | 0 | \(W\) (hard) |
| \(a_2\) | \(b_2\) | \(c_3\) | .8 | 0.2231 |
The soft weights sum to \(9.6078\), so were this CPT the whole encoding any \(W > 9.6078\), say \(W = 10\), would serve; in a full network \(W\) must exceed the sum over all clauses.
A truth assignment violating an indicator clause pays at least \(W\) and cannot be optimal, so the optimal assignments are network instantiations; one selecting \(a_i b_j c_k\) violates exactly the (11.10) clause of \(\theta_{c_k \mid a_i b_j}\), all others having a true negative literal, so over the whole network
\begin{equation*} Pn(\hat{\omega}) = \sum_{\theta_{x \mid \mathbf{u}} \sim \mathbf{x}} -\log \theta_{x \mid \mathbf{u}} = -\log Pr(\mathbf{x}) , \end{equation*}
and minimizing the penalty – equivalently maximizing the weight, by Definition 11.4 – yields an MPE instantiation.
Consider the class of Bayesian networks in which every variable is binary and every nonroot CPT is deterministic (that is, contains only zero/one parameters). Describe a corresponding reduction to WMC with a CNF encoding that includes a single Boolean variable for each network node, no variables for network parameters, and no more than one clause for each network parameter.
Use one Boolean variable per node, also written \(X\), reading \(X\) true as the value \(x\) and \(X\) false as \(\bar{x}\); binarity then already encodes “exactly one value of \(X\) is chosen”, so no indicator clauses (11.3) and no parameter variables are needed. Write \(\ell_x = X\) and \(\ell_{\bar x} = \neg X\).
Clauses. Determinism makes exactly one of \(\theta_{x \mid \mathbf{u}}, \theta_{\bar x \mid \mathbf{u}}\) zero for each nonroot node \(X\) and each parent instantiation \(\mathbf{u} = u_1,\ldots,u_m\); for that value \(v\) generate the one clause
\begin{equation*} \neg \ell_{u_1} \vee \ldots \vee \neg \ell_{u_m} \vee \neg \ell_{v} , \end{equation*}
that is, \(\ell_{u_1} \wedge \ldots \wedge \ell_{u_m} \Longrightarrow \neg \ell_v\): the context \(\mathbf{u}\) rules out the value \(v\). Roots generate no clause.
Weights. \(W\!t(X) = \theta_x\) and \(W\!t(\neg X) = \theta_{\bar x}\) at a root, and \(W\!t(X) = W\!t(\neg X) = 1\) at a nonroot.
Size. Exactly \(n\) Boolean variables, and exactly one clause of \(m+1\) literals per pair of a nonroot node and a parent instantiation – one per two nonroot parameters, hence strictly fewer than one per network parameter, as required.
Correctness. Truth assignments \(\omega_{\mathbf{x}}\) correspond one to one with network instantiations \(\mathbf{x}\), and \(\omega_{\mathbf{x}}\) violates a clause iff some nonroot factor of \(Pr(\mathbf{x}) = \prod_X \theta_{x \mid \mathbf{u}}\) is zero: the clause for \(v\mathbf{u}\) is violated exactly when \(v\mathbf{u} \sim \mathbf{x}\) with \(\theta_{v \mid \mathbf{u}} = 0\), and every clause of \(\Delta_N\) arises this way. (This is not the same as “\(\omega_{\mathbf{x}} \models \Delta_N\) iff \(Pr(\mathbf{x}) > 0\)”, since a root parameter may itself be \(0\).) Every nonroot parameter being \(0\) or \(1\), a model therefore has every nonroot factor equal to \(1\), so
\begin{equation*} W\!t(\omega_{\mathbf{x}}) = \prod_{X \text{ root}} \theta_{x} = Pr(\mathbf{x}) \end{equation*}
whether or not some root parameter vanishes, while a nonmodel has \(Pr(\mathbf{x}) = 0\). Nonmodels may thus be added back for free:
\begin{equation*} \mathrm{WMC}(\Delta_N) = \sum_{\omega_{\mathbf{x}} \models \Delta_N} Pr(\mathbf{x}) = \sum_{\mathbf{x}} Pr(\mathbf{x}) = 1 , \end{equation*}
and conjoining the unit clauses \(\ell_{e_1}, \ldots, \ell_{e_k}\) for evidence \(e = e_1,\ldots,e_k\) retains exactly the models with \(\mathbf{x} \sim e\), so
\begin{equation*} \mathrm{WMC}(\Delta_N \wedge \ell_{e_1} \wedge \ldots \wedge \ell_{e_k}) = \sum_{\mathbf{x} \sim e} Pr(\mathbf{x}) = Pr(e), \end{equation*}
the analogue of Theorem 11.7 here. (Evidence may equally be folded into the weights as in Exercise 11.5.)
For instance, the AND gate \(\theta_{x \mid u_1 u_2} = 1\), \(\theta_{x \mid \mathbf{u}} = 0\) otherwise, produces four clauses, one per parent instantiation:
| parent instantiation | \(\theta\) that is \(0\) | clause |
|---|---|---|
| \(u_1 u_2\) | \(\theta_{\bar x \mid u_1 u_2}\) | \(\neg U_1 \vee \neg U_2 \vee X\) |
| \(u_1 \bar u_2\) | \(\theta_{x \mid u_1 \bar u_2}\) | \(\neg U_1 \vee U_2 \vee \neg X\) |
| \(\bar u_1 u_2\) | \(\theta_{x \mid \bar u_1 u_2}\) | \(U_1 \vee \neg U_2 \vee \neg X\) |
| \(\bar u_1 \bar u_2\) | \(\theta_{x \mid \bar u_1 \bar u_2}\) | \(U_1 \vee U_2 \vee \neg X\) |
which together are \(X \iff U_1 \wedge U_2\), with \(X\) carrying weight \(1\) on both literals.
Exercises 11.8–11.10
Prove Theorem 11.8.
For reference, Theorem 11.8 concerns the second CNF encoding of a Bayesian network, given in Section 11.6.2. Let \(N\) be a Bayesian network over variables \(X_1,\dots,X_n\). For each network variable \(X\) with parents \(\mathbf{U}\), fix a total order \(x_1 < x_2 < \dots < x_k\) on the values of \(X\). The encoding uses two kinds of Boolean variables:
- an indicator variable \(I_x\) for each value \(x\) of each network variable \(X\);
- a parameter variable \(Q_{x|\mathbf{u}}\) for each instantiation \(x\mathbf{u}\) of a family \(X\mathbf{U}\) in which \(x\) is not the last value of \(X\) in the value order.
The CNF \(\Delta_N\) consists of the indicator clauses, generated for each variable \(X\) with values \(x_1,\dots,x_k\),
\begin{equation*} I_{x_1} \vee I_{x_2} \vee \dots \vee I_{x_k}, \qquad \neg I_{x_i} \vee \neg I_{x_j} \ \ \text{for } i < j, \tag{11.5} \end{equation*}
together with the parameter clauses, generated for each variable \(X\) and each instantiation \(\mathbf{u} = u_1,\dots,u_m\) of its parents \(\mathbf{U}\),
\begin{equation*} \begin{aligned} I_{u_1} \wedge \dots \wedge I_{u_m} \wedge \neg Q_{x_1|\mathbf{u}} \wedge \dots \wedge \neg Q_{x_{i-1}|\mathbf{u}} \wedge Q_{x_i|\mathbf{u}} &\Rightarrow I_{x_i}, \quad i < k,\\ I_{u_1} \wedge \dots \wedge I_{u_m} \wedge \neg Q_{x_1|\mathbf{u}} \wedge \dots \wedge \neg Q_{x_{k-1}|\mathbf{u}} &\Rightarrow I_{x_k}. \end{aligned} \tag{11.6} \end{equation*}
Theorem 11.8 states: let \(N\) be a Bayesian network inducing probability distribution \(Pr\) and let \(\Delta_N\) be its CNF encoding given by (11.5) and (11.6). For any evidence \(e = e_1,\dots,e_k\) we have
\begin{equation*} Pr(e) \;=\; \mathrm{WMC}(\Delta_N \wedge I_{e_1} \wedge \dots \wedge I_{e_k}), \end{equation*}
given the following weights:
\begin{equation*} \begin{aligned} Wt(I_x) &= 1, & Wt(\neg I_x) &= 1,\\ Wt(Q_{x|\mathbf{u}}) &= \frac{\theta_{x|\mathbf{u}}} {1 - \sum_{x^{\prime} < x} \theta_{x^{\prime}|\mathbf{u}}}, & Wt(\neg Q_{x|\mathbf{u}}) &= 1 - Wt(Q_{x|\mathbf{u}}). \end{aligned} \end{equation*}
The models of \(\Delta_N\) fall into classes of total weight \(Pr(\mathbf{x})\), one class per network instantiation; summing over \(\mathbf{x} \sim e\) is then the theorem.
The indicator clauses (11.5) make exactly one \(I_x\) true per network variable, so every model \(\omega\) of \(\Delta_N\) determines an instantiation \(\mathbf{x}(\omega)\), and the classes
\begin{equation*} M(\mathbf{x}) \;=\; \{\, \omega \models \Delta_N \;:\; \mathbf{x}(\omega) = \mathbf{x} \,\} \end{equation*}
are disjoint and exhaust the models.
Fix \(\mathbf{x}\). In \(M(\mathbf{x})\) the indicators are pinned and weigh \(1\), so a model’s weight is the product over its parameter literals; these split into blocks \(Q_{x_1|\mathbf{u}},\dots,Q_{x_{k-1}|\mathbf{u}}\), one per family \(X\mathbf{U}\) and parent instantiation \(\mathbf{u}\), each block mentioned only by its own clauses of (11.6). Abbreviate \(\theta_i = \theta_{x_i|\mathbf{u}}\), \(S_i = \sum_{j<i}\theta_j\), and \(\lambda_i = Wt(Q_{x_i|\mathbf{u}}) = \theta_i/(1-S_i)\); a CPT row sums to \(1\), so \(S_i + \theta_i \le 1\) and \(0 \le \lambda_i \le 1\), legitimate weights, with the convention \(\lambda_i = 0\) when \(S_i = 1\).
(i) \(\mathbf{u} \not\sim \mathbf{x}\). Some \(I_{u_j}\) is false, so every antecedent in (11.6) for this \(\mathbf{u}\) fails, the block is free, and its contribution factorizes to \(\prod_{i<k}\bigl(\lambda_i + (1-\lambda_i)\bigr) = 1\).
(ii) \(\mathbf{u} \sim \mathbf{x}\), with \(\mathbf{x}\) setting \(X = x_r\). Let \(f\) be the block’s first true index, \(f = \min\{i<k : Q_{x_i|\mathbf{u}} \text{ true}\}\) and \(f = k\) if there is none. The clause of index \(i<k\) has a true antecedent precisely when \(f = i\), and the last clause precisely when \(f = k\), while \(I_{x_i}\) is true only for \(i = r\); hence the group is satisfied iff \(f = r\). Admissibility thus fixes \(\neg Q_{x_1|\mathbf{u}},\dots,\neg Q_{x_{r-1}|\mathbf{u}}\) and, when \(r<k\), also \(Q_{x_r|\mathbf{u}}\), leaving a free tail that sums to \(1\) as in (i). Since \(1-\lambda_j = (1-S_{j+1})/(1-S_j)\) telescopes to \(\prod_{j<i}(1-\lambda_j) = 1-S_i\), the block contributes
\begin{equation*} \lambda_r \prod_{j<r} (1-\lambda_j) = \frac{\theta_r}{1-S_r}(1-S_r) = \theta_r \quad (r<k), \qquad \prod_{j<k} (1-\lambda_j) = 1 - S_k = \theta_k \quad (r=k), \end{equation*}
that is, \(\theta_{x|\mathbf{u}}\) with \(x\mathbf{u} \sim \mathbf{x}\) in both cases. (If \(S_i = 1\) for a least \(i\), then \(\prod_{j<i}(1-\lambda_j) = 1-S_i = 0\) and \(\theta_r = 0\) for all \(r \ge i\), so both sides of each identity vanish.)
Each family contributes exactly one block of type (ii), namely that of its unique parent instantiation compatible with \(\mathbf{x}\), so multiplying over all blocks and applying the chain rule (Chapter 3),
\begin{equation*} \sum_{\omega \in M(\mathbf{x})} Wt(\omega) \;=\; \prod_{\theta_{x|\mathbf{u}} \sim \mathbf{x}} \theta_{x|\mathbf{u}} \;=\; Pr(\mathbf{x}). \end{equation*}
Finally, a model of \(\Delta = \Delta_N \wedge I_{e_1} \wedge \dots \wedge I_{e_k}\) is a model of \(\Delta_N\) with \(\mathbf{x}(\omega) \sim e\), one indicator per variable being true, so the models of \(\Delta\) are the disjoint union of the \(M(\mathbf{x})\) over \(\mathbf{x} \sim e\) and
\begin{equation*} \mathrm{WMC}(\Delta) = \sum_{\mathbf{x} \sim e} \ \sum_{\omega \in M(\mathbf{x})} Wt(\omega) = \sum_{\mathbf{x} \sim e} Pr(\mathbf{x}) = Pr(e). \qquad \blacksquare \end{equation*}
Show how we can extend Theorems 11.7 and 11.8 to handle a more general type of evidence in which we may not know the exact value of a multivalued variable but only that some of its values are impossible.
For reference: Theorem 11.7 concerns the first CNF encoding of Section 11.6.1, which uses an indicator variable \(I_x\) for each value \(x\) of each network variable \(X\) and a parameter variable \(P_{x|\mathbf{u}}\) for each family instantiation \(x\mathbf{u}\), with indicator clauses
\begin{equation*} I_{x_1} \vee \dots \vee I_{x_k}, \qquad \neg I_{x_i} \vee \neg I_{x_j} \ \ \text{for } i<j, \tag{11.3} \end{equation*}
and parameter clauses
\begin{equation*} I_{u_1} \wedge \dots \wedge I_{u_m} \wedge I_x \iff P_{x|u_1,\dots,u_m}. \tag{11.4} \end{equation*}
It states that \(Pr(e) = \mathrm{WMC}(\Delta_N \wedge I_{e_1} \wedge \dots \wedge I_{e_k})\) under the weights \(Wt(I_x) = Wt(\neg I_x) = Wt(\neg P_{x|\mathbf{u}}) = 1\) and \(Wt(P_{x|\mathbf{u}}) = \theta_{x|\mathbf{u}}\). Theorem 11.8 states the analogous identity for the second encoding of Section 11.6.2, given by the indicator clauses (11.5) — which are identical to (11.3) — and the parameter clauses (11.6), under the weights \(Wt(I_x) = Wt(\neg I_x) = 1\), \(Wt(Q_{x|\mathbf{u}}) = \theta_{x|\mathbf{u}}/(1 - \sum_{x^{\prime}<x}\theta_{x^{\prime}|\mathbf{u}})\) and \(Wt(\neg Q_{x|\mathbf{u}}) = 1 - Wt(Q_{x|\mathbf{u}})\).
In both theorems the evidence \(e = e_1,\dots,e_k\) is an instantiation: it pins down the exact value of each of \(k\) variables. The task is to handle instead evidence of the form “variable \(X\) is known not to take any of the values \(x \notin \Lambda_X\),” for an arbitrary set \(\Lambda_X\) of surviving values.
Replace the evidence unit clauses by the disjunction of the surviving indicators: writing \(\Lambda_{E_i} \subseteq \mathrm{val}(E_i)\) for the values of the observed variable \(E_i\) that have not been ruled out and \(e = \bigwedge_{i=1}^{k}(E_i \in \Lambda_{E_i})\),
\begin{equation*} \Delta_N^{e} \;=\; \Delta_N \wedge \bigwedge_{i=1}^{k} \Big( \bigvee_{x \in \Lambda_{E_i}} I_{x} \Big), \qquad Pr(e) \;=\; \mathrm{WMC}(\Delta_N^{e}), \end{equation*}
with the weights of Theorem 11.7 or Theorem 11.8 left unchanged.
Both theorems rest on two facts established in their proofs (Exercise 11.8 for the second encoding): every model \(\omega\) of \(\Delta_N\) makes exactly one indicator true per network variable, by the clauses (11.3) = (11.5), and so determines an instantiation \(\mathbf{x}(\omega)\); and the classes \(M(\mathbf{x}) = \{\omega \models \Delta_N : \mathbf{x}(\omega) = \mathbf{x}\}\) partition the models with \(\sum_{\omega \in M(\mathbf{x})} Wt(\omega) = Pr(\mathbf{x})\) – the latter by applying the theorem with the complete instantiation \(\mathbf{x}\) as the evidence. Since \(\omega\) makes exactly one indicator of \(E_i\) true, it satisfies the added clause iff \(\mathbf{x}(\omega)\) gives \(E_i\) a value in \(\Lambda_{E_i}\); hence \(\omega \models \Delta_N^{e}\) iff \(\omega \models \Delta_N\) and \(\mathbf{x}(\omega) \models e\), and
\begin{equation*} \mathrm{WMC}(\Delta_N^{e}) = \sum_{\mathbf{x} \models e} \ \sum_{\omega \in M(\mathbf{x})} Wt(\omega) = \sum_{\mathbf{x} \models e} Pr(\mathbf{x}) = Pr(e), \end{equation*}
the last step being the definition of the probability of an event. Only the indicator clauses were used, and the two encodings share them. Singleton \(\Lambda_{E_i}\) recovers the two theorems verbatim; \(\Lambda_{E_i} = \emptyset\) makes the CNF unsatisfiable, correctly returning \(0 = Pr(e)\); and modulo \(\Delta_N\) the added clause is equivalent to the unit clauses \(\neg I_x\) for \(x \notin \Lambda_{E_i}\), which a model counter propagates away.
Method (2): leave \(\Delta_N\) untouched and change only the indicator weights, as in Exercise 11.5 – \(Wt_e(I_x) = 0\) when \(x\) is a ruled-out value of an observed variable and \(1\) otherwise, \(Wt_e(\neg I_x) = 1\), parameter weights unchanged. A model \(\omega \in M(\mathbf{x})\) carries exactly one positive indicator per variable, so \(Wt_e(\omega) = Wt(\omega)\) when \(\mathbf{x} \models e\) and \(0\) otherwise, and summing by class gives \(Pr(e)\) again. This is the version to use when one compiled structure must answer many evidence sets, only the leaf weights changing.
Show that we can drop the indicator clauses given in (11.9) without affecting the correctness of the MPE to W-MAXSAT reduction given in Section 11.7.
For reference: in the reduction of Section 11.7 a Bayesian network \(N\) over variables \(X_1,\dots,X_n\) is encoded as a weighted CNF whose only Boolean variables are the indicators \(I_x\), one for each value \(x\) of each network variable \(X\). For each network variable \(X\) with values \(x_1,\dots,x_k\) we generate the hard indicator clauses
\begin{equation*} (I_{x_1} \vee I_{x_2} \vee \dots \vee I_{x_k})^{W} \tag{11.8} \end{equation*}
\begin{equation*} (\neg I_{x_i} \vee \neg I_{x_j})^{W}, \qquad \text{for } i < j, \tag{11.9} \end{equation*}
and for each network parameter \(\theta_{x|u_1,\dots,u_m}\) we generate the parameter clause
\begin{equation*} (\neg I_x \vee \neg I_{u_1} \vee \dots \vee \neg I_{u_m})^{-\log \theta_{x|u_1,\dots,u_m}}, \tag{11.10} \end{equation*}
where \(-\log 0\) is defined to be \(W\), so a zero parameter also yields a hard clause. The special weight \(W\) is chosen greater than the sum of the weights of all soft clauses. Definition 11.4 poses W-MAXSAT as the problem of finding a truth assignment of maximal weight \(Wt(\hat{\omega}) = \sum_{\hat{\omega} \models \alpha_i} w_i\). Section 11.7 then defines the penalty of a truth assignment as the total weight of the clauses it violates, \(Pn(\hat{\omega}) = \sum_{\hat{\omega} \not\models \alpha_i} w_i\), and notes that \(Wt(\hat{\omega}) + Pn(\hat{\omega})\) is the constant sum of all clause weights, so W-MAXSAT is equivalently the problem of finding an assignment of minimum penalty. A truth assignment \(\hat{\omega}\) corresponds to a network instantiation \(x_1,\dots,x_n\) when \(I_{x_1},\dots,I_{x_n}\) appear positively in \(\hat{\omega}\) and all other indicators appear negatively; Section 11.7 shows that such an assignment has penalty \(-\log Pr(x_1,\dots,x_n)\).
Show that if the clauses (11.9) are deleted from the encoding — keeping only (11.8) and (11.10) — then a minimum-penalty truth assignment still yields an MPE instantiation.
Deleting (11.9) is harmless because the surviving CNF \(\Phi\) – the hard clauses (11.8) together with the parameter clauses (11.10) – has no clause of mixed polarity: (11.8) is all positive indicators and (11.10) all negated ones. So turning an indicator from true to false can only satisfy more parameter clauses, and extra true indicators never pay. (The sum of soft weights is unchanged by deleting hard clauses, so the same \(W\) serves.)
(i) The minimum penalty is below \(W\). Since \(\sum_{\mathbf{x}} Pr(\mathbf{x}) = 1\), some \(\mathbf{x}^{0}\) has \(Pr(\mathbf{x}^{0}) > 0\); its corresponding assignment \(\hat{\omega}^{0}\) satisfies every clause (11.8), and every hard clause (11.10) as well – such a clause has \(\theta_{x|\mathbf{u}} = 0\) and is violated only when that parameter is compatible with \(\mathbf{x}^{0}\), which would force \(Pr(\mathbf{x}^{0}) = 0\). Hence \(Pn(\hat{\omega}^{0}) = -\log Pr(\mathbf{x}^{0}) < W\), so any minimum-penalty \(\hat{\omega}\) satisfies every hard clause and in particular makes at least one indicator true per network variable.
(ii) Pruning extra true indicators never costs. Given such an \(\hat{\omega}\), choose one true indicator \(I_{x^{\ast}}\) per variable and let \(\hat{\omega}^{\prime}\) set every other indicator false. Every clause satisfied by \(\hat{\omega}\) is still satisfied: a clause (11.8) by \(I_{x^{\ast}}\), which stays true; a clause (11.10) by whichever literal \(\neg I_y\) satisfied it, since indicators only move from true to false. So \(Pn(\hat{\omega}^{\prime}) \le Pn(\hat{\omega}) = p^{\ast}\), whence \(\hat{\omega}^{\prime}\) is optimal too, and it corresponds to an instantiation \(\mathbf{x}^{\ast}\).
(iii) The penalty of a corresponding assignment, as computed in Section 11.7 without ever using (11.9): a clause (11.10) is violated by \(\hat{\omega}^{\prime}\) exactly when its parameter is compatible with \(\mathbf{x}\), so by the chain rule
\begin{equation*} Pn(\hat{\omega}^{\prime}) = \sum_{\theta_{x|\mathbf{u}} \sim \mathbf{x}} -\log \theta_{x|\mathbf{u}} = -\log Pr(\mathbf{x}). \end{equation*}
Under the convention \(-\log 0 = W\) this is an equality of symbols when \(Pr(\mathbf{x}) = 0\) (with \(t\) zero compatible parameters the penalty is \(tW\)), but all that is used below is
\begin{equation*} \begin{aligned} Pr(\mathbf{x}) > 0 &\ \Rightarrow\ Pn(\hat{\omega}^{\prime}) = -\log Pr(\mathbf{x}) < W,\\ Pr(\mathbf{x}) = 0 &\ \Rightarrow\ Pn(\hat{\omega}^{\prime}) \ge W . \end{aligned} \end{equation*}
Since \(p^{\ast} < W\) by (i), (iii) gives \(Pr(\mathbf{x}^{\ast}) > 0\) and \(p^{\ast} = -\log Pr(\mathbf{x}^{\ast})\). Every instantiation \(\mathbf{x}\) has a corresponding assignment competing for the minimum, so \(-\log Pr(\mathbf{x}) \ge p^{\ast}\) whenever \(Pr(\mathbf{x}) > 0\), that is \(Pr(\mathbf{x}) \le Pr(\mathbf{x}^{\ast})\), and trivially so when \(Pr(\mathbf{x}) = 0\). Hence \(\mathbf{x}^{\ast}\) is an MPE instantiation and \(p^{\ast} = -\log \max_{\mathbf{x}} Pr(\mathbf{x})\), the guarantee of the original encoding. The choice function in (ii) was arbitrary, so any selection of one true indicator per variable decodes a minimum-penalty assignment to an MPE.
Evidence asserted by hard unit clauses \(I_{e_1},\dots,I_{e_k}\) changes nothing, provided \(Pr(e) > 0\) so that (i) still finds a positive-probability \(\mathbf{x}^{0} \sim e\): take \(I_{e_i}\) as the chosen indicator of \(E_i\) in (ii), and \(\hat{\omega}^{\prime}\) still satisfies the unit clauses.
Compiling Bayesian Networks
Exercises 12.1–12.7
Consider the arithmetic circuit in Figure 12.13. The circuit is built over three binary variables \(A\), \(B\), \(C\) (values \(a_1,a_2\), \(b_1,b_2\), \(c_1,c_2\)) and it is the compiled form of the naive-Bayes network \(B \leftarrow A \rightarrow C\). Its leaves are the indicators \(\lambda_{a_1},\lambda_{a_2},\lambda_{b_1},\lambda_{b_2}, \lambda_{c_1},\lambda_{c_2}\) and the parameters, whose values are printed in the figure:
| parameter | value | parameter | value |
|---|---|---|---|
| \(\theta_{a_1}\) | .1 | \(\theta_{a_2}\) | .9 |
| \(\theta_{b_1\mid a_1}\) | .2 | \(\theta_{b_2\mid a_1}\) | .8 |
| \(\theta_{b_1\mid a_2}\) | .3 | \(\theta_{b_2\mid a_2}\) | .7 |
| \(\theta_{c_1\mid a_1}\) | .4 | \(\theta_{c_2\mid a_1}\) | .6 |
| \(\theta_{c_1\mid a_2}\) | .01 | \(\theta_{c_2\mid a_2}\) | .99 |
Reading the figure bottom-up, the internal nodes of the circuit are (each node is written as its operation applied to its children):
| node | definition |
|---|---|
| \(n_1\) | \(\star(\lambda_{c_1},\theta_{c_1\mid a_1})\) |
| \(n_2\) | \(\star(\lambda_{c_2},\theta_{c_2\mid a_1})\) |
| \(n_3\) | \(\star(\lambda_{a_1},\theta_{a_1})\) |
| \(n_4\) | \(\star(\lambda_{a_2},\theta_{a_2})\) |
| \(n_5\) | \(\star(\lambda_{c_1},\theta_{c_1\mid a_2})\) |
| \(n_6\) | \(\star(\lambda_{c_2},\theta_{c_2\mid a_2})\) |
| \(n_7\) | \(\star(\theta_{b_1\mid a_1},n_3)\) |
| \(n_8\) | \(\star(\theta_{b_1\mid a_2},n_4)\) |
| \(n_9\) | \(+(n_1,n_2)\) |
| \(n_{10}\) | \(+(n_5,n_6)\) |
| \(n_{11}\) | \(\star(\theta_{b_2\mid a_1},n_3)\) |
| \(n_{12}\) | \(\star(\theta_{b_2\mid a_2},n_4)\) |
| \(n_{13}\) | \(\star(n_7,n_9)\) |
| \(n_{14}\) | \(\star(n_8,n_{10})\) |
| \(n_{15}\) | \(\star(n_9,n_{11})\) |
| \(n_{16}\) | \(\star(n_{10},n_{12})\) |
| \(n_{17}\) | \(+(n_{13},n_{14})\) |
| \(n_{18}\) | \(+(n_{15},n_{16})\) |
| \(n_{19}\) | \(\star(\lambda_{b_1},n_{17})\) |
| \(n_{20}\) | \(\star(\lambda_{b_2},n_{18})\) |
| \(n_{21}\) | \(+(n_{19},n_{20})\) |
with \(n_{21}\) the circuit output (root). Here \(\star\) denotes a multiplication node and \(+\) an addition node, each listed with its children.
(a) Construct the polynomial \(f\) represented by this arithmetic circuit.
(b) Compute the partial derivatives \(\partial f/\partial \lambda_{a_1}\), \(\partial f/\partial \lambda_{a_2}\), \(\partial f/\partial \theta_{c_1\mid a_1}\), and \(\partial f/\partial \theta_{c_2\mid a_2}\).
(c) Evaluate the derivatives in (b) at evidence \(e = a_1 c_1\).
(d) What is the probabilistic meaning of these derivatives?
(a) Expanding from the root, \(n_{21} = \lambda_{b_1}n_{17} + \lambda_{b_2}n_{18}\) with \(n_{13},\dots,n_{16}\) pairing \(\theta_{b\mid a}n_3\) or \(\theta_{b\mid a}n_4\) with the matching \(C\)-sum \(n_9 = \sum_c \lambda_c\theta_{c\mid a_1}\), \(n_{10} = \sum_c \lambda_c\theta_{c\mid a_2}\), so
\begin{equation*} f \;=\; \sum_{b}\lambda_b\sum_{a}\lambda_a\theta_a\theta_{b\mid a} \Big(\sum_{c}\lambda_c\theta_{c\mid a}\Big). \end{equation*}
Multiplied out this is the network polynomial of \(B \leftarrow A \rightarrow C\) in the canonical form of Definition 12.1, one term per instantiation of \(ABC\):
\begin{equation*} \begin{aligned} f =\;& \lambda_{a_1}\lambda_{b_1}\lambda_{c_1}\, \theta_{a_1}\theta_{b_1\mid a_1}\theta_{c_1\mid a_1}\\ &+ \lambda_{a_1}\lambda_{b_1}\lambda_{c_2}\, \theta_{a_1}\theta_{b_1\mid a_1}\theta_{c_2\mid a_1}\\ &+ \lambda_{a_1}\lambda_{b_2}\lambda_{c_1}\, \theta_{a_1}\theta_{b_2\mid a_1}\theta_{c_1\mid a_1}\\ &+ \lambda_{a_1}\lambda_{b_2}\lambda_{c_2}\, \theta_{a_1}\theta_{b_2\mid a_1}\theta_{c_2\mid a_1}\\ &+ \lambda_{a_2}\lambda_{b_1}\lambda_{c_1}\, \theta_{a_2}\theta_{b_1\mid a_2}\theta_{c_1\mid a_2}\\ &+ \lambda_{a_2}\lambda_{b_1}\lambda_{c_2}\, \theta_{a_2}\theta_{b_1\mid a_2}\theta_{c_2\mid a_2}\\ &+ \lambda_{a_2}\lambda_{b_2}\lambda_{c_1}\, \theta_{a_2}\theta_{b_2\mid a_2}\theta_{c_1\mid a_2}\\ &+ \lambda_{a_2}\lambda_{b_2}\lambda_{c_2}\, \theta_{a_2}\theta_{b_2\mid a_2}\theta_{c_2\mid a_2}. \end{aligned} \end{equation*}
(b) The polynomial is multilinear, so each derivative deletes the differentiation variable from the terms containing it and discards the rest:
\begin{equation*} \begin{aligned} \frac{\partial f}{\partial \lambda_{a_i}} &= \theta_{a_i}\big(\lambda_{b_1}\theta_{b_1\mid a_i} +\lambda_{b_2}\theta_{b_2\mid a_i}\big) \big(\lambda_{c_1}\theta_{c_1\mid a_i} +\lambda_{c_2}\theta_{c_2\mid a_i}\big), \quad i = 1,2,\\ \frac{\partial f}{\partial \theta_{c_1\mid a_1}} &= \lambda_{a_1}\lambda_{c_1}\theta_{a_1} \big(\lambda_{b_1}\theta_{b_1\mid a_1}+\lambda_{b_2}\theta_{b_2\mid a_1}\big),\\ \frac{\partial f}{\partial \theta_{c_2\mid a_2}} &= \lambda_{a_2}\lambda_{c_2}\theta_{a_2} \big(\lambda_{b_1}\theta_{b_1\mid a_2}+\lambda_{b_2}\theta_{b_2\mid a_2}\big). \end{aligned} \end{equation*}
(c) Evidence \(e = a_1c_1\) sets \(\lambda_{a_1} = \lambda_{c_1} = 1\), \(\lambda_{a_2} = \lambda_{c_2} = 0\), and \(\lambda_{b_1} = \lambda_{b_2} = 1\) since \(B\) is unmentioned, so
\begin{equation*} \begin{aligned} \frac{\partial f}{\partial \lambda_{a_1}}(e) &= (.1)(.2+.8)(.4) = .04, & \frac{\partial f}{\partial \lambda_{a_2}}(e) &= (.9)(.3+.7)(.01) = .009,\\ \frac{\partial f}{\partial \theta_{c_1\mid a_1}}(e) &= (1)(1)(.1)(.2+.8) = .1, & \frac{\partial f}{\partial \theta_{c_2\mid a_2}}(e) &= (0)(0)(.9)(1) = 0 . \end{aligned} \end{equation*}
(d) By Theorem 12.2, \(\partial f/\partial \lambda_x(e) = \Pr(x, e-X)\) and \(\theta_{x\mid u}\,\partial f/\partial \theta_{x\mid u}(e) = \Pr(x,u,e)\), and here \(e-A = c_1\), \(e-C = a_1\):
- \(.04 = \Pr(a_1c_1) = \Pr(e)\), since \(a_1\) is already the value of \(A\) in \(e\).
- \(.009 = \Pr(a_2c_1)\), the probability of the evidence with \(A\) flipped to \(a_2\), read off without re-evaluating the circuit.
- \((.4)(.1) = .04 = \Pr(c_1,a_1,e)\), the family marginal of \(CA\); equivalently, by (12.6), \(.1\) is the rate \(\partial \Pr(e)/\partial \theta_{c_1\mid a_1}\) used in Chapter 16.
- \(0 = \Pr(c_2,a_2,e)\), necessarily zero because \(c_2a_2\) contradicts \(e\).
Consider the arithmetic circuit in Figure 12.13 (its nodes, structure and parameter values are transcribed in Exercise 12.1). Evaluate and differentiate this circuit at evidence \(e = a_1 c_1\). Perform the differentiation using both propagation schemes given by Algorithms 34 and 35.
Evidence \(e = a_1c_1\) sets \(\lambda_{a_1} = \lambda_{c_1} = 1\), \(\lambda_{a_2} = \lambda_{c_2} = 0\), \(\lambda_{b_1} = \lambda_{b_2} = 1\). Visiting children before parents gives the bottom-up pass shared by both algorithms:
| node | expression | value |
|---|---|---|
| \(n_1\) | \(\lambda_{c_1}\theta_{c_1\mid a_1}=(1)(.4)\) | \(.4\) |
| \(n_2\) | \(\lambda_{c_2}\theta_{c_2\mid a_1}=(0)(.6)\) | \(0\) |
| \(n_3\) | \(\lambda_{a_1}\theta_{a_1}=(1)(.1)\) | \(.1\) |
| \(n_4\) | \(\lambda_{a_2}\theta_{a_2}=(0)(.9)\) | \(0\) |
| \(n_5\) | \(\lambda_{c_1}\theta_{c_1\mid a_2}=(1)(.01)\) | \(.01\) |
| \(n_6\) | \(\lambda_{c_2}\theta_{c_2\mid a_2}=(0)(.99)\) | \(0\) |
| \(n_7\) | \(\theta_{b_1\mid a_1}n_3=(.2)(.1)\) | \(.02\) |
| \(n_8\) | \(\theta_{b_1\mid a_2}n_4=(.3)(0)\) | \(0\) |
| \(n_9\) | \(n_1+n_2=.4+0\) | \(.4\) |
| \(n_{10}\) | \(n_5+n_6=.01+0\) | \(.01\) |
| \(n_{11}\) | \(\theta_{b_2\mid a_1}n_3=(.8)(.1)\) | \(.08\) |
| \(n_{12}\) | \(\theta_{b_2\mid a_2}n_4=(.7)(0)\) | \(0\) |
| \(n_{13}\) | \(n_7n_9=(.02)(.4)\) | \(.008\) |
| \(n_{14}\) | \(n_8n_{10}=(0)(.01)\) | \(0\) |
| \(n_{15}\) | \(n_9n_{11}=(.4)(.08)\) | \(.032\) |
| \(n_{16}\) | \(n_{10}n_{12}=(.01)(0)\) | \(0\) |
| \(n_{17}\) | \(n_{13}+n_{14}\) | \(.008\) |
| \(n_{18}\) | \(n_{15}+n_{16}\) | \(.032\) |
| \(n_{19}\) | \(\lambda_{b_1}n_{17}=(1)(.008)\) | \(.008\) |
| \(n_{20}\) | \(\lambda_{b_2}n_{18}=(1)(.032)\) | \(.032\) |
| \(n_{21}\) | \(n_{19}+n_{20}=.008+.032\) | \(.04\) |
The output is \(\mathrm{vr}(n_{21}) = .04 = \Pr(a_1c_1)\), as Theorem 12.1 requires.
Algorithm 34. Set \(\mathrm{dr}(n_{21}) = 1\), all other registers \(0\), and visit parents before children, a node \(v\) adding \(\mathrm{dr}(p)\) from an addition parent \(p\) and \(\mathrm{dr}(p)\prod_{v^{\prime} \ne v}\mathrm{vr}(v^{\prime})\) from a multiplication parent. Note \(n_9\) has parents \(n_{13}, n_{15}\), and \(n_3\) has parents \(n_7, n_{11}\) (symmetrically for \(n_{10}, n_4\)):
\begin{equation*} \begin{aligned} \mathrm{dr}(n_{19}) &= \mathrm{dr}(n_{20}) = \mathrm{dr}(n_{17}) = \mathrm{dr}(n_{18}) = 1,\\ \mathrm{dr}(n_{13}) &= \mathrm{dr}(n_{14}) = \mathrm{dr}(n_{15}) = \mathrm{dr}(n_{16}) = 1,\\ \mathrm{dr}(\lambda_{b_1}) &= (1)(.008) = .008, \quad \mathrm{dr}(\lambda_{b_2}) = (1)(.032) = .032,\\ \mathrm{dr}(n_7) &= \mathrm{dr}(n_{11}) = (1)(.4) = .4, \quad \mathrm{dr}(n_8) = \mathrm{dr}(n_{12}) = (1)(.01) = .01,\\ \mathrm{dr}(n_9) &= (1)(.02)+(1)(.08) = .1, \quad \mathrm{dr}(n_{10}) = (1)(0)+(1)(0) = 0,\\ \mathrm{dr}(n_1) &= \mathrm{dr}(n_2) = .1, \quad \mathrm{dr}(n_5) = \mathrm{dr}(n_6) = 0,\\ \mathrm{dr}(n_3) &= (.4)(.2)+(.4)(.8) = .4, \quad \mathrm{dr}(n_4) = (.01)(.3)+(.01)(.7) = .01. \end{aligned} \end{equation*}
The leaves follow, \(\lambda_{c_1}\) having parents \(n_1, n_5\) and \(\lambda_{c_2}\) parents \(n_2, n_6\):
| leaf | computation | \(\mathrm{dr}\) |
|---|---|---|
| \(\lambda_{a_1}\) | \(\mathrm{dr}(n_3)\theta_{a_1}=(.4)(.1)\) | \(.04\) |
| \(\theta_{a_1}\) | \(\mathrm{dr}(n_3)\lambda_{a_1}=(.4)(1)\) | \(.4\) |
| \(\lambda_{a_2}\) | \(\mathrm{dr}(n_4)\theta_{a_2}=(.01)(.9)\) | \(.009\) |
| \(\theta_{a_2}\) | \(\mathrm{dr}(n_4)\lambda_{a_2}=(.01)(0)\) | \(0\) |
| \(\lambda_{b_1}\) | (above) | \(.008\) |
| \(\lambda_{b_2}\) | (above) | \(.032\) |
| \(\theta_{b_1\mid a_1}\) | \(\mathrm{dr}(n_7)\mathrm{vr}(n_3)=(.4)(.1)\) | \(.04\) |
| \(\theta_{b_2\mid a_1}\) | \(\mathrm{dr}(n_{11})\mathrm{vr}(n_3)=(.4)(.1)\) | \(.04\) |
| \(\theta_{b_1\mid a_2}\) | \(\mathrm{dr}(n_8)\mathrm{vr}(n_4)=(.01)(0)\) | \(0\) |
| \(\theta_{b_2\mid a_2}\) | \(\mathrm{dr}(n_{12})\mathrm{vr}(n_4)=(.01)(0)\) | \(0\) |
| \(\lambda_{c_1}\) | from \(n_1\) and \(n_5\): \((.1)(.4)+(0)(.01)\) | \(.04\) |
| \(\lambda_{c_2}\) | from \(n_2\) and \(n_6\): \((.1)(.6)+(0)(.99)\) | \(.06\) |
| \(\theta_{c_1\mid a_1}\) | \(\mathrm{dr}(n_1)\lambda_{c_1}=(.1)(1)\) | \(.1\) |
| \(\theta_{c_2\mid a_1}\) | \(\mathrm{dr}(n_2)\lambda_{c_2}=(.1)(0)\) | \(0\) |
| \(\theta_{c_1\mid a_2}\) | \(\mathrm{dr}(n_5)\lambda_{c_1}=(0)(1)\) | \(0\) |
| \(\theta_{c_2\mid a_2}\) | \(\mathrm{dr}(n_6)\lambda_{c_2}=(0)(0)\) | \(0\) |
Algorithm 35 replaces \(\prod_{v^{\prime} \ne v}\mathrm{vr}(v^{\prime})\) by the division \(\mathrm{vr}(p)/\mathrm{vr}(v)\), carrying one bit per multiplication node: \(\mathrm{bit}(p) = 1\) exactly when one child of \(p\) is zero, and then \(\mathrm{vr}(p)\) stores the product of the remaining children. The algorithm is stated for strictly alternating circuits, which this one is not (\(n_7, n_8, n_{11}, n_{12}\) and \(n_{13},\dots,n_{16}\) have multiplication children), so use the relaxation the book allows, testing a child’s type as well as its bit: the true value of \(c\) is \(0\) when \(c\) is a multiplication node with \(\mathrm{bit}( c) = 1\), and \(\mathrm{vr}( c)\) otherwise. An addition node then sums only the children of bit \(0\).
| node | \(\mathrm{bit}\) | \(\mathrm{vr}\) | true value |
|---|---|---|---|
| \(n_1\) | \(0\) | \(.4\) | \(.4\) |
| \(n_2\) | \(1\) | \(.6\) | \(0\) |
| \(n_3\) | \(0\) | \(.1\) | \(.1\) |
| \(n_4\) | \(1\) | \(.9\) | \(0\) |
| \(n_5\) | \(0\) | \(.01\) | \(.01\) |
| \(n_6\) | \(1\) | \(.99\) | \(0\) |
| \(n_7\) | \(0\) | \(.02\) | \(.02\) |
| \(n_8\) | \(1\) | \(.3\) | \(0\) |
| \(n_9\) | (add) | \(.4\) | \(.4\) |
| \(n_{10}\) | (add) | \(.01\) | \(.01\) |
| \(n_{11}\) | \(0\) | \(.08\) | \(.08\) |
| \(n_{12}\) | \(1\) | \(.7\) | \(0\) |
| \(n_{13}\) | \(0\) | \(.008\) | \(.008\) |
| \(n_{14}\) | \(1\) | \(.01\) | \(0\) |
| \(n_{15}\) | \(0\) | \(.032\) | \(.032\) |
| \(n_{16}\) | \(1\) | \(.01\) | \(0\) |
| \(n_{17}\) | (add) | \(.008\) | \(.008\) |
| \(n_{18}\) | (add) | \(.032\) | \(.032\) |
| \(n_{19}\) | \(0\) | \(.008\) | \(.008\) |
| \(n_{20}\) | \(0\) | \(.032\) | \(.032\) |
| \(n_{21}\) | (add) | \(.04\) | \(.04\) |
The top-down pass adds, at a multiplication parent \(p\) of \(v\): nothing if \(\mathrm{vr}(p) = 0\); \(\mathrm{dr}(p)\mathrm{vr}(p)/\mathrm{vr}(v)\) if \(\mathrm{bit}(p) = 0\); and \(\mathrm{dr}(p)\mathrm{vr}(p)\) if \(\mathrm{bit}(p) = 1\) and \(v\) is the single zero-valued child of \(p\), nothing otherwise. From \(\mathrm{dr}(n_{21}) = 1\):
\begin{equation*} \begin{aligned} \mathrm{dr}(n_{19}) &= \mathrm{dr}(n_{20}) = 1,\\ \mathrm{dr}(\lambda_{b_1}) &= (1)(.008)/1 = .008,\quad \mathrm{dr}(n_{17}) = (1)(.008)/.008 = 1,\\ \mathrm{dr}(\lambda_{b_2}) &= (1)(.032)/1 = .032,\quad \mathrm{dr}(n_{18}) = (1)(.032)/.032 = 1,\\ \mathrm{dr}(n_{13}) &= \mathrm{dr}(n_{14}) = \mathrm{dr}(n_{15}) = \mathrm{dr}(n_{16}) = 1,\\ \mathrm{dr}(n_7) &= (1)(.008)/.02 = .4,\quad \mathrm{dr}(n_{11}) = (1)(.032)/.08 = .4,\\ \mathrm{dr}(n_9) &= (1)(.008)/.4 + (1)(.032)/.4 = .1,\\ \mathrm{dr}(n_8) &= (1)(.01) = .01,\quad \mathrm{dr}(n_{12}) = (1)(.01) = .01,\quad \mathrm{dr}(n_{10}) = 0,\\ \mathrm{dr}(n_1) &= \mathrm{dr}(n_2) = .1,\quad \mathrm{dr}(n_5) = \mathrm{dr}(n_6) = 0,\\ \mathrm{dr}(n_3) &= (.4)(.02)/.1 + (.4)(.08)/.1 = .4,\quad \mathrm{dr}(n_4) = (.01)(.3) + (.01)(.7) = .01, \end{aligned} \end{equation*}
where \(\mathrm{dr}(n_{10}) = 0\) because the single zero-valued child of \(n_{14}\) is \(n_8\) and that of \(n_{16}\) is \(n_{12}\), so the bit-\(1\) branch never fires for \(n_{10}\), while \(n_4\) is the zero child of both \(n_8\) and \(n_{12}\), so it does fire there. The leaves:
\begin{equation*} \begin{aligned} \mathrm{dr}(\theta_{b_1\mid a_1}) &= (.4)(.02)/.2 = .04,\quad \mathrm{dr}(\theta_{b_2\mid a_1}) = (.4)(.08)/.8 = .04,\\ \mathrm{dr}(\theta_{b_1\mid a_2}) &= \mathrm{dr}(\theta_{b_2\mid a_2}) = 0,\\ \mathrm{dr}(\lambda_{a_1}) &= (.4)(.1)/1 = .04,\quad \mathrm{dr}(\theta_{a_1}) = (.4)(.1)/.1 = .4,\\ \mathrm{dr}(\lambda_{a_2}) &= (.01)(.9) = .009,\quad \mathrm{dr}(\theta_{a_2}) = 0,\\ \mathrm{dr}(\lambda_{c_1}) &= (.1)(.4)/1 + (0)(.01)/1 = .04,\quad \mathrm{dr}(\lambda_{c_2}) = (.1)(.6) = .06,\\ \mathrm{dr}(\theta_{c_1\mid a_1}) &= (.1)(.4)/.4 = .1,\quad \mathrm{dr}(\theta_{c_2\mid a_1}) = 0,\\ \mathrm{dr}(\theta_{c_1\mid a_2}) &= (0)(.01)/.01 = 0,\quad \mathrm{dr}(\theta_{c_2\mid a_2}) = 0. \end{aligned} \end{equation*}
Both parents of \(\lambda_{c_2}\) have bit \(1\) with \(\lambda_{c_2}\) as their single zero child, contributing \((.1)(.6)\) and \((0)(.99)\), whereas \(\theta_{c_2\mid a_1}\) gets nothing from \(n_2\), not being that child – exactly the case a naive division scheme would mishandle, since \(\mathrm{vr}(\lambda_{c_2}) = 0\). Every register matches Algorithm 34, which computes the same \(\mathrm{dr}(v) = \partial\mathrm{vr}( r)/\partial\mathrm{vr}(v)\) but forms the sibling products explicitly.
Consider a Bayesian network with structure \(A \rightarrow B \rightarrow C\), where all variables are binary (values \(a_1,a_2\); \(b_1,b_2\); \(c_1,c_2\)). Construct an arithmetic circuit for this network using the method of variable elimination given in Section 12.4.1 and using elimination order \(C, B, A\).
Run variable elimination on circuit factors (Section 12.4.1), every factor entry being a circuit node and \(\star\), \(+\) creating a multiplication resp. addition node with the given children. The initial factor of a family \(X\mathbf{U}\) maps \(x\mathbf{u}\) to \(\star(\lambda_x,\theta_{x\mid u})\), one per CPT:
| \(A\) | \(f_A\) |
|---|---|
| \(a_1\) | \(n_1=\star(\lambda_{a_1},\theta_{a_1})\) |
| \(a_2\) | \(n_2=\star(\lambda_{a_2},\theta_{a_2})\) |
| \(A\) | \(B\) | \(f_{B\mid A}\) |
|---|---|---|
| \(a_1\) | \(b_1\) | \(n_3=\star(\lambda_{b_1},\theta_{b_1\mid a_1})\) |
| \(a_1\) | \(b_2\) | \(n_4=\star(\lambda_{b_2},\theta_{b_2\mid a_1})\) |
| \(a_2\) | \(b_1\) | \(n_5=\star(\lambda_{b_1},\theta_{b_1\mid a_2})\) |
| \(a_2\) | \(b_2\) | \(n_6=\star(\lambda_{b_2},\theta_{b_2\mid a_2})\) |
| \(B\) | \(C\) | \(f_{C\mid B}\) |
|---|---|---|
| \(b_1\) | \(c_1\) | \(n_7=\star(\lambda_{c_1},\theta_{c_1\mid b_1})\) |
| \(b_1\) | \(c_2\) | \(n_8=\star(\lambda_{c_2},\theta_{c_2\mid b_1})\) |
| \(b_2\) | \(c_1\) | \(n_9=\star(\lambda_{c_1},\theta_{c_1\mid b_2})\) |
| \(b_2\) | \(c_2\) | \(n_{10}=\star(\lambda_{c_2},\theta_{c_2\mid b_2})\) |
Leaves are shared – \(\lambda_{b_1}\) by \(n_3\) and \(n_5\), \(\lambda_{c_1}\) by \(n_7\) and \(n_9\) – which is what keeps the circuit compact.
Eliminating \(C\) from \(f_{C\mid B}\), the only factor mentioning it, makes one addition node per value of \(B\):
| \(B\) | \(\sum_C f_{C\mid B}\) |
|---|---|
| \(b_1\) | \(n_{11}=+(n_7,n_8)\) |
| \(b_2\) | \(n_{12}=+(n_9,n_{10})\) |
Eliminating \(B\): multiply that factor by \(f_{B\mid A}\),
| \(A\) | \(B\) | product |
|---|---|---|
| \(a_1\) | \(b_1\) | \(n_{13}=\star(n_3,n_{11})\) |
| \(a_1\) | \(b_2\) | \(n_{14}=\star(n_4,n_{12})\) |
| \(a_2\) | \(b_1\) | \(n_{15}=\star(n_5,n_{11})\) |
| \(a_2\) | \(b_2\) | \(n_{16}=\star(n_6,n_{12})\) |
and sum \(B\) out:
| \(A\) | result |
|---|---|
| \(a_1\) | \(n_{17}=+(n_{13},n_{14})\) |
| \(a_2\) | \(n_{18}=+(n_{15},n_{16})\) |
Eliminating \(A\): multiply by \(f_A\),
| \(A\) | product |
|---|---|
| \(a_1\) | \(n_{19}=\star(n_1,n_{17})\) |
| \(a_2\) | \(n_{20}=\star(n_2,n_{18})\) |
and sum \(A\) out, leaving the trivial factor whose single entry
\begin{equation*} n_{21} \;=\; +(n_{19},n_{20}) \end{equation*}
is the circuit root. So the circuit has \(16\) leaves (six indicators, ten parameters), \(16\) multiplication nodes (\(n_1\) to \(n_{10}\), \(n_{13}\) to \(n_{16}\), \(n_{19}, n_{20}\)) and \(5\) addition nodes (\(n_{11}, n_{12}, n_{17}, n_{18}, n_{21}\)), every internal node binary, hence \(42\) edges. Unwinding the root gives \(\sum_{a,b,c}\lambda_a\lambda_b\lambda_c\,\theta_a\theta_{b\mid a}\theta_{c\mid b}\) (Check!), the network polynomial of Definition 12.1, so the root evaluates to \(\Pr(e)\) for every \(e\) by Theorem 12.1. The order \(C,B,A\) has width \(w = 1\), matching the \(O(n\exp(w))\) size bound of Section 12.4.1; the compression relative to the eight-term polynomial comes from the sharing of \(n_{11}, n_{12}\) and of the leaves.
Show that the following partial derivatives are equal to zero for a network polynomial \(f\):
(a) \(\dfrac{\partial^2 f}{\partial \lambda_x\,\partial \lambda_{x^{\prime}}}\), where \(x\) and \(x^{\prime}\) are values (possibly equal) of the same variable.
(b) \(\dfrac{\partial^2 f}{\partial \theta_{x\mid u}\,\partial \theta_{x^{\prime}\mid u^{\prime}}}\), where \(x\mathbf{u}\) and \(x^{\prime}\mathbf{u}^{\prime}\) are instantiations (possibly equal) of the same family.
What does this imply on the structure of the polynomial \(f\)?
Both vanish because every term of
\begin{equation*} f \;=\; \sum_{\mathbf{z}}\ \prod_{\theta_{x\mid u}\sim \mathbf{z}}\theta_{x\mid u} \ \prod_{\lambda_x \sim \mathbf{z}}\lambda_x \end{equation*}
contains exactly one indicator of each variable \(X\) and exactly one parameter of each family \(X\mathbf{U}\), each to the first power: a term is indexed by a complete instantiation \(\mathbf{z}\), which assigns \(X\) a unique value and \(X\mathbf{U}\) a unique instantiation.
(a) If \(x \ne x^{\prime}\), no term contains both \(\lambda_x\) and \(\lambda_{x^{\prime}}\), an instantiation compatible with \(x\) being incompatible with \(x^{\prime}\). So \(\partial f/\partial\lambda_x\), got by deleting \(\lambda_x\) from the terms that contain it and discarding the others, mentions \(\lambda_{x^{\prime}}\) nowhere, and differentiating again gives \(0\). If \(x = x^{\prime}\), degree \(1\) makes \(\partial f/\partial\lambda_x\) free of \(\lambda_x\) itself, so again the second derivative vanishes.
(b) Verbatim the same argument with \(\theta_{x\mid u}\) and \(\theta_{x^{\prime}\mid u^{\prime}}\) in place of the two indicators, a term being compatible with exactly one instantiation of the family \(X\mathbf{U}\).
Structurally, then, \(f\) is linear not merely in each variable but in each block – the indicators \(\Lambda_X\) of a network variable, the parameters \(\Theta_{X\mathbf{U}}\) of a family – with every term a product of exactly one variable from each of the \(2n\) blocks. Hence
\begin{equation*} f \;=\; \sum_{x} \lambda_x \,\frac{\partial f}{\partial \lambda_x}, \qquad f \;=\; \sum_{x\mathbf{u}} \theta_{x\mid u}\, \frac{\partial f}{\partial \theta_{x\mid u}}, \end{equation*}
the first sum over the values of any one fixed variable and the second over the instantiations of any one fixed family.
Provide probabilistic semantics for the following second partial derivatives of the network polynomial:
\begin{equation*} \frac{\partial^2 f}{\partial \lambda_x\,\partial \lambda_y}(e), \qquad \frac{\partial^2 f}{\partial \theta_{x\mid u}\,\partial \lambda_y}(e), \qquad \frac{\partial^2 f}{\partial \theta_{x\mid u}\,\partial \theta_{y\mid v}}(e). \end{equation*}
Provide a circuit propagation scheme that will compute these derivatives and discuss its time and space complexity.
(i) \(\partial^2 f/\partial\lambda_x\partial\lambda_y(e) = \Pr(x,y,e-XY)\) when \(X \ne Y\), and \(0\) when \(X = Y\) by Exercise 12.4(a). Deleting \(\lambda_x\) and then \(\lambda_y\) from the terms of Definition 12.1, and using \(\prod_{\theta\sim\mathbf{z}}\theta = \Pr(\mathbf{z})\) (chain rule),
\begin{equation*} \frac{\partial^2 f}{\partial\lambda_x\partial\lambda_y} = \sum_{\mathbf{z}\sim xy}\ \Pr(\mathbf{z}) \prod_{\lambda_w\sim\mathbf{z},\, W\notin\{X,Y\}}\lambda_w , \end{equation*}
and at \(e\) the surviving \(\mathbf{z}\) are exactly those compatible with \(xy\) and with \(e-XY\): the probability of the evidence obtained by setting \(X\) to \(x\) and \(Y\) to \(y\).
(ii) \(\theta_{x\mid u}\,\partial^2 f/\partial\theta_{x\mid u}\,\partial\lambda_y(e) = \Pr(x,\mathbf{u},y,e-Y)\). Degree \(1\) in \(\theta_{x\mid u}\) gives
\begin{equation*} \theta_{x\mid u}\frac{\partial f}{\partial\theta_{x\mid u}} = \sum_{\mathbf{z}\sim x\mathbf{u}}\Pr(\mathbf{z}) \prod_{\lambda_w\sim\mathbf{z}}\lambda_w , \end{equation*}
and differentiating by \(\lambda_y\) at \(e\) retains the \(\mathbf{z}\) compatible with \(x\mathbf{u}\), with \(y\), and with \(e-Y\); this is the family marginal of \(X\mathbf{U}\) under \(e\) with \(Y\) reset to \(y\), and it vanishes if \(y\) contradicts \(x\mathbf{u}\).
(iii) \(\theta_{x\mid u}\theta_{y\mid v}\,\partial^2 f/\partial\theta_{x\mid u}\, \partial\theta_{y\mid v}(e) = \Pr(x,\mathbf{u},y,\mathbf{v},e)\), the joint marginal of the two families under \(e\), by the same computation applied twice – and \(0\) when the two families coincide, by Exercise 12.4(b).
A propagation scheme. All three are ordinary first derivatives evaluated at a modified indicator vector. For evidence \(e\) and an instantiation \(\mathbf{s}\) of a set \(\mathbf{S}\), let \(\rho_{e,\mathbf{s}}\) be the indicator vector of the evidence “\(e\) and \(\mathbf{s}\)”, that is \(\rho_{e,\mathbf{s}}(\lambda_w) = 1\) iff \(w \sim e\) and either \(W \notin \mathbf{S}\) or \(w \sim \mathbf{s}\). One evaluation-plus-differentiation pass of Algorithm 34 or 35 on the same circuit with that input costs \(O(|AC|)\) and gives, by Theorem 12.2 applied to that evidence,
\begin{equation*} \begin{aligned} \frac{\partial f}{\partial\lambda_x}(\rho_{e,\mathbf{s}}) &= \Pr\big(x,\ (e\wedge\mathbf{s})-X\big),\\ \theta_{x\mid u}\frac{\partial f}{\partial\theta_{x\mid u}}(\rho_{e,\mathbf{s}}) &= \Pr\big(x,\mathbf{u},\,e,\,\mathbf{s}\big). \end{aligned} \end{equation*}
So \(\mathbf{s} = y\) yields, in one pass, every derivative of type (i) and of type (ii) for that fixed \(y\), and \(\mathbf{s} = y\mathbf{v}\) yields every derivative of type (iii) for that fixed \(y\mathbf{v}\) – a whole row of the second-derivative matrix per pass. Derivatives covered by Exercise 12.4 are reported as \(0\) without computation.
Complexity. With \(m\) indicators and \(q\) parameters in all (\(m \le q\), both \(O(n\exp(w))\)), types (i) and (ii) need \(m\) passes and type (iii) needs \(q\), so the time is \(O((m+q)|AC|) = O(q\,|AC|)\), against \(O(q^2|AC|)\) for re-evaluating once per pair. Each pass recomputes from scratch, so the working space is the two register arrays, \(O(|AC|)\), plus the output – \(\Theta(m^2+q^2)\) if all second derivatives are retained, \(O(|AC|)\) for a single row.
Suppose we extend the notion of evidence to allow for constraining the value of a variable instead of fixing it. For example, if \(X\) is a variable with three values \(x_1\), \(x_2\), and \(x_3\), then a piece of evidence on variable \(X\) may be \(X = x_1 \vee X = x_2\), which rules out value \(x_3\) without committing to either value \(x_1\) or \(x_2\). Given this extended notion of evidence, known as a finding, show how we can evaluate a network polynomial so that its value equals the probability of the given findings.
Evaluate the polynomial with each indicator set to
\begin{equation*} \lambda_x \;=\; \begin{cases} 1, & \text{if } x\in S_X,\\ 0, & \text{otherwise,} \end{cases} \end{equation*}
where the finding on \(X\) is \(\beta_X = \bigvee_{x \in S_X}(X = x)\) and a variable on which nothing is observed gets the trivial finding \(S_X = \mathcal{D}_X\). Then \(f(\beta) = \Pr(\beta)\) for \(\beta = \bigwedge_{X \in \mathbf{Z}}\beta_X\).
Indeed, in each term of Definition 12.1 the \(\theta\)-product is \(\Pr(\mathbf{z})\) by the chain rule, and the \(\lambda\)-product contains exactly one indicator per variable (Exercise 12.4), namely \(\lambda_{\mathbf{z}(X)}\), so
\begin{equation*} \prod_{\lambda_x\sim\mathbf{z}}\lambda_x = \prod_{X\in\mathbf{Z}} [\,\mathbf{z}(X)\in S_X\,] =\begin{cases} 1, & \text{if } \mathbf{z}\models\beta,\\ 0, & \text{otherwise,} \end{cases} \end{equation*}
a product of zeros and ones being \(1\) exactly when \(\mathbf{z}\) satisfies every finding. Hence \(f(\beta) = \sum_{\mathbf{z}\models\beta}\Pr(\mathbf{z}) = \Pr(\beta)\), the event \(\beta\) being the disjoint union of the instantiations satisfying it. Theorem 12.1 is the case \(|S_X| = 1\) on the instantiated variables and \(S_X = \mathcal{D}_X\) on the rest.
The circuit itself is untouched – only the leaf inputs differ – so a finding query still costs one bottom-up pass, \(O(|AC|)\), and the same argument one differentiation deeper gives \(\partial f/\partial\lambda_x(\beta) = \Pr(x, \beta - X)\), with \(\beta - X\) the result of making the finding on \(X\) trivial, and \(\theta_{x\mid u}\,\partial f/\partial\theta_{x\mid u}(\beta) = \Pr(x,\mathbf{u},\beta)\).
Consider the construction of an arithmetic circuit using variable elimination (Section 12.4.1). For each addition node \(n\) constructed by this algorithm, let \(\mathrm{var}(n)\) stand for the variable \(X\) whose elimination has led to the construction of node \(n\). Given some MAP variables \(\mathbf{M}\) and evidence \(e\), show that the following procedure generates an upper bound on the MAP probability \(\mathrm{MAP}_P(\mathbf{M},e)\): evaluate the circuit while treating an addition node \(n\) as a maximization node if \(\mathrm{var}(n)\in\mathbf{M}\).
The modified evaluation computes
\begin{equation*} V \;=\; \bigotimes_{X_n}\bigotimes_{X_{n-1}}\cdots\bigotimes_{X_1} F(\mathbf{z}), \qquad \bigotimes_{X_i} = \begin{cases} \max_{X_i}, & X_i \in \mathbf{M},\\ \sum_{X_i}, & X_i \notin \mathbf{M}, \end{cases} \end{equation*}
where \(\pi = X_1,\dots,X_n\) is the elimination order used to build the circuit (\(X_1\) eliminated first, hence innermost) and \(F(\mathbf{z}) = \Pr(\mathbf{z})\,[\mathbf{z}\sim e] \ge 0\) is the term of the network polynomial at evidence \(e\). For the addition nodes created when \(X_k\) is eliminated are exactly those with \(\mathrm{var}(n) = X_k\), and each adds the entries of the product factor over the values of \(X_k\), so making them maximization nodes replaces \(\sum_{X_k}\) by \(\max_{X_k}\) and changes nothing else; and the correctness induction for variable elimination uses only that the operator commutes with multiplication by a factor not mentioning \(X_k\), which holds for \(\max\) as well since every quantity here is nonnegative (\(\max_x c\,g(x) = c\max_x g(x)\) for \(c \ge 0\)).
Next, for nonnegative \(G\),
\begin{equation*} \sum_{y}\ \max_{x} G(x,y) \;\ge\; \max_{x}\ \sum_{y} G(x,y), \end{equation*}
since if \(x^{\ast}\) attains the right-hand maximum then \(\max_x G(x,y) \ge G(x^{\ast},y)\) for every \(y\), and summing over \(y\) gives it. Both \(\sum\) and \(\max\) are monotone in their argument, so replacing a fragment \(\sum_{Y}\max_{X}\) of the expression for \(V\) by \(\max_{X}\sum_{Y}\) never increases the value of the whole. Bubble-sorting the operator sequence until every \(\max\) precedes every \(\sum\) – at most \(\binom{n}{2}\) transpositions, operators of the same kind commuting freely – therefore produces a nonincreasing chain from \(V\) down to
\begin{equation*} \max_{\mathbf{M}}\ \sum_{\mathbf{Z}\setminus\mathbf{M}} F(\mathbf{z}) \;=\; \mathrm{MAP}_P(\mathbf{M},e), \end{equation*}
so \(V \ge \mathrm{MAP}_P(\mathbf{M},e)\), as required. The bound is exact when no transposition is needed, that is when \(\pi\) is \(\mathbf{M}\)-constrained.
Exercises 12.8–12.14
Given a Bayesian network and some evidence \(e\), show how to construct a Boolean formula whose models are precisely the MPE instantiations of evidence \(e\). The complexity of your algorithm should be \(O(n \exp(w))\), where \(n\) is the network size and \(w\) is the width of a given elimination order.
Compile, maximize, and read the formula off the evaluated circuit. Assume \(\mathrm{MPE}_P(e) > 0\); otherwise every \(e\)-compatible instantiation has probability zero and the notion degenerates (return the formula for “compatible with \(e\)”, or \(\bot\)).
Run variable elimination along \(\pi\) keeping a trace of its operations (Section 12.4.1), giving an arithmetic circuit \(AC\) for the network polynomial, of size and construction time \(O(n \exp(w))\). Replace every addition node by a maximization node, giving the maximizer circuit \(AC^m\) of Definition 12.4; set \(\lambda_x = 1\) iff \(x \sim e\), set each \(\theta_{x|u}\) to its network value, and evaluate bottom-up into registers \(\mathrm{vr}(v)\), so that the root holds \(AC^m(e) = \mathrm{MPE}_P(e)\) (Section 12.3.2).
Introduce one Boolean indicator \(I_x\) per value of each variable and define, bottom-up,
- \(\alpha_v = I_x\) at a leaf \(\lambda_x\), and \(\alpha_v = \top\) at a leaf \(\theta_{x|u}\);
- \(\alpha_v = \alpha_{c_1} \wedge \cdots \wedge \alpha_{c_k}\) at a multiplication node;
- \(\alpha_v = \bigvee_{\,i \,:\, \mathrm{vr}(c_i) = \mathrm{vr}(v)} \alpha_{c_i}\) at a maximization node, keeping only the children that attain the maximum.
The formula is \(\Phi = \alpha_r \wedge \Delta\), with \(r\) the root and
\begin{equation*} \Delta \;=\; \bigwedge_{X} \Bigl[\; \bigvee_{x} I_x \;\wedge \bigwedge_{x \neq x^{\prime}} (\neg I_x \vee \neg I_{x^{\prime}}) \;\Bigr] \end{equation*}
the usual indicator clauses (11.8)–(11.9). Kept as a DAG with one internal node per circuit node, \(|\Phi| = O(|AC^m|) + O(\sum_X |X|^2) = O(n \exp(w))\), the second term because \(\sum_X |X| \le n\) while \(|X| \le \exp(w)\) for every \(X\), each \(X\) occurring in some cluster of the order.
Correctness. Complete subcircuits (Definition 12.5) of \(AC^m\) correspond one to one with the terms of the network polynomial, hence with the network instantiations \(z\), the subcircuit for \(z\) containing exactly one leaf \(\lambda_x\) per variable, the one with \(x \sim z\). Call a complete subcircuit maximal if every maximization node in it chooses a child \(c\) with \(\mathrm{vr}( c) = \mathrm{vr}(v)\).
(i) A maximal complete subcircuit has value \(\mathrm{vr}(v)\) at each of its nodes, by induction: a multiplication node keeps all children, so its value is \(\prod_c \mathrm{vr}( c) = \mathrm{vr}(v)\), and a maximization node keeps one child of full value. At the root the value is \(\mathrm{MPE}_P(e)\).
(ii) Conversely \(\mathrm{val}(v) \le \mathrm{vr}(v)\) always, values being nonnegative and a maximization node picking one child; and equality pushes downward from \(\mathrm{val}( r) = \mathrm{vr}( r) > 0\): at a multiplication node \(\prod_c \mathrm{val}( c) = \prod_c \mathrm{vr}( c)\) with all factors positive forces \(\mathrm{val}( c) = \mathrm{vr}( c)\) childwise, and at a maximization node with chosen child \(c\), \(\mathrm{vr}(v) = \mathrm{val}( c) \le \mathrm{vr}( c) \le \mathrm{vr}(v)\).
So the maximal complete subcircuits are exactly those of maximal value, i.e. exactly the MPE instantiations of \(e\) (the recovery procedure of Section 12.3.2). Finally \(\Delta\) forces every model of \(\Phi\) to be \(\omega_z\) for a unique instantiation \(z\), and by construction \(\alpha_r\) holds under \(\omega_z\) iff some maximal complete subcircuit has all its \(\lambda\)-leaves compatible with \(z\) – one per variable – that is, iff \(z\) is an MPE instantiation. Hence
\begin{equation*} \mathrm{Models}(\Phi) \;=\; \{\, \omega_z \;:\; z \text{ is an MPE instantiation of } e \,\}. \end{equation*}
Compilation, conversion, evaluation and the construction of the \(\alpha_v\) are each linear in the circuit size, so the whole algorithm is \(O(n \exp(w))\).
Unlike in Exercise 11.10, the clauses (11.9) cannot be dropped here: \(\alpha_r\) is monotone, so any assignment setting more indicators true would satisfy it too, admitting models that select two values of one variable and describe no instantiation at all.
Provide an algorithm for generating circuits that can be used to compute MAP. Describe the computational complexity of the method.
Compile with an \(\mathbf{M}\)-constrained elimination order and turn the addition nodes of the MAP variables into maximization nodes.
- Choose an order \(\pi\) in which every variable of \(\mathbf{Y} = \mathbf{Z}\setminus\mathbf{M}\) precedes every variable of \(\mathbf{M}\) (run min-fill on \(\mathbf{Y}\) first, then on \(\mathbf{M}\)); let \(w_{\mathbf{M}}\), the constrained width, be its width.
- Run the circuit-generating variable elimination of Section 12.4.1 along \(\pi\), labelling every addition node with the variable \(\mathrm{var}(n)\) whose elimination created it, as in Exercise 12.7.
- Replace each addition node with \(\mathrm{var}(n) \in \mathbf{M}\) by a maximization node, leaving the others alone; call the result \(AC^{\mathrm{map}}\).
Evaluating \(AC^{\mathrm{map}}\) bottom-up with \(\lambda_x = 1\) iff \(x \sim e\) leaves
\begin{equation*} \mathrm{MAP}_P(\mathbf{M}, e) \;=\; \max_{\mathbf{m}} \sum_{\mathbf{y}} \Pr(\mathbf{m}, \mathbf{y}, e) \end{equation*}
at the root, and recording the maximizing child at each maximization node reads off a MAP instantiation directly – the node created by eliminating \(M\) has one child per value of \(M\).
The constrained order is what makes this exact rather than an upper bound: a circuit node is created only after its children, so no node created while eliminating some \(M \in \mathbf{M}\) is a descendant of one created while eliminating some \(Y \in \mathbf{Y}\); hence in \(AC^{\mathrm{map}}\) no maximization node lies below an addition node, and bottom-up evaluation performs \(\max_{\mathbf{m}}\sum_{\mathbf{y}}\), never \(\sum_{\mathbf{y}}\max_{\mathbf{m}}\). Formally this is the variable-elimination induction with \(\max\) in place of \(\sum\) for the \(\mathbf{M}\) variables, licensed by nonnegativity as in Exercise 12.7.
Complexity: \(O(n \exp(w_{\mathbf{M}}))\) to construct the circuit, with the conversion, evaluation and extraction all linear in its size, so each later evidence costs one pass. Here \(w_{\mathbf{M}} \ge w\) and the gap can be arbitrarily large – unavoidably, since D-MAP is NP-complete already on polytrees of treewidth at most \(2\) (Theorem 11.6), while \(O(n\exp(w))\) would place MAP alongside MPE. Compiling with an unconstrained order and maximizing the same nodes costs only \(O(n\exp(w))\) but returns the upper bound of Exercise 12.7 instead. When \(\mathbf{M}\) is all of \(\mathbf{Z}\), every addition node becomes a maximization node and \(AC^{\mathrm{map}}\) is the maximizer circuit of Definition 12.4.
Consider a Bayesian network with structure \(A \to B \to C\), where all variables are binary and its jointree is \(A - AB - BC\). Construct the arithmetic circuit embedded in this jointree as given in Section 12.4.2, assuming that \(BC\) is the root cluster and that CPTs and evidence indicators for variables \(A\), \(B\), and \(C\) are assigned to clusters \(A\), \(AB\), and \(BC\), respectively.
That is: the jointree has three clusters \(\mathbf{C}_1 = \{A\}\), \(\mathbf{C}_2 = \{A,B\}\) and \(\mathbf{C}_3 = \{B,C\}\), with edges \(\mathbf{C}_1 - \mathbf{C}_2\) and \(\mathbf{C}_2 - \mathbf{C}_3\), hence separators \(\mathbf{S}_{12} = \{A\}\) and \(\mathbf{S}_{23} = \{B\}\). Cluster \(BC\) is the root, so \(AB\) is its child and \(A\) is the child of \(AB\). The CPT \(\Theta_A\) and indicator \(\lambda_A\) are assigned to cluster \(A\); the CPT \(\Theta_{B|A}\) and indicator \(\lambda_B\) to cluster \(AB\); the CPT \(\Theta_{C|B}\) and indicator \(\lambda_C\) to cluster \(BC\). Variables \(A\), \(B\), \(C\) have values \(a_1, a_2\); \(b_1, b_2\); \(c_1, c_2\).
By Definition 12.7 with \(\mathbf{C}_3 = BC\) as root, the parent-to-child chain is
\begin{equation*} \mathbf{C}_3 \;\longrightarrow\; \mathbf{S}_{23} \;\longrightarrow\; \mathbf{C}_2 \;\longrightarrow\; \mathbf{S}_{12} \;\longrightarrow\; \mathbf{C}_1 , \end{equation*}
so separator \(B\) is the child of cluster \(BC\) and the parent of cluster \(AB\), and separator \(A\) is the child of \(AB\) and the parent of cluster \(A\). The circuit therefore has one multiplication node per cluster instantiation (ten), one addition node per separator instantiation (four), the output addition node \(f\), and the six indicator and ten parameter inputs. A cluster node multiplies the inputs assigned to its cluster that are compatible with its instantiation together with the compatible addition nodes of its child separators; a separator node adds the compatible multiplication nodes of its child cluster; \(f\) adds the multiplication nodes of the root cluster. Bottom-up:
\begin{equation*} \begin{aligned} n_{a_1} &= \lambda_{a_1} \star \theta_{a_1}, & n_{a_2} &= \lambda_{a_2} \star \theta_{a_2}, \\ s_{a_1} &= n_{a_1}, & s_{a_2} &= n_{a_2}, \\ n_{a_1b_1} &= \lambda_{b_1} \star \theta_{b_1|a_1} \star s_{a_1}, & n_{a_1b_2} &= \lambda_{b_2} \star \theta_{b_2|a_1} \star s_{a_1}, \\ n_{a_2b_1} &= \lambda_{b_1} \star \theta_{b_1|a_2} \star s_{a_2}, & n_{a_2b_2} &= \lambda_{b_2} \star \theta_{b_2|a_2} \star s_{a_2}, \\ s_{b_1} &= n_{a_1b_1} + n_{a_2b_1}, & s_{b_2} &= n_{a_1b_2} + n_{a_2b_2}, \\ n_{b_1c_1} &= \lambda_{c_1} \star \theta_{c_1|b_1} \star s_{b_1}, & n_{b_1c_2} &= \lambda_{c_2} \star \theta_{c_2|b_1} \star s_{b_1}, \\ n_{b_2c_1} &= \lambda_{c_1} \star \theta_{c_1|b_2} \star s_{b_2}, & n_{b_2c_2} &= \lambda_{c_2} \star \theta_{c_2|b_2} \star s_{b_2}, \end{aligned} \end{equation*}
and the output node
\begin{equation*} f = n_{b_1c_1} + n_{b_1c_2} + n_{b_2c_1} + n_{b_2c_2}, \end{equation*}
the \(n\)-nodes being multiplication nodes and the \(s\)-nodes and \(f\) addition nodes. Unfolding from the root gives \(\sum_{i,j,k}\lambda_{a_i}\lambda_{b_j}\lambda_{c_k}\, \theta_{a_i}\theta_{b_j|a_i}\theta_{c_k|b_j}\) (Check!), the network polynomial of the chain, as Theorem 12.5 guarantees; the counts match its bound, \(3 \cdot 2^2 = 12 \ge 10\) multiplication nodes and \(2 \cdot 2^1 = 4\) separator addition nodes. The nodes \(s_{a_i}\) have a single child each, cluster \(A\) coinciding with its parent separator, but the uncollapsed form is the one Definition 12.7 prescribes and the one that preserves the strict alternation of Exercise 12.11.
Show that the arithmetic circuit embedded in a jointree has the following properties:
- (a) The circuit alternates between addition and multiplication nodes.
- (b) Each multiplication node has a single parent.
(Recall Definition 12.7: given a rooted jointree with an assignment of CPTs and evidence indicators to clusters, the embedded circuit has one output addition node \(f\); one addition node \(s\) per instantiation \(\mathbf{s}\) of each separator \(\mathbf{S}\); one multiplication node \(c\) per instantiation \(\mathbf{c}\) of each cluster \(\mathbf{C}\); and input nodes \(\lambda_x\) and \(\theta_{x|\mathbf{u}}\). The children of \(f\) are the multiplication nodes of the root cluster; the children of \(s\) are the compatible multiplication nodes of the child cluster of \(\mathbf{S}\); the children of \(c\) are the compatible addition nodes of the child separators of \(\mathbf{C}\) together with the compatible inputs \(\theta_{x|\mathbf{u}}\) and \(\lambda_x\) whose CPT \(\Theta_{X|\mathbf{U}}\) or indicator \(\lambda_X\) is assigned to \(\mathbf{C}\).)
Both properties are read off the children in Definition 12.7, using that in a rooted jointree every nonroot cluster has exactly one parent separator and every separator exactly one parent and one child cluster.
(a) An addition node is either the output node \(f\), whose children are the multiplication nodes of the root cluster, or a separator node \(s\), whose children are the multiplication nodes \(c\) with \(\mathbf{c} \sim \mathbf{s}\) of the child cluster of \(\mathbf{S}\); either way every child is a multiplication node, so an addition node has neither an addition child nor a leaf child. A multiplication node \(c\) has as children the addition nodes \(s\) with \(\mathbf{s} \sim \mathbf{c}\) of the child separators of \(\mathbf{C}\), together with input nodes, so it has no multiplication child. Hence the types strictly alternate \(+, \star, +, \star, \ldots\) down every path from the root, one multiplication level per cluster and one addition level per separator, and leaves have only multiplication parents – exactly the structural assumption of Algorithm 35.
(b) All parents of a multiplication node \(c\) are addition nodes by (a), so it is enough to see which addition nodes list \(c\) as a child.
(i) \(\mathbf{C}\) is the root cluster. It is the child of no separator, and separator nodes take their children from their child cluster, so no separator node lists \(c\); the output node \(f\) is its only parent.
(ii) \(\mathbf{C}\) is not the root cluster. Then \(f\), which takes children only from the root cluster, does not list \(c\), and the unique parent separator \(\mathbf{S}\) of \(\mathbf{C}\) is the only separator whose child cluster is \(\mathbf{C}\). Its node \(s\) lists \(c\) precisely when \(\mathbf{s} \sim \mathbf{c}\), and since \(\mathbf{S} \subseteq \mathbf{C}\) exactly one instantiation of \(\mathbf{S}\) is compatible with \(\mathbf{c}\), namely the projection \(\mathbf{c}|_{\mathbf{S}}\). So \(c\) again has exactly one parent. \(\blacksquare\)
Given an arithmetic circuit that is embedded in a binary jointree, describe a circuit propagation scheme that will evaluate and differentiate the circuit under the following constraints:
- The method can use only two registers for each addition or leaf node but no registers for multiplication nodes.
- The time complexity of the algorithm is linear in the circuit size.
Compare your developed scheme to the Shenoy-Shafer architecture for jointree propagation. Recall that a binary jointree is one in which each cluster has at most three neighbors.
Keep two registers at every addition node and every leaf and none at multiplication nodes. Exercise 12.11 makes that enough: a multiplication node \(c\) has a unique parent \(p\), an addition node, so the chain rule gives
\begin{equation*} \mathrm{dr}( c) \;=\; \mathrm{dr}(p) \cdot \frac{\partial\, \mathrm{vr}(p)}{\partial\, \mathrm{vr}( c)} \;=\; \mathrm{dr}(p), \end{equation*}
and all children of \(c\) are addition nodes or leaves, which do have value registers, so \(\mathrm{vr}( c) = \prod_{v \in \mathrm{ch}( c)} \mathrm{vr}(v)\) is recomputable on demand.
Upward pass. Set \(\mathrm{vr}(\lambda_x) = 1\) if \(x \sim e\) and \(0\) otherwise, and each \(\mathrm{vr}(\theta_{x|\mathbf{u}})\) to its network parameter; then visit addition nodes children-before-parents,
\begin{equation*} \mathrm{vr}(p) \;\longleftarrow\; \sum_{c \,\in\, \mathrm{ch}(p)} \; \prod_{v \,\in\, \mathrm{ch}( c)} \mathrm{vr}(v), \end{equation*}
every \(v\) on the right being an addition node or a leaf, hence already filled; \(\mathrm{vr}( c)\) is formed and consumed inside the sum and never stored.
Downward pass. Set \(\mathrm{dr}( r) = 1\) at the output node and \(0\) at every other addition node and leaf; then visit addition nodes parents-before-children, executing for each multiplication child \(c\) of \(p\)
\begin{equation*} \mathrm{dr}(v) \;\longleftarrow\; \mathrm{dr}(v) \;+\; \mathrm{dr}(p) \prod_{v^{\prime} \,\in\, \mathrm{ch}( c),\; v^{\prime} \neq v} \mathrm{vr}(v^{\prime}), \qquad v \in \mathrm{ch}( c), \end{equation*}
which is line 10 of Algorithm 34 with \(\mathrm{dr}( c)\) replaced by \(\mathrm{dr}(p)\).
Correctness. The upward pass merely inlines the multiplication nodes, so it computes the values of line 2 of Algorithm 34. The downward pass accumulates \(\mathrm{dr}(v) = \sum_{c \in \mathrm{pa}(v)} \mathrm{dr}( c) \prod_{v^{\prime} \ne v} \mathrm{vr}(v^{\prime})\), the identity of Section 12.3.1 for a node all of whose parents are multiplication nodes – which by Exercise 12.11(a) every addition node and every leaf is, so line 8 of Algorithm 34 never fires for such a \(v\) and no addition-parent term is missing. The top-down order makes \(\mathrm{dr}(p)\) final before it is used. Hence \(\mathrm{dr}(v) = \partial f/\partial\,\mathrm{vr}(v)\) at every leaf, and Theorem 12.2 applies unchanged.
In a binary jointree a cluster has at most three neighbours, hence at most two child separators, so \(k = |\mathrm{ch}( c)|\) is \(O(1)\) and the \(k\) sibling products may simply be formed one at a time: the upward pass costs \(\sum_c O(k)\) and the downward \(\sum_c O(k^2)\), both linear in the circuit size, with no division and no special handling of zeros. (Without the binary assumption, prefix and suffix products \(L_i = \prod_{j<i}\mathrm{vr}(v_j)\), \(R_i = \prod_{j>i}\mathrm{vr}(v_j)\) give \(O(k)\) using \(O(k)\) scratch words reused from node to node.)
The scheme is Shenoy-Shafer. That architecture stores two factors per separator, the messages \(M_{ij}\) and \(M_{ji}\), and nothing at the clusters; here \(\mathrm{vr}(s)\) is the entry of the inward message at \(\mathbf{s}\) and \(\mathrm{dr}(s)\) the entry of the outward one, with nothing at the cluster-instantiation nodes – space exponential in separator size, not cluster size. Its message \(M_{ij} = \sum_{\mathbf{C}_i \setminus \mathbf{S}_{ij}} \Phi_i \prod_{k \neq j} M_{ki}\) (7.4) re-multiplies assigned factors and incoming messages instead of materializing a cluster table, which is what recomputing \(\mathrm{vr}( c)\) and the sibling products does; and its cluster marginal \(\Pr(\mathbf{C}_i, e) = \Phi_i \prod_k M_{ki}\) (7.5) is
\begin{equation*} \mathrm{dr}( c)\,\mathrm{vr}( c) \;=\; \mathrm{dr}(p) \prod_{v \in \mathrm{ch}( c)} \mathrm{vr}(v), \end{equation*}
the very expression the downward pass forms. The binary restriction plays the same role in both: in Section 7.7.3 it keeps \(\alpha = \sum_i n_i^2\) linear in \(n\), here it bounds the children of a multiplication node. Only the bookkeeping differs – a cluster waiting for messages from all neighbours but \(j\) becomes a static topological traversal fixed when the circuit is compiled.
Given an arithmetic circuit that is embedded in a jointree, describe a circuit propagation scheme that will evaluate and differentiate the circuit under the following constraints:
- The method can use only one register \(\mathrm{dvr}(v)\) for each circuit node \(v\).
- When the algorithm terminates, the register \(\mathrm{dvr}(v)\) contains the product \(\mathrm{dr}(v)\,\mathrm{vr}(v)\), where \(\mathrm{dr}(v)\) and \(\mathrm{vr}(v)\) are as computed by Algorithm 34.
- The time complexity of the algorithm is linear in the circuit size.
Compare your developed scheme to the Hugin architecture for jointree propagation.
(Algorithm 34 is the two-pass circuit propagation scheme: an upward pass computes the value \(\mathrm{vr}(v)\) of every node at the given evidence, and a downward pass computes \(\mathrm{dr}(v) = \partial\, \mathrm{vr}( r)/\partial\, \mathrm{vr}(v)\) for the circuit root \(r\), using
\begin{equation*} \mathrm{dr}(v) \leftarrow \mathrm{dr}(v) + \mathrm{dr}(p) \end{equation*}
for an addition parent \(p\) and
\begin{equation*} \mathrm{dr}(v) \leftarrow \mathrm{dr}(v) + \mathrm{dr}(p) \prod_{v^{\prime} \neq v} \mathrm{vr}(v^{\prime}) \end{equation*}
for a multiplication parent \(p\).)
One register suffices because \(\mathrm{dr}(v)\mathrm{vr}(v)\) obeys a pure sum recurrence downward. By Exercise 12.11 the circuit strictly alternates, every multiplication node has a single (addition) parent, and every parent of an addition node or leaf is a multiplication node; so the circuit is layered (layer \(0\) the root) with all parents of a node in one layer. Algorithm 34 gives \(\mathrm{dr}( c) = \mathrm{dr}(p)\) at a multiplication node \(c\) with its unique addition parent \(p\), hence for \(\mathrm{vr}(p) \neq 0\)
\begin{equation*} \text{(I)}\quad \mathrm{dr}( c)\,\mathrm{vr}( c) \;=\; \frac{\mathrm{dr}(p)\,\mathrm{vr}(p)}{\mathrm{vr}(p)}\;\mathrm{vr}( c), \end{equation*}
while at an addition node or leaf \(v\), all of whose parents are multiplication nodes,
\begin{equation*} \begin{aligned} \text{(II)}\quad \mathrm{dr}(v)\,\mathrm{vr}(v) &= \mathrm{vr}(v) \sum_{c \in \mathrm{pa}(v)} \mathrm{dr}( c) \prod_{v^{\prime} \in \mathrm{ch}( c),\, v^{\prime} \neq v} \mathrm{vr}(v^{\prime}) \\ &= \sum_{c \in \mathrm{pa}(v)} \mathrm{dr}( c) \prod_{v^{\prime} \in \mathrm{ch}( c)} \mathrm{vr}(v^{\prime}) \;=\; \sum_{c \in \mathrm{pa}(v)} \mathrm{dr}( c)\,\mathrm{vr}( c) , \end{aligned} \end{equation*}
so no sibling values are needed. Pass 1 is the upward pass of Algorithm 34 run in \(\mathrm{dvr}\), leaving \(\mathrm{dvr}(v) = \mathrm{vr}(v)\) and the root at \(\Pr(e)\). Pass 2 runs layer by layer under the invariant that on entering layer \(d\) its registers hold \(\mathrm{dr}\,\mathrm{vr}\) and all deeper layers still hold \(\mathrm{vr}\) (true at layer \(0\), where \(\mathrm{dr}( r) = 1\)):
- (i) Addition layer \(d\). For each addition node \(p\) set \(t \leftarrow \sum_{c \in \mathrm{ch}(p)} \mathrm{dvr}( c) = \mathrm{vr}(p)\), then \(\rho \leftarrow \mathrm{dvr}(p)/t\) if \(t \neq 0\) and \(\rho \leftarrow 0\) otherwise, and \(\mathrm{dvr}( c) \leftarrow \rho\,\mathrm{dvr}( c)\) at every child: this is (I), and since circuit values are nonnegative \(t = 0\) forces every \(\mathrm{vr}( c) = 0\), so \(\rho = 0\) is correct and no division by zero occurs.
- (ii) Multiplication layer \(d\). Zero layer \(d+1\), then \(\mathrm{dvr}(v) \leftarrow \mathrm{dvr}(v) + \mathrm{dvr}( c)\) for each child \(v\) of each \(c\): this is (II).
Each node collects all contributions before its own layer is processed, so the invariant propagates and every register terminates at \(\mathrm{dr}(v)\mathrm{vr}(v)\); overwriting \(\mathrm{vr}\) at layer \(d+1\) is safe because the only later read of a value register is the \(t\) of layer \(d+1\), which reads layer \(d+2\). Each edge is traversed twice per pass, so the work is linear for an arbitrary jointree — no binary restriction as in Exercise 12.12.
Comparison with Hugin. This is Hugin propagation written node by node: one register per multiplication node (cluster instantiation) and one per addition node (separator instantiation) mirror Hugin’s single \(\Phi_i\) per cluster and \(\Phi_{ij}\) per separator with no message tables, and by Theorem 12.2 they terminate at \(\Pr(\mathbf{c}, e)\) and \(\Pr(\mathbf{s}, e)\) — entry for entry Hugin’s \(\Phi_i\) and \(\Phi_{ij}\). Bullet (ii) is Hugin’s marginalization \(\Phi_{ij} \leftarrow \sum_{\mathbf{C}_i \setminus \mathbf{S}_{ij}} \Phi_i\) and bullet (i) its division-and-multiply \(\Phi_j \leftarrow \Phi_j \Phi_{ij}/\Phi_{ij}^{\mathrm{old}}\), with \(\rho \leftarrow 0\) at \(t = 0\) the convention \(f_1/f_2 = 0\) of Definition 7.7.
Consider the arithmetic circuit in Figure 12.13. Evaluate and differentiate this circuit at evidence \(e = b_2\) using the propagation scheme given by Algorithm 36. Compute all MPE instantiations given the evidence and describe the meaning of derivatives with respect to inputs \(\lambda_{a_1}\) and \(\theta_{c_2|a_2}\).
The circuit of Figure 12.13 is the arithmetic circuit of the Bayesian network with structure \(A \to B\), \(A \to C\), all three variables having two values (\(a_1,a_2\); \(b_1,b_2\); \(c_1,c_2\)), and with parameters
| \(\theta_{a_1}\) | \(\theta_{a_2}\) |
|---|---|
| .1 | .9 |
| \(\theta_{b_1 \mid a_1}\) | \(\theta_{b_2 \mid a_1}\) | \(\theta_{b_1 \mid a_2}\) | \(\theta_{b_2 \mid a_2}\) |
|---|---|---|---|
| .2 | .8 | .3 | .7 |
| \(\theta_{c_1 \mid a_1}\) | \(\theta_{c_2 \mid a_1}\) | \(\theta_{c_1 \mid a_2}\) | \(\theta_{c_2 \mid a_2}\) |
|---|---|---|---|
| .4 | .6 | .01 | .99 |
Its structure, from the leaves upward, is the following (each node listed with its children; \(\star\) denotes a multiplication node):
- \(p_{a} = \lambda_{a} \star \theta_{a}\), for \(a \in \{a_1,a_2\}\);
- \(q_{c,a} = \lambda_{c} \star \theta_{c|a}\), for each of the four pairs \(c,a\);
- \(s_{a} = q_{c_1,a} + q_{c_2,a}\), an addition node, for \(a \in \{a_1,a_2\}\);
- \(h_{b,a} = \theta_{b|a} \star p_{a}\), for each of the four pairs \(b,a\);
- \(m_{b,a} = h_{b,a} \star s_{a}\), for each of the four pairs \(b,a\);
- \(t_{b} = m_{b,a_1} + m_{b,a_2}\), an addition node, for \(b \in \{b_1,b_2\}\);
- \(u_{b} = \lambda_{b} \star t_{b}\), for \(b \in \{b_1,b_2\}\);
- the output addition node \(f = u_{b_1} + u_{b_2}\).
Algorithm 36 is the maximizer-circuit propagation scheme: the addition nodes of the circuit are replaced by maximization nodes, an upward pass fills the value registers \(\mathrm{vr}(v)\), then \(\mathrm{dr}\) is set to \(1\) at the root and \(0\) elsewhere, and a downward pass sets
\begin{equation*} \mathrm{dr}(v) \leftarrow \max(\mathrm{dr}(v), \mathrm{dr}(p)) \end{equation*}
for each maximization parent \(p\) of \(v\) and
\begin{equation*} \mathrm{dr}(v) \leftarrow \max\Bigl(\mathrm{dr}(v),\; \mathrm{dr}(p) \prod_{v^{\prime} \neq v} \mathrm{vr}(v^{\prime})\Bigr) \end{equation*}
for each multiplication parent \(p\).
Replacing the addition nodes \(s_a, t_b, f\) by maximization nodes gives the maximizer circuit \(AC^m\) of Definition 12.4; at \(e = b_2\) the indicators are \(\lambda_{b_1} = 0\) and all others \(1\), with each \(\theta\) leaf at its network value.
Upward pass.
\begin{equation*} \begin{aligned} \mathrm{vr}(p_{a_1}) &= .1, & \mathrm{vr}(p_{a_2}) &= .9, \\ \mathrm{vr}(q_{c_1,a_1}) &= .4,\; \mathrm{vr}(q_{c_2,a_1}) = .6, & \mathrm{vr}(q_{c_1,a_2}) &= .01,\; \mathrm{vr}(q_{c_2,a_2}) = .99, \\ \mathrm{vr}(s_{a_1}) &= \max(.4,.6) = .6, & \mathrm{vr}(s_{a_2}) &= \max(.01,.99) = .99, \\ \mathrm{vr}(h_{b_1,a_1}) &= .02,\; \mathrm{vr}(h_{b_2,a_1}) = .08, & \mathrm{vr}(h_{b_1,a_2}) &= .27,\; \mathrm{vr}(h_{b_2,a_2}) = .63, \\ \mathrm{vr}(m_{b_1,a_1}) &= .012,\; \mathrm{vr}(m_{b_2,a_1}) = .048, & \mathrm{vr}(m_{b_1,a_2}) &= .2673,\; \mathrm{vr}(m_{b_2,a_2}) = .6237, \\ \mathrm{vr}(t_{b_1}) &= .2673, & \mathrm{vr}(t_{b_2}) &= .6237, \\ \mathrm{vr}(u_{b_1}) &= 0, & \mathrm{vr}(u_{b_2}) &= .6237, \end{aligned} \end{equation*}
so \(AC^m(e) = \mathrm{vr}(f) = \max(0,.6237) = .6237 = \mathrm{MPE}_P(b_2)\).
Downward pass. Set \(\mathrm{dr}(f) = 1\) and all else \(0\); the maximization node \(f\) passes \(1\) to both \(u_b\), and Algorithm 36 then gives
\begin{equation*} \begin{aligned} \mathrm{dr}(\lambda_{b_1}) &= .2673, & \mathrm{dr}(t_{b_1}) &= 0, \\ \mathrm{dr}(\lambda_{b_2}) &= .6237, & \mathrm{dr}(t_{b_2}) &= 1, \\ \mathrm{dr}(m_{b_2,a}) &= 1, & \mathrm{dr}(m_{b_1,a}) &= 0, \\ \mathrm{dr}(h_{b_2,a_1}) &= \mathrm{vr}(s_{a_1}) = .6, & \mathrm{dr}(h_{b_2,a_2}) &= \mathrm{vr}(s_{a_2}) = .99, \\ \mathrm{dr}(s_{a_1}) &= \mathrm{vr}(h_{b_2,a_1}) = .08, & \mathrm{dr}(s_{a_2}) &= \mathrm{vr}(h_{b_2,a_2}) = .63, \\ \mathrm{dr}(p_{a_1}) &= \max(0 \cdot .2,\; .6 \cdot .8) = .48, & \mathrm{dr}(p_{a_2}) &= \max(0 \cdot .3,\; .99 \cdot .7) = .693, \end{aligned} \end{equation*}
every contribution through \(m_{b_1,a}\) being \(0\) and losing its maximization, so \(\mathrm{dr}(h_{b_1,a}) = 0\); the \(s_a\) pass their registers down unchanged, giving \(\mathrm{dr}(q_{c,a_1}) = .08\) and \(\mathrm{dr}(q_{c,a_2}) = .63\). At the shared leaves \(\lambda_c\) the maximum over the two parents is taken: \(\mathrm{dr}(\lambda_{c_1}) = \max(.032, .0063) = .032\) and \(\mathrm{dr}(\lambda_{c_2}) = \max(.048, .6237) = .6237\). Collecting the leaf derivatives:
| leaf | \(\lambda_{a_1}\) | \(\lambda_{a_2}\) | \(\lambda_{b_1}\) | \(\lambda_{b_2}\) | \(\lambda_{c_1}\) | \(\lambda_{c_2}\) |
|---|---|---|---|---|---|---|
| \(\mathrm{dr}\) | .048 | .6237 | .2673 | .6237 | .032 | .6237 |
| leaf | \(\theta_{a_1}\) | \(\theta_{a_2}\) | \(\theta_{b_1 \mid a_1}\) | \(\theta_{b_2 \mid a_1}\) | \(\theta_{b_1 \mid a_2}\) | \(\theta_{b_2 \mid a_2}\) |
|---|---|---|---|---|---|---|
| \(\mathrm{dr}\) | .48 | .693 | 0 | .06 | 0 | .891 |
| leaf | \(\theta_{c_1 \mid a_1}\) | \(\theta_{c_2 \mid a_1}\) | \(\theta_{c_1 \mid a_2}\) | \(\theta_{c_2 \mid a_2}\) |
|---|---|---|---|---|
| \(\mathrm{dr}\) | .08 | .08 | .63 | .63 |
These agree with Theorem 12.4, \(\partial f^m_x/\partial \lambda_x (e) = \mathrm{MPE}_P(x, e - X)\), and with (12.10), \(\theta_{x|\mathbf{u}}\,\partial f^m_{x,\mathbf{u}} / \partial \theta_{x|\mathbf{u}}(e) = \mathrm{MPE}_P(e, x, \mathbf{u})\), read off the joint \(\Pr(a,b,c) = \theta_a \theta_{b|a} \theta_{c|a}\):
| instantiation | \(a_1b_1c_1\) | \(a_1b_1c_2\) | \(a_1b_2c_1\) | \(a_1b_2c_2\) | \(a_2b_1c_1\) | \(a_2b_1c_2\) | \(a_2b_2c_1\) | \(a_2b_2c_2\) |
|---|---|---|---|---|---|---|---|---|
| \(\Pr\) | .008 | .012 | .032 | .048 | .0027 | .2673 | .0063 | .6237 |
for instance \(\mathrm{MPE}_P(a_1, b_2) = \max(.032,.048) = .048 = \mathrm{dr}(\lambda_{a_1})\) (Check! for the remaining entries).
All MPE instantiations. These are the complete subcircuits (Definition 12.5) whose every maximization choice attains the parent’s value; descending from the root:
- (i) at \(f\): \(\mathrm{vr}(u_{b_1}) = 0 \neq .6237\), so only \(u_{b_2}\), giving \(B = b_2\);
- (ii) at \(t_{b_2}\): \(\mathrm{vr}(m_{b_2,a_1}) = .048 \neq .6237\), so only \(m_{b_2,a_2}\), which via \(h_{b_2,a_2}\) contributes \(p_{a_2}\), giving \(A = a_2\);
- (iii) at \(s_{a_2}\): \(\mathrm{vr}(q_{c_1,a_2}) = .01 \neq .99\), so only \(q_{c_2,a_2}\), giving \(C = c_2\).
Every maximization node has a unique maximizing child, so \(a_2 b_2 c_2\) is the one MPE instantiation, of probability \(.6237\).
By (12.9), \(\mathrm{dr}(\lambda_{a_1}) = \mathrm{MPE}_P(a_1, e - A) = \mathrm{MPE}_P(a_1, b_2)\): the MPE probability that strengthening the evidence to \(a_1 b_2\) would give, read off without re-evaluating the circuit; as \(.048 < .6237 = \mathrm{dr}(\lambda_{a_2})\), the criterion of Exercise 12.15 says \(a_1\) occurs in no MPE instantiation. By (12.7), \(\mathrm{dr}(\theta_{c_2|a_2})\) is the rate of change of the maximizer polynomial restricted to terms containing \(\theta_{c_2|a_2}\) — the restriction being what makes it well defined, since for \(\theta = \theta_{c_2|a_2}\) the unrestricted \(f^m(b_2) = \max(.63\,\theta, .048)\) has a kink at \(\theta = .048/.63\) while \(f^m_{c_2,a_2} = .63\,\theta\) is linear — and by (12.10) its scaled value
\begin{equation*} \theta_{c_2|a_2}\,\frac{\partial f^m_{c_2,a_2}}{\partial \theta_{c_2|a_2}}(e) = .99 \cdot .63 = .6237 = \mathrm{MPE}_P(b_2, c_2, a_2) \end{equation*}
equals \(\mathrm{MPE}_P(b_2)\), so the family instantiation \(c_2 a_2\) does occur in an MPE instantiation.
Exercises 12.15–12.20
Let \(X\) be a binary variable, with values \(x\) and \(\bar x\), in a Bayesian network with maximizer polynomial \(f^m\). Show that every MPE instantiation for evidence \(e\) includes \(X = x\) if and only if
\begin{equation*} \frac{\partial f^m_x}{\partial \lambda_x}(e) \;>\; \frac{\partial f^m_{\bar x}}{\partial \lambda_{\bar x}}(e). \end{equation*}
Here \(f^m_x\) denotes the restriction of the maximizer polynomial to \(x\) in the sense of Definition 12.6. Assume that variable \(X\) is not instantiated by the evidence \(e\).
Since \(X\) is unset by \(e\) we have \(e - X = e\), so Theorem 12.4 identifies the two derivatives with \(d_x = \mathrm{MPE}_P(x,e)\) and \(d_{\bar x} = \mathrm{MPE}_P(\bar x, e)\), and the claim reads: every MPE instantiation for \(e\) sets \(X = x\) iff \(d_x > d_{\bar x}\). Writing \(z \sim e\) for compatibility of a complete instantiation, binary \(X\) partitions \(\{z : z \sim e\}\) into the two nonempty sets \(\{z \sim xe\}\) and \(\{z \sim \bar x e\}\), so
\begin{equation*} \mathrm{MPE}_P(e) \;=\; \max(d_x, d_{\bar x}). \tag{\(\ast\)} \end{equation*}
(i) \(\Leftarrow\). If \(d_x > d_{\bar x}\) then \(\mathrm{MPE}_P(e) = d_x\) by \((\ast)\), and an MPE instantiation \(z^\star\) setting \(X = \bar x\) would satisfy \(z^\star \sim \bar x e\), whence \(d_x = \mathrm{Pr}(z^\star) \le d_{\bar x} < d_x\) — a contradiction.
(ii) \(\Rightarrow\), by contraposition. If \(d_x \le d_{\bar x}\) then \(\mathrm{MPE}_P(e) = d_{\bar x}\) by \((\ast)\), and the nonempty finite set \(\{z \sim \bar x e\}\) contains some \(z^\star\) attaining \(d_{\bar x} = \mathrm{MPE}_P(e)\) — an MPE instantiation setting \(X = \bar x\).
Show the MLF encoded by the propositional sentence
\begin{equation*} \Delta \;=\; A \wedge (B \Rightarrow D) \wedge (C \Rightarrow B). \end{equation*}
Recall the encoding convention of Section 12.4.3: a propositional sentence \(\Delta\) over variables \(V_1,\dots,V_n\) encodes a multi-linear function over corresponding MLF variables, where each model \(\omega\) of \(\Delta\) contributes one term, and MLF variable \(X\) appears in that term if and only if \(\omega\) sets the propositional variable \(X\) to true. The MLF encoded by \(\Delta\) is the sum of the terms contributed by all of its models.
The MLF encoded by \(\Delta\) is
\begin{equation*} f \;=\; A \;+\; AD \;+\; ABD \;+\; ABCD . \end{equation*}
Over \(\{A,B,C,D\}\) the first conjunct forces \(A\) true, and splitting on \(B\): with \(B\) false, \(C \Rightarrow B\) forces \(C\) false and \(D\) is free; with \(B\) true, \(B \Rightarrow D\) forces \(D\) true and \(C\) is free. So \(\Delta\) has exactly four models, each contributing the product of the variables it sets true:
| model | \(A\) | \(B\) | \(C\) | \(D\) | encoded term |
|---|---|---|---|---|---|
| \(\omega_1\) | true | false | false | false | \(A\) |
| \(\omega_2\) | true | false | false | true | \(AD\) |
| \(\omega_3\) | true | true | false | true | \(ABD\) |
| \(\omega_4\) | true | true | true | true | \(ABCD\) |
Let \(\Delta_f\) be a propositional sentence encoding an MLF \(f\) (each model of \(\Delta_f\) encodes the term containing exactly those MLF variables \(X\) for which the model sets the propositional variable \(V_X\) to true, and \(f\) is the sum of these terms). Let \(\Gamma_f\) be an equivalent NNF circuit that satisfies decomposability, determinism, and smoothness. Show that the arithmetic circuit extracted from \(\Gamma_f\) as given in Section 12.4.3 is a representation of the MLF \(f\). Recall the extraction rules: replace every and-node by a multiplication node, every or-node by an addition node, every negative literal \(\neg V_X\) by the constant \(1\), and every positive literal \(V_X\) by the MLF variable \(X\).
Structural induction on \(\Gamma_f\). For a node \(N\) let \(\Delta_N\) be the sentence it represents, \(\mathrm{vars}(N)\) the variables labelling the leaves below it, \(g_N\) the polynomial computed at the extracted node, and
\begin{equation*} h_N \;\stackrel{\text{def}}{=}\; \sum_{\substack{\omega \models \Delta_N \\ \omega \text{ over } \mathrm{vars}(N)}} t(\omega) , \qquad t(\omega) \;=\; \prod_{\substack{X \in \mathrm{vars}(N) \\ \omega(V_X) = \mathrm{true}}} X , \end{equation*}
the MLF encoded by \(\Delta_N\) read over \(\mathrm{vars}(N)\). Smoothness is taken relative to the full variable set of \(\Delta_f\) — what Exercise 2.11 delivers, and what is needed, since Section 2.7 smoothness alone constrains only an or-node’s children and would let the root omit a variable of \(f\) — so \(h_{\text{root}} = f\), and it suffices to prove \(g_N = h_N\).
- (i) Leaves. For \(N = V_X\) the single model over \(\{X\}\) sets \(V_X\) true, of term \(X\), and extraction gives the leaf \(X\); for \(N = \neg V_X\) the single model sets \(V_X\) false, contributing the empty product \(1\), and extraction gives the constant \(1\) — a negative literal omits a variable from a term rather than killing the term.
- (ii) And-nodes (decomposability). \(\Delta_N = \bigwedge_i \Delta_{C_i}\) and \(\mathrm{vars}(N) = \bigcup_i \mathrm{vars}(C_i)\), the union disjoint, so every \(\omega\) over \(\mathrm{vars}(N)\) factors uniquely as \((\omega_1,\dots,\omega_k)\) with \(\omega \models \Delta_N\) iff \(\omega_i \models \Delta_{C_i}\) for all \(i\) (each \(\Delta_{C_i}\) mentioning only \(\mathrm{vars}(C_i)\)) and \(t(\omega) = \prod_i t(\omega_i)\); distributing the product over the sums gives \(h_N = \prod_i h_{C_i}\), and extraction made \(N\) a multiplication node, so \(g_N = \prod_i g_{C_i} = h_N\) by the hypothesis.
- (iii) Or-nodes (smoothness, determinism). \(\Delta_N = \bigvee_i \Delta_{C_i}\) with \(\mathrm{vars}(C_i) = \mathrm{vars}(N)\) by smoothness, so the models of each \(\Delta_{C_i}\) are already models over \(\mathrm{vars}(N)\) and no term expansion is needed, and the models of \(\Delta_N\) over \(\mathrm{vars}(N)\) are their union — disjoint by determinism (\(\Delta_{C_i} \wedge \Delta_{C_j}\) inconsistent for \(i \neq j\), which is also what keeps \(h_N\) an MLF rather than giving a twice-counted model coefficient \(2\)). So the term sums add, \(h_N = \sum_i h_{C_i}\), and extraction made \(N\) an addition node, giving \(g_N = \sum_i g_{C_i} = h_N\).
At the root, \(g_{\text{root}} = h_{\text{root}} = f\).
Prove Lemma 12.1 on Page 310, which states:
Lemma 12.1 (Path coefficients). Consider a maximizer circuit \(AC^m\) evaluated at some evidence \(e\) and let \(\alpha\) be a path from the circuit root to some leaf node \(n\). Define the coefficient \(r\) of path \(\alpha\) as the product of values attained by nodes \(c\), where \(c\) is not on path \(\alpha\) but has a multiplication parent on \(\alpha\). Then \(r \cdot k\) is the maximum value attained by any complete subcircuit that includes path \(\alpha\), where \(k\) is the value of leaf node \(n\).
Here the value of a node is the one computed by the bottom-up evaluation pass of Algorithm 36 at evidence \(e\) (a maximization node takes the maximum of its children’s values, a multiplication node takes their product, a leaf takes its input value), and a complete subcircuit is as in Definition 12.5: start at the root, include all children of every visited multiplication node and exactly one child of every visited maximization node; its value is the product of the values of its leaves.
Induct on the length \(m\) of \(\alpha\), all values being nonnegative — leaves are indicators in \(\{0,1\}\) or parameters in \([0,1]\), and max and product preserve nonnegativity — which is what licenses maximizing a product factor by factor. Read paths and complete subcircuits in the tree unwinding of the DAG, write \(\mathrm{val}(S)\) for the product of \(S\)’s leaf values with traversal multiplicity, and note that the nodes off \(\alpha = v_0 \to \cdots \to v_m\) with a multiplication parent on \(\alpha\) are exactly the siblings along \(\alpha\).
(a) \(\mathrm{vr}(v) = \max\{\mathrm{val}(S) : S \text{ rooted at } v\}\) for every \(v\), by bottom-up induction: at a leaf the only such \(S\) is \(v\); at a maximization node the subcircuits are \(v\) plus one rooted at a single child, of maximum \(\max_t \mathrm{vr}(c_t) = \mathrm{vr}(v)\); at a multiplication node with children \(c_1,\dots,c_j\) the choices at the children are independent and \(\mathrm{val}(S) = \prod_t \mathrm{val}(S_t)\), so by nonnegativity (\(\max_{a \in A, b \in B} ab = (\max A)(\max B)\))
\begin{equation*} \max_S \mathrm{val}(S) = \prod_{t=1}^{j} \max_{S_t} \mathrm{val}(S_t) = \prod_{t=1}^{j} \mathrm{vr}(c_t) = \mathrm{vr}(v). \end{equation*}
(b) The lemma is the case \(v = \) root of: for every node \(v\) and path \(\alpha\) from \(v\) to a leaf \(n\), with \(r\) the coefficient of \(\alpha\) and \(k = \mathrm{vr}(n)\),
\begin{equation*} \max\{\, \mathrm{val}(S) : S \text{ rooted at } v,\; S \supseteq \alpha \,\} \;=\; r \cdot k . \end{equation*}
For \(m = 0\) the only \(S\) is the leaf \(n\), of value \(k\), and \(r\) is the empty product \(1\). For \(m > 0\) split \(\alpha = v_0 \to \alpha^{\prime}\) with \(\alpha^{\prime}\) running from the child \(v_1\) to \(n\) and \(r^{\prime}\) its coefficient, so by the hypothesis the best \(S^{\prime}\) rooted at \(v_1\) with \(S^{\prime} \supseteq \alpha^{\prime}\) has value \(r^{\prime}k\).
- (i) \(v_0\) a maximization node: \(S \supseteq \alpha\) is \(v_0\) plus such an \(S^{\prime}\), with \(\mathrm{val}(S) = \mathrm{val}(S^{\prime})\), and \(v_0\) contributes no siblings, so \(r = r^{\prime}\) and the maximum is \(rk\).
- (ii) \(v_0\) a multiplication node with children \(v_1, c_2,\dots,c_j\): \(S\) is \(v_0\) plus an independent subcircuit at each child, constrained only by \(S_1 \supseteq \alpha^{\prime}\), so maximizing factor by factor via the hypothesis and (a),
\begin{equation*} \max_{S \supseteq \alpha} \mathrm{val}(S) \;=\; (r^{\prime} k)\prod_{t=2}^{j}\mathrm{vr}(c_t) \;=\; rk, \end{equation*}
the siblings along \(\alpha\) being \(c_2,\dots,c_j\) together with those along \(\alpha^{\prime}\).
Consider the network polynomial \(f\) for a Bayesian network and let \(S = \{\theta_{x_1|u_1}, \dots, \theta_{x_k|u_k}\}\) be a set of parameters with equal values in the same CPT; that is, all of them belong to the CPT \(\Theta_{X|U}\) of a single variable \(X\) with parents \(U\), and they share a common numeric value. Replace all these parameters in the polynomial \(f\) with a new variable \(\eta\). What is the probabilistic meaning of \(\partial f/\partial \eta(e)\) for a given evidence \(e\)?
Writing \(\alpha\) for the event \(\bigvee_{i=1}^{k}(X = x_i \wedge U = u_i)\),
\begin{equation*} \eta \, \frac{\partial f}{\partial \eta}(e) \;=\; \mathrm{Pr}(\alpha, e), \qquad\text{i.e.}\qquad \frac{\partial f}{\partial \eta}(e) \;=\; \frac{\mathrm{Pr}(\alpha, e)}{\eta} \ \ (\eta \neq 0): \end{equation*}
the probability that \(e\) holds and the family \(XU\) takes one of the tied instantiations, divided by the shared value — the generalization of (12.4), which is the case \(k = 1\).
By Definition 12.1 each term of \(f\) carries exactly one parameter of \(\Theta_{X|U}\), namely \(\theta_{x|u}\) for the restriction \(xu\) of its complete instantiation; hence no term contains two members of \(S\), the substitution creates no \(\eta^2\), and \(f\) stays multi-linear in \(\eta\). Grouping the terms by which member of \(S\) they carry,
\begin{equation*} f \;=\; \sum_{i=1}^{k} \theta_{x_i|u_i}\, g_i \;+\; h, \qquad g_i \;=\; \frac{\partial f}{\partial \theta_{x_i|u_i}}, \end{equation*}
where \(h\) collects the terms carrying no member of \(S\). No \(g_i\) contains a parameter of \(\Theta_{X|U}\) and no term of \(h\) a member of \(S\), so the substitution leaves \(g_1,\dots,g_k\) and \(h\) untouched, turns \(f\) into \(\eta\sum_i g_i + h\), and gives the unconditional identity \(\partial f/\partial \eta = \sum_i \partial f/\partial \theta_{x_i|u_i}\); multiplying by the common value \(\eta = \theta_{x_i|u_i}\) and applying (12.4) of Theorem 12.2,
\begin{equation*} \eta \, \frac{\partial f}{\partial \eta}(e) \;=\; \sum_{i=1}^{k} \theta_{x_i|u_i}\,\frac{\partial f}{\partial \theta_{x_i|u_i}}(e) \;=\; \sum_{i=1}^{k} \mathrm{Pr}(x_i, u_i, e) \;=\; \mathrm{Pr}(\alpha, e), \end{equation*}
the last step because \(x_1u_1,\dots,x_ku_k\) are distinct instantiations of the same variables \(XU\), hence mutually exclusive.
Let \(f\) be an MLF and let \(f_m\) be another MLF obtained by including only the minimal terms of \(f\). Here a term of \(f\) is minimal if the number of variables it contains is minimal among the terms of \(f\). Suppose now that \(\Delta_f\) is a CNF that encodes MLF \(f\). Describe a procedure for obtaining an arithmetic circuit for MLF \(f_m\). Hint: Consider Exercise 2.13.
For reference, Exercise 2.13 reads: Let \(\Gamma\) be an NNF circuit that satisfies decomposability, determinism, and smoothness. Consider the following procedure for generating a subcircuit \(\Gamma_m\) of circuit \(\Gamma\). Assign an integer to each node of \(\Gamma\) as follows: an input node is assigned \(0\) if labelled with true or a positive literal, \(\infty\) if labelled with false, and \(1\) if labelled with a negative literal; an or-node is assigned the minimum of the integers assigned to its children, and an and-node the sum of the integers assigned to its children. Obtain \(\Gamma_m\) from \(\Gamma\) by deleting every edge that extends from an or-node \(N\) to a child \(C\) where \(N\) and \(C\) have different integers assigned to them. Then the models of \(\Gamma_m\) are the minimum-cardinality models of \(\Gamma\), where the cardinality of a model is the number of variables it sets to false.
Run Exercise 2.13 with the weights reversed — counting variables set to true, since under the encoding of Section 12.4.3 a term contains \(X\) exactly when the model sets \(V_X\) true, so term length is the true-count — and extract:
- Compile \(\Delta_f\) into an equivalent NNF circuit \(\Gamma_f\) satisfying decomposability, determinism, and smoothness (step 2 of Section 12.4.3, smoothed by Exercise 2.11 so that the root mentions every variable of \(\Delta_f\)).
- Label bottom-up with \(i(\cdot)\): positive literal \(1\), negative literal \(0\), true \(0\), false \(\infty\); an or-node the minimum of its children, an and-node the sum.
- Delete every or-edge \(N \to C\) with \(i( C) \neq i(N)\), discard what is now unreachable from the root, and call the survivor \(\Gamma_m\).
- Extract the arithmetic circuit from \(\Gamma_m\) as in Section 12.4.3: and-node to multiplication, or-node to addition, \(\neg V_X\) to the constant \(1\), \(V_X\) to \(X\).
Steps 2–4 are three linear sweeps on a circuit no larger than \(\Gamma_f\), so all the cost is in step 1. Correctness is three claims.
(i) For every node \(N\),
\begin{equation*} i(N) \;=\; \min_{\substack{\omega \models \Delta_N \\ \omega \text{ over } \mathrm{vars}(N)}} \bigl|\{X \in \mathrm{vars}(N) : \omega(V_X) = \mathrm{true}\}\bigr|, \end{equation*}
with \(\min \emptyset = \infty\): the length of the shortest term of the MLF encoded at \(N\). This is the structural induction of Exercise 12.17 with \(\min\) for \(\sum\) — at an and-node decomposability makes the models a product over disjoint variable sets, so true-counts add and the minimum of the sum is the sum of the minima; at an or-node smoothness makes the children’s models be models over the same \(\mathrm{vars}(N)\), so the model sets union and the minima take a minimum.
(ii) The models of \(\Gamma_m\) are exactly the minimum-true-count models of \(\Gamma_f\), i.e. those encoding the minimal terms of \(f\). Each model \(\omega\) has a unique certificate \(T_\omega\) — descend from the root taking all children of an and-node and, by determinism, the unique child satisfied by \(\omega\) at an or-node — carrying by decomposability and smoothness exactly one literal leaf per variable, namely \(\omega\)’s own, so \(\omega\)’s true-count is \(w(T_\omega) = \sum_{\ell} i(\ell)\). An induction gives \(w(T) \ge i(v)\) for every complete subcircuit \(T\) rooted at \(v\), tight iff \(T\) picks a child with \(i( C) = i(N)\) at every or-node: at an and-node \(w(T) = \sum_c w(T_c) \ge \sum_c i( c) = i(v)\), tight iff each part is; at an or-node with chosen child \(c\), \(w(T) = w(T_c) \ge i( c) \ge i(v)\), tight iff both inequalities are. Step 3 deletes exactly the non-tight or-edges, so \(T_\omega\) survives iff \(w(T_\omega) = i(\text{root})\); and as \(\Gamma_m\) only drops disjuncts, its models are those of \(\Gamma_f\) whose certificate survives. (If \(i(\text{root}) = \infty\) then \(\Delta_f\) is unsatisfiable and the construction returns the empty circuit.)
(iii) \(\Gamma_m\) inherits the three properties: no and-edge is deleted and at least one child of every or-node survives (the minimum is attained), so \(\mathrm{vars}\) is unchanged at every surviving node, whence decomposability and smoothness; determinism holds because each surviving child’s models are a subset of the original child’s.
So \(\Gamma_m\) encodes \(f_m\), and by Exercise 12.17 the circuit extracted at step 4 represents it.
Inference with Local Structure
Exercises 13.1–13.7
Consider the Bayesian network of Figure 13.2: it has root nodes \(X_1,\ldots,X_n\) and a single leaf \(Y\) with edges \(X_i \to Y\) for \(i=1,\ldots,n\), so \(Y\) has all of \(X_1,\ldots,X_n\) as parents and the network has treewidth \(n\). All variables take values in \(\{0,1\}\), each \(X_i\) has a uniform distribution (\(\theta_{x_i=0}=\theta_{x_i=1}=1/2\)), and \(Y\) is the logical-or of its parents, so \(\theta_{y|x_1,\ldots,x_n}=1\) precisely when either \(y=1\) and \(x_i=1\) for some \(i\), or \(y=0\) and \(x_i=0\) for all \(i\). Under these assumptions the network polynomial factors as in Equation 13.1:
\begin{equation*} f = \left(\tfrac12\right)^{n}\left( \lambda_{y=0}\prod_{i=1}^{n}\lambda_{x_i=0} \;+\; \lambda_{y=1}\sum_{i=1}^{n} \left(\prod_{j=1}^{i-1}\lambda_{x_j=0}\right)\lambda_{x_i=1} \left(\prod_{j=i+1}^{n}(\lambda_{x_j=0}+\lambda_{x_j=1})\right) \right). \end{equation*}
Provide an arithmetic circuit of size \(O(n)\) for this polynomial.
Share one prefix chain and one suffix chain across the \(n\) terms of the inner sum, which a DAG does for free where computing each term’s \(\prod_{j<i}\lambda_{x_j=0}\) and \(\prod_{j>i}(\lambda_{x_j=0}+\lambda_{x_j=1})\) separately would cost \(\Theta(n^2)\) nodes. Take as leaves the \(2n+2\) indicators and one constant \((1/2)^n\) (parameters substituted by value as in Figure 13.1(b), so the circuit is valid only at these values), and with \(+\) and \(\star\) the two node types of Definition 12.2 (a ternary node abbreviating two binary ones) set
\begin{equation*} \begin{aligned} A_i &= +(\lambda_{x_i=0},\lambda_{x_i=1}), & i&=1,\ldots,n, \\ P_0 &= 1,\quad P_i = \star(P_{i-1},\lambda_{x_i=0}), & i&=1,\ldots,n, \\ S_{n+1} &= 1,\quad S_i = \star(A_i,S_{i+1}), & i&=n,\ldots,2, \\ T_i &= \star(P_{i-1},\lambda_{x_i=1},S_{i+1}), & i&=1,\ldots,n, \\ \Sigma &= +(T_1,+(T_2,\ldots)), \\ f &= \star\Bigl(\left(\tfrac12\right)^{n},\; +\bigl(\star(\lambda_{y=0},P_n),\,\star(\lambda_{y=1},\Sigma)\bigr)\Bigr). \end{aligned} \end{equation*}
Then \(P_i=\prod_{j\le i}\lambda_{x_j=0}\) and \(S_i=\prod_{j\ge i}A_j\), so \(T_i\) is exactly the \(i\)-th summand of Equation 13.1, \(\Sigma\) the inner sum, and the root \(f\). Counting, with \(P_0, P_1, S_{n+1}, S_n\) costing no node and \(T_1, T_n\) one each,
\begin{equation*} \begin{aligned} \text{leaves} &: 2n+3,\\ \text{addition} &: n \;(\text{the }A_i) + (n-1) \;(\Sigma) + 1 \;=\; 2n,\\ \text{multiplication} &: (n-1) + (n-2) + (2n-2) + 3 \;=\; 4n-2 , \end{aligned} \end{equation*}
so at most \(8n+1\) nodes and, every internal node being binary, \(O(n)\) edges.
Consider Exercise 13.1, that is, the network of Figure 13.2 with root nodes \(X_1,\ldots,X_n\), leaf \(Y\), edges \(X_i \to Y\), uniform priors on the \(X_i\), and \(Y\) the logical-or of its parents, whose polynomial is given by Equation 13.1:
\begin{equation*} f = \left(\tfrac12\right)^{n}\left( \lambda_{y=0}\prod_{i=1}^{n}\lambda_{x_i=0} \;+\; \lambda_{y=1}\sum_{i=1}^{n} \left(\prod_{j=1}^{i-1}\lambda_{x_j=0}\right)\lambda_{x_i=1} \left(\prod_{j=i+1}^{n}(\lambda_{x_j=0}+\lambda_{x_j=1})\right) \right). \end{equation*}
Show that a smaller circuit can be constructed for this polynomial assuming that the circuit can contain subtraction nodes.
With \(A_i=\lambda_{x_i=0}+\lambda_{x_i=1}\) and \(T_i\) the \(i\)-th summand of the inner sum, the whole sum collapses to a difference of two products,
\begin{equation*} \sum_{i=1}^{n} T_i \;=\; \prod_{i=1}^{n}A_i \;-\; \prod_{i=1}^{n}\lambda_{x_i=0} , \end{equation*}
which is the identity a subtraction node buys. Indeed, put
\begin{equation*} Q_k \;=\; \left(\prod_{j\le k}\lambda_{x_j=0}\right)\left(\prod_{j>k}A_j\right), \qquad k=0,1,\ldots,n, \end{equation*}
so that \(Q_0=\prod_{i}A_i\) and \(Q_n=\prod_i \lambda_{x_i=0}\). For each \(i\),
\begin{equation*} \begin{aligned} Q_{i-1}-Q_i &= \left(\prod_{j<i}\lambda_{x_j=0}\right)\bigl(A_i-\lambda_{x_i=0}\bigr) \left(\prod_{j>i}A_j\right)\\ &= \left(\prod_{j<i}\lambda_{x_j=0}\right)\lambda_{x_i=1} \left(\prod_{j>i}A_j\right)\;=\;T_i , \end{aligned} \end{equation*}
because \(A_i-\lambda_{x_i=0}=\lambda_{x_i=1}\), so summing over \(i\) telescopes to \(\sum_i T_i = Q_0-Q_n\). Substituting into Equation 13.1,
\begin{equation*} f \;=\; \left(\tfrac12\right)^{n}\left( \lambda_{y=0}\,\Pi_0 \;+\;\lambda_{y=1}\bigl(\Pi_A-\Pi_0\bigr)\right), \qquad \Pi_0=\prod_{i=1}^n\lambda_{x_i=0},\quad \Pi_A=\prod_{i=1}^n A_i , \end{equation*}
realized by \(n\) addition nodes \(A_i=+(\lambda_{x_i=0},\lambda_{x_i=1})\), two chains of \(n-1\) multiplication nodes for \(\Pi_A\) and \(\Pi_0\), one subtraction node \(\Delta=-(\Pi_A,\Pi_0)\), the two products \(\star(\lambda_{y=0},\Pi_0)\), \(\star(\lambda_{y=1},\Delta)\), one addition node combining them, and one multiplication by \((1/2)^n\): in all \(2n+3\) leaves, \(n+1\) addition, \(2n+1\) multiplication and \(1\) subtraction node, so \(5n+6\) against the \(8n+1\) of Exercise 13.1 — subtraction expressing “at least one \(X_i\) is \(1\)” by complementation where a monotone circuit must enumerate the \(n\) exclusive choices of the first parent that is \(1\).
Consider a Bayesian network consisting of binary nodes \(X_1,\ldots,X_n,Y\) and edges \(X_i \to Y\) for \(i=1,\ldots,n\) (the structure of Figure 13.2, with all \(X_i\) roots and \(Y\) their common child). Assume that \(Y\) is true with probability \(\epsilon_1\) given that any of its parents are true, and that it is false with probability \(\epsilon_0\) given that all its parents are false; that is, \(Y\) is a soft-or of its parents. Provide an arithmetic circuit for this network of size \(O(n)\) while making no assumptions about the distributions over nodes \(X_i\).
The soft-or CPT takes only four distinct values however large \(n\) is, and that parameter equality is the local structure the circuit exploits: \(\theta_{y|\mathbf{x}}\) is \(\epsilon_0, 1-\epsilon_0\) for \(y=0,1\) when every \(x_i=0\), and \(1-\epsilon_1, \epsilon_1\) for \(y=0,1\) when some \(x_i=1\). Writing the values of \(X_i\) as \(0,1\), with arbitrary priors \(\theta_{x_i=0},\theta_{x_i=1}\), abbreviate
\begin{equation*} \alpha_i=\lambda_{x_i=0}\,\theta_{x_i=0},\qquad \beta_i=\lambda_{x_i=1}\,\theta_{x_i=1},\qquad \sigma_i=\alpha_i+\beta_i . \end{equation*}
Split \(f = \sum_{\mathbf{x},y}\lambda_y\,\theta_{y|\mathbf{x}}\prod_i\lambda_{x_i}\theta_{x_i}\) according to whether \(\mathbf{x}\) is all-false — on which block the inner product is \(\prod_i\alpha_i\), while over all \(\mathbf{x}\) the inner products sum to \(\prod_i\sigma_i\), since \(\sum_{x_i}\lambda_{x_i}\theta_{x_i}=\sigma_i\) and the sum factors — and apply the telescoping identity of Exercise 13.2 (with \(\alpha_j,\beta_j,\sigma_j\) for \(\lambda_{x_j=0},\lambda_{x_j=1},A_j\); the proof there uses only \(\sigma_i-\alpha_i=\beta_i\)):
\begin{equation*} \sum_{\substack{\mathbf{x}\\ x_i=1\ \text{for some}\ i}}\ \prod_{i=1}^{n} \lambda_{x_i}\theta_{x_i} \;=\;\prod_{i=1}^{n}\sigma_i-\prod_{i=1}^{n}\alpha_i \;=\;\sum_{i=1}^{n}\left(\prod_{j<i}\alpha_j\right)\beta_i\left(\prod_{j>i}\sigma_j\right). \end{equation*}
Since \(\theta_{y|\mathbf{x}}\) is constant on each block, this gives the factorization
\begin{equation*} \begin{aligned} f \;=\;& \bigl(\epsilon_0\lambda_{y=0}+(1-\epsilon_0)\lambda_{y=1}\bigr) \prod_{i=1}^{n}\alpha_i\\ &+\bigl((1-\epsilon_1)\lambda_{y=0}+\epsilon_1\lambda_{y=1}\bigr) \sum_{i=1}^{n}\left(\prod_{j<i}\alpha_j\right)\beta_i\left(\prod_{j>i}\sigma_j\right), \end{aligned} \end{equation*}
realized term by term with leaves the \(2n+2\) indicators, the \(2n\) constants \(\theta_{x_i}\) and \(\epsilon_0,1-\epsilon_0,\epsilon_1,1-\epsilon_1\) (parameters substituted by value as in Figure 13.1(b)), and, exactly as in Exercise 13.1:
- \(\alpha_i=\star(\lambda_{x_i=0},\theta_{x_i=0})\), \(\beta_i=\star(\lambda_{x_i=1},\theta_{x_i=1})\): \(2n\) multiplication nodes; \(\sigma_i=+(\alpha_i,\beta_i)\): \(n\) addition nodes;
- the prefix chain \(P_i=\star(P_{i-1},\alpha_i)=\prod_{j\le i}\alpha_j\) with \(P_0=1\): \(n-1\) multiplication nodes; the suffix chain \(S_i=\star(\sigma_i,S_{i+1})=\prod_{j\ge i}\sigma_j\) with \(S_{n+1}=1\): \(n-2\) multiplication nodes;
- the term nodes \(T_i=\star(P_{i-1},\beta_i,S_{i+1})\): at most \(2n-2\) multiplication nodes; the accumulation \(\Sigma=+(T_1,+(T_2,\ldots))\): \(n-1\) addition nodes;
- the two \(Y\)-mixtures \(M_0=+(\star(\epsilon_0,\lambda_{y=0}), \star(1-\epsilon_0,\lambda_{y=1}))\) and \(M_1=+(\star(1-\epsilon_1,\lambda_{y=0}), \star(\epsilon_1,\lambda_{y=1}))\): \(4\) multiplication and \(2\) addition nodes;
- the root \(f=+(\star(M_0,P_n),\star(M_1,\Sigma))\): \(2\) multiplication and \(1\) addition node.
The total is at most \(6n+1\) multiplication nodes, \(2n+2\) addition nodes and \(4n+6\) leaves, hence \(O(n)\) nodes and, all internal nodes being binary, \(O(n)\) edges; the priors are unconstrained, entering only as the leaf constants inside \(\alpha_i\) and \(\beta_i\).
Consider a Bayesian network consisting of binary nodes \(X_1,\ldots,X_n,Y\) and edges \(X_i \to Y\) for \(i=1,\ldots,n\) (the structure of Figure 13.2: \(n\) roots \(X_i\) and their common child \(Y\), whose treewidth is \(n\)). Assume that \(Y\) is true if and only if an odd number of its parents \(X_i\) are true, i.e. \(Y\) is the parity (exclusive-or) of its parents. Provide an arithmetic circuit for this network of size \(O(n)\) while making no assumptions about the distributions over nodes \(X_i\).
Parity admits no context-specific independence at all, yet the polynomial still has a linear circuit, because the parity of a prefix of the parents is a two-valued summary of that prefix and so obeys a two-line recurrence. With the values of \(X_i\) written \(0,1\), arbitrary priors \(\theta_{x_i=0},\theta_{x_i=1}\), and
\begin{equation*} \alpha_i=\lambda_{x_i=0}\,\theta_{x_i=0},\qquad \beta_i=\lambda_{x_i=1}\,\theta_{x_i=1}, \end{equation*}
the deterministic CPT of \(Y\) — \(\theta_{y=1|\mathbf{x}}=1, \theta_{y=0|\mathbf{x}}=0\) when \(\bigoplus_i x_i=1\), the reverse when \(\bigoplus_i x_i=0\) — kills every term of \(f=\sum_{\mathbf{x},y}\lambda_y\theta_{y|\mathbf{x}}\prod_i\lambda_{x_i}\theta_{x_i}\) whose parent instantiation has the wrong parity, leaving \(f=\lambda_{y=0}E_n+\lambda_{y=1}O_n\) for the even- and odd-parity partial sums
\begin{equation*} E_k=\sum_{\substack{x_1,\ldots,x_k\\ \bigoplus_{i\le k}x_i=0}}\ \prod_{i\le k} \lambda_{x_i}\theta_{x_i}, \qquad O_k=\sum_{\substack{x_1,\ldots,x_k\\ \bigoplus_{i\le k}x_i=1}}\ \prod_{i\le k} \lambda_{x_i}\theta_{x_i}. \end{equation*}
Splitting on \(x_k\) — a prefix is even iff \(x_k=0\) with an even \((k-1)\)-prefix or \(x_k=1\) with an odd one — gives, the empty instantiation having even parity,
\begin{equation*} \begin{aligned} E_0 &= 1, & O_0 &= 0,\\ E_k &= E_{k-1}\alpha_k+O_{k-1}\beta_k, & O_k &= O_{k-1}\alpha_k+E_{k-1}\beta_k \end{aligned} \end{equation*}
for \(k=1,\ldots,n\). As in Figure 13.1(b) parameters are substituted by value, so the circuit takes the \(2n+2\) indicators and the \(2n\) constants \(\theta_{x_i}\) as leaves, then the \(2n\) products \(\alpha_k=\star(\lambda_{x_k=0},\theta_{x_k=0})\), \(\beta_k=\star(\lambda_{x_k=1},\theta_{x_k=1})\), then per stage \(k\) the four products \(\star(E_{k-1},\alpha_k)\), \(\star(O_{k-1},\beta_k)\), \(\star(O_{k-1},\alpha_k)\), \(\star(E_{k-1},\beta_k)\) and two addition nodes for \(E_k, O_k\) — only \(n-1\) stages costing anything, stage \(1\) being degenerate with \(E_1=\alpha_1\), \(O_1=\beta_1\) — and the root \(f=+(\star(\lambda_{y=0},E_n),\star(\lambda_{y=1},O_n))\). In all \(2n+4(n-1)+2=6n-2\) multiplication nodes, \(2(n-1)+1=2n-1\) addition nodes and \(4n+2\) leaves, all internal nodes binary, so the size of Definition 12.2 is \(O(n)\); nothing was assumed about the priors, which enter only as leaf constants.
Figure 13.20 depicts a Bayesian network with three nodes \(A\), \(B\), \(C\) and edges \(A \to C\) and \(B \to C\) (so \(A\) and \(B\) are roots and \(C\) has parents \(A,B\)). Variables \(A\) and \(B\) are binary with values \(a_1,a_2\) and \(b_1,b_2\); variable \(C\) has three values \(c_1,c_2,c_3\). The CPT \(\Theta_{C|AB}\) is
| row | A | B | C | \(\theta_{C\mid AB}\) |
|---|---|---|---|---|
| 1 | \(a_1\) | \(b_1\) | \(c_1\) | 0 |
| 2 | \(a_1\) | \(b_1\) | \(c_2\) | .5 |
| 3 | \(a_1\) | \(b_1\) | \(c_3\) | .5 |
| 4 | \(a_1\) | \(b_2\) | \(c_1\) | .2 |
| 5 | \(a_1\) | \(b_2\) | \(c_2\) | .3 |
| 6 | \(a_1\) | \(b_2\) | \(c_3\) | .5 |
| 7 | \(a_2\) | \(b_1\) | \(c_1\) | 0 |
| 8 | \(a_2\) | \(b_1\) | \(c_2\) | 0 |
| 9 | \(a_2\) | \(b_1\) | \(c_3\) | 1 |
| 10 | \(a_2\) | \(b_2\) | \(c_1\) | .2 |
| 11 | \(a_2\) | \(b_2\) | \(c_2\) | .3 |
| 12 | \(a_2\) | \(b_2\) | \(c_3\) | .5 |
Construct two CNF encodings for this CPT, one that ignores local structure (Section 13.3.1) and another that accounts for local structure (Section 13.3.2).
Write \(I_x\) for the indicator variable of value \(x\) and \(P_{x|\mathbf{u}}\) for the parameter variable of \(\theta_{x|\mathbf{u}}\), with weights \(1\) on \(I_x, \neg I_x, \neg P_{x|\mathbf{u}}\) and \(\theta_{x|\mathbf{u}}\) on \(P_{x|\mathbf{u}}\), so that weighted model counting gives probabilities of evidence (Section 11.6.1).
(1) Structure-based encoding (Section 13.3.1). Indicator clauses, the exactly-one constraint on \(C\) taking one positive clause and three pairwise exclusions:
\begin{equation*} \begin{aligned} & I_{a_1}\vee I_{a_2}, && \neg I_{a_1}\vee\neg I_{a_2},\\ & I_{b_1}\vee I_{b_2}, && \neg I_{b_1}\vee\neg I_{b_2},\\ & I_{c_1}\vee I_{c_2}\vee I_{c_3}, && \neg I_{c_1}\vee\neg I_{c_2},\quad \neg I_{c_1}\vee\neg I_{c_3},\quad \neg I_{c_2}\vee\neg I_{c_3}. \end{aligned} \end{equation*}
Parameter clauses: one sentence per CPT row, twelve in all,
\begin{equation*} I_{a_i}\wedge I_{b_j}\wedge I_{c_k}\iff P_{c_k|a_i b_j}, \qquad i,j\in\{1,2\},\ k\in\{1,2,3\}, \end{equation*}
each of which unfolds (as in footnote 2 of Section 13.3.1) into one IP clause
\begin{equation*} \neg I_{a_i}\vee\neg I_{b_j}\vee\neg I_{c_k}\vee P_{c_k|a_ib_j} \end{equation*}
and three PI clauses
\begin{equation*} \neg P_{c_k|a_ib_j}\vee I_{a_i},\qquad \neg P_{c_k|a_ib_j}\vee I_{b_j},\qquad \neg P_{c_k|a_ib_j}\vee I_{c_k}. \end{equation*}
In all \(7\) indicator and \(12\) parameter variables and \(8+12+36=56\) clauses, the numbers entering only as literal weights.
(2) Encoding with local structure (Section 13.3.2). Three refinements in turn.
Zero parameters. Rows \(1,7,8\) are zero; each drops its parameter variable and its clauses in favour of the single clause \(\neg I_{u_1}\vee\ldots\vee\neg I_{u_n}\vee\neg I_x\):
\begin{equation*} \neg I_{a_1}\vee\neg I_{b_1}\vee\neg I_{c_1},\qquad \neg I_{a_2}\vee\neg I_{b_1}\vee\neg I_{c_1},\qquad \neg I_{a_2}\vee\neg I_{b_1}\vee\neg I_{c_2}. \end{equation*}
Resolving the first two against \(I_{a_1}\vee I_{a_2}\) replaces them by the equivalent shorter \(\neg I_{b_1}\vee\neg I_{c_1}\).
One parameters. Row \(9\) has \(\theta_{c_3|a_2b_1}=1\), so its positive literal has weight \(1\) and can neither reweight nor exclude a model: \(P_{c_3|a_2b_1}\) and its four clauses are dropped, losing nothing logically either, since given \(a_2,b_1\) the zero clauses force \(\neg I_{c_1},\neg I_{c_2}\) and then \(I_{c_1}\vee I_{c_2}\vee I_{c_3}\) forces \(I_{c_3}\).
Equal parameters. The eight remaining rows take three distinct values, so introduce one variable per group:
- \(\eta_1\), weight \(.5\), for rows \(2,3,6,12\);
- \(\eta_2\), weight \(.2\), for rows \(4,10\);
- \(\eta_3\), weight \(.3\), for rows \(5,11\).
The defining sentences are \((I_{f_1}\vee\ldots\vee I_{f_m})\iff\eta\), which here read
\begin{equation*} \begin{aligned} (I_{a_1}\!\wedge\! I_{b_1}\!\wedge\! I_{c_2})\vee (I_{a_1}\!\wedge\! I_{b_1}\!\wedge\! I_{c_3})\vee (I_{a_1}\!\wedge\! I_{b_2}\!\wedge\! I_{c_3})\vee (I_{a_2}\!\wedge\! I_{b_2}\!\wedge\! I_{c_3}) &\iff \eta_1,\\ (I_{a_1}\!\wedge\! I_{b_2}\!\wedge\! I_{c_1})\vee (I_{a_2}\!\wedge\! I_{b_2}\!\wedge\! I_{c_1}) &\iff \eta_2,\\ (I_{a_1}\!\wedge\! I_{b_2}\!\wedge\! I_{c_2})\vee (I_{a_2}\!\wedge\! I_{b_2}\!\wedge\! I_{c_2}) &\iff \eta_3. \end{aligned} \end{equation*}
The indicator clauses simplify these. In \(\eta_2,\eta_3\) the two disjuncts differ only in \(A\), and \(I_{a_1}\vee I_{a_2}\) is a clause, so
\begin{equation*} \eta_2\iff I_{b_2}\wedge I_{c_1},\qquad \eta_3\iff I_{b_2}\wedge I_{c_2}. \end{equation*}
In \(\eta_1\) the last two disjuncts collapse the same way to \(I_{b_2}\wedge I_{c_3}\), while the first two collapse to \(I_{a_1}\wedge I_{b_1}\wedge(I_{c_2}\vee I_{c_3})\), and \(I_{c_2}\vee I_{c_3}\) is equivalent to \(\neg I_{c_1}\) under the exactly-one constraint on \(C\). Hence
\begin{equation*} \eta_1\iff (I_{a_1}\wedge I_{b_1}\wedge\neg I_{c_1})\vee(I_{b_2}\wedge I_{c_3}). \end{equation*}
Converting to CNF (Section 2.7.3), for \(\eta_2,\eta_3\) immediately:
\begin{equation*} \begin{aligned} &\neg\eta_2\vee I_{b_2}, &&\neg\eta_2\vee I_{c_1}, &&\neg I_{b_2}\vee\neg I_{c_1}\vee\eta_2,\\ &\neg\eta_3\vee I_{b_2}, &&\neg\eta_3\vee I_{c_2}, &&\neg I_{b_2}\vee\neg I_{c_2}\vee\eta_3. \end{aligned} \end{equation*}
For \(\eta_1\), the direction “disjunct implies \(\eta_1\)” gives the two clauses
\begin{equation*} \neg I_{a_1}\vee\neg I_{b_1}\vee I_{c_1}\vee\eta_1,\qquad \neg I_{b_2}\vee\neg I_{c_3}\vee\eta_1, \end{equation*}
and the direction \(\eta_1\Rightarrow(u\vee v)\), with \(u=I_{a_1}\wedge I_{b_1}\wedge\neg I_{c_1}\) and \(v=I_{b_2}\wedge I_{c_3}\), is put in CNF by distributing the six literal pairs:
\begin{equation*} \begin{aligned} &\neg\eta_1\vee I_{a_1}\vee I_{b_2}, &&\neg\eta_1\vee I_{a_1}\vee I_{c_3},\\ &\neg\eta_1\vee I_{b_1}\vee I_{c_3}, &&\neg\eta_1\vee\neg I_{c_1}\vee I_{b_2},\\ &\neg\eta_1\vee\neg I_{c_1}\vee I_{c_3}. && \end{aligned} \end{equation*}
(The sixth product, \(\neg\eta_1\vee I_{b_1}\vee I_{b_2}\), is subsumed by the indicator clause \(I_{b_1}\vee I_{b_2}\) and is dropped.)
Putting it together, the local-structure encoding consists of the \(8\) indicator clauses, the determinism clauses \(\neg I_{b_1}\vee\neg I_{c_1}\) and \(\neg I_{a_2}\vee\neg I_{b_1}\vee\neg I_{c_2}\), and the \(13\) clauses above, using \(7\) indicator variables and only \(3\) parameter variables \(\eta_1,\eta_2,\eta_3\) of weights \(.5,.2,.3\): \(23\) clauses and \(10\) variables, against \(56\) clauses and \(19\) variables for the structure-based encoding.
Each instantiation \(a_ib_jc_k\) fixes the indicators, hence the \(\eta\)’s, hence at most one model, of weight the product of the weights of the \(\eta\)’s set true; walking the rows recovers the twelve CPT entries (Check!).
Consider again the Bayesian network of Figure 13.20: nodes \(A\), \(B\), \(C\) with edges \(A \to C\) and \(B \to C\), where \(A\) is binary with values \(a_1,a_2\), \(B\) is binary with values \(b_1,b_2\), and \(C\) has three values \(c_1,c_2,c_3\), with CPT
| row | A | B | C | \(\theta_{C\mid AB}\) |
|---|---|---|---|---|
| 1 | \(a_1\) | \(b_1\) | \(c_1\) | 0 |
| 2 | \(a_1\) | \(b_1\) | \(c_2\) | .5 |
| 3 | \(a_1\) | \(b_1\) | \(c_3\) | .5 |
| 4 | \(a_1\) | \(b_2\) | \(c_1\) | .2 |
| 5 | \(a_1\) | \(b_2\) | \(c_2\) | .3 |
| 6 | \(a_1\) | \(b_2\) | \(c_3\) | .5 |
| 7 | \(a_2\) | \(b_1\) | \(c_1\) | 0 |
| 8 | \(a_2\) | \(b_1\) | \(c_2\) | 0 |
| 9 | \(a_2\) | \(b_1\) | \(c_3\) | 1 |
| 10 | \(a_2\) | \(b_2\) | \(c_1\) | .2 |
| 11 | \(a_2\) | \(b_2\) | \(c_2\) | .3 |
| 12 | \(a_2\) | \(b_2\) | \(c_3\) | .5 |
Construct an arithmetic circuit for this network while assuming that the instantiation \(a_2,b_1\) is always part of the evidence (see Section 13.3.3). Assume that variables \(A\) and \(B\) have uniform CPTs, that is, \(\theta_{a_1}=\theta_{a_2}=\theta_{b_1}=\theta_{b_2}=.5\).
Building the evidence in collapses the circuit to the single multiplication node \(.25\,\lambda_{c_3}\). By the second option of Section 13.3.3 — encode in CNF, condition, simplify, compile to a decomposable, deterministic, smooth NNF circuit, extract by Section 12.4.3:
(1) CNF with local structure. The \(\Theta_{C|AB}\) clauses are those of Exercise 13.5; the two uniform root CPTs are equal parameters, so become \(P_A\) and \(P_B\) of weight \(.5\). In full:
- indicator clauses: \(I_{a_1}\vee I_{a_2}\), \(\neg I_{a_1}\vee\neg I_{a_2}\), \(I_{b_1}\vee I_{b_2}\), \(\neg I_{b_1}\vee\neg I_{b_2}\), \(I_{c_1}\vee I_{c_2}\vee I_{c_3}\) and the three pairwise exclusions on \(C\);
- determinism: \(\neg I_{b_1}\vee\neg I_{c_1}\) and \(\neg I_{a_2}\vee\neg I_{b_1}\vee\neg I_{c_2}\);
- \(\eta_1\iff(I_{a_1}\wedge I_{b_1}\wedge\neg I_{c_1})\vee(I_{b_2}\wedge I_{c_3})\), weight \(.5\);
- \(\eta_2\iff I_{b_2}\wedge I_{c_1}\), weight \(.2\);
- \(\eta_3\iff I_{b_2}\wedge I_{c_2}\), weight \(.3\);
- \(P_A\iff I_{a_1}\vee I_{a_2}\), weight \(.5\); \(P_B\iff I_{b_1}\vee I_{b_2}\), weight \(.5\).
(2) Condition. Replacing \(I_{a_2}, I_{b_1}\) by \(\top\), unit propagation forces \(\neg I_{a_1}\) and \(\neg I_{b_2}\) from the exclusion clauses, then \(\neg I_{c_1}\) and \(\neg I_{c_2}\) from the two determinism clauses, then \(I_{c_3}\) from \(I_{c_1}\vee I_{c_2}\vee I_{c_3}\), then \(\neg\eta_1,\neg\eta_2,\neg\eta_3\) (every disjunct needs \(I_{a_1}\) or \(I_{b_2}\)), and \(P_A, P_B\). Every variable is determined, so the conditioned CNF has the single model
\begin{equation*} \neg I_{a_1},\ \neg I_{b_2},\ \neg I_{c_1},\ \neg I_{c_2},\ I_{c_3},\ \neg\eta_1,\ \neg\eta_2,\ \neg\eta_3,\ P_A,\ P_B . \end{equation*}
(3) Compile and extract. A CNF with a single model is the conjunction of that model’s literals,
\begin{equation*} \Gamma=\neg I_{a_1}\wedge\neg I_{b_2}\wedge\neg I_{c_1}\wedge\neg I_{c_2}\wedge I_{c_3} \wedge\neg\eta_1\wedge\neg\eta_2\wedge\neg\eta_3\wedge P_A\wedge P_B , \end{equation*}
a single and-node over distinct variables — decomposable, deterministic for want of an or-node, and smooth. The substitutions \(\wedge\mapsto\star\), negative literal \(\mapsto 1\), \(I_x\mapsto\lambda_x\), \(P\mapsto\) its weight then give
\begin{equation*} \mathrm{AC}\;=\;\star(1,1,1,1,\lambda_{c_3},1,1,1,.5,.5) \;=\;\star(.5,\ .5,\ \lambda_{c_3}), \end{equation*}
that is, after folding the constants, one multiplication node with leaves \(.25\) and \(\lambda_{c_3}\), representing \(f^{a_2,b_1} = .25\,\lambda_{c_3}\) — which is what setting \(\lambda_{a_2}=\lambda_{b_1}=1\), \(\lambda_{a_1}=\lambda_{b_2}=0\) in \(f=\sum_{a,b,c}\lambda_a\lambda_b\lambda_c\,\theta_a\theta_b\theta_{c|ab}\) leaves directly, \(\theta_{a_2}\theta_{b_1}\lambda_{c_3}\cdot 1 = .25\,\lambda_{c_3}\). The price is that the \(A\)- and \(B\)-indicators no longer occur, so the circuit answers only queries with \(a_2,b_1\) in the evidence.
Figure 13.21 gives the conditional probability table \(\Theta_{D|A,B,C}\) of a binary variable \(D\) with binary parents \(A\), \(B\) and \(C\):
| A | B | C | D | \(\Pr(D\mid A,B,C)\) |
|---|---|---|---|---|
| true | true | true | true | .9 |
| true | true | true | false | .1 |
| true | true | false | true | .9 |
| true | true | false | false | .1 |
| true | false | true | true | .9 |
| true | false | true | false | .1 |
| true | false | false | true | .2 |
| true | false | false | false | .8 |
| false | true | true | true | .5 |
| false | true | true | false | .5 |
| false | true | false | true | .5 |
| false | true | false | false | .5 |
| false | false | true | true | 0 |
| false | false | true | false | 1 |
| false | false | false | true | 0 |
| false | false | false | false | 1 |
Encode this CPT as a CNF while ignoring local structure (Section 13.3.1). Show how the encoding would change if we account for determinism (Section 13.3.2). Show how this last encoding would change if we account for equal parameters (Section 13.3.2).
Write \(a,\bar a\) for the values of \(A\) and similarly for \(B,C,D\); indicator literals and negative parameter literals have weight \(1\), a positive parameter literal the weight of its parameter.
(1) Ignoring local structure. Indicator clauses, two per variable:
\begin{equation*} \begin{aligned} & I_a\vee I_{\bar a}, && \neg I_a\vee\neg I_{\bar a}, && I_b\vee I_{\bar b}, && \neg I_b\vee\neg I_{\bar b},\\ & I_c\vee I_{\bar c}, && \neg I_c\vee\neg I_{\bar c}, && I_d\vee I_{\bar d}, && \neg I_d\vee\neg I_{\bar d}. \end{aligned} \end{equation*}
Parameter clauses: one sentence per CPT row, sixteen in all,
\begin{equation*} I_{a^{\prime}}\wedge I_{b^{\prime}}\wedge I_{c^{\prime}}\wedge I_{d^{\prime}} \iff P_{d^{\prime}|a^{\prime}b^{\prime}c^{\prime}}, \end{equation*}
where \(a^{\prime}\) ranges over \(a,\bar a\) and so on. Each sentence unfolds into one IP clause
\begin{equation*} \neg I_{a^{\prime}}\vee\neg I_{b^{\prime}}\vee\neg I_{c^{\prime}}\vee\neg I_{d^{\prime}} \vee P_{d^{\prime}|a^{\prime}b^{\prime}c^{\prime}} \end{equation*}
and four PI clauses \(\neg P_{d^{\prime}|a^{\prime}b^{\prime}c^{\prime}}\vee I_{a^{\prime}}\), \(\neg P_{d^{\prime}|a^{\prime}b^{\prime}c^{\prime}}\vee I_{b^{\prime}}\), \(\neg P_{d^{\prime}|a^{\prime}b^{\prime}c^{\prime}}\vee I_{c^{\prime}}\), \(\neg P_{d^{\prime}|a^{\prime}b^{\prime}c^{\prime}}\vee I_{d^{\prime}}\). The weight of \(P_{d^{\prime}|a^{\prime}b^{\prime}c^{\prime}}\) is the number in the corresponding row.
In all \(8\) indicator and \(16\) parameter variables and \(8+16+64=88\) clauses, depending only on the structure — the numbers appear only as weights.
(2) Accounting for determinism. The zero parameters \(\theta_{d|\bar a\bar b c}\) and \(\theta_{d|\bar a\bar b\bar c}\) lose their variables and ten clauses in favour of
\begin{equation*} \neg I_{\bar a}\vee\neg I_{\bar b}\vee\neg I_{c}\vee\neg I_{d},\qquad \neg I_{\bar a}\vee\neg I_{\bar b}\vee\neg I_{\bar c}\vee\neg I_{d}. \end{equation*}
which resolve on \(C\) and, since \(I_c\vee I_{\bar c}\) is a clause, are jointly equivalent to the shorter \(\neg I_{\bar a}\vee\neg I_{\bar b}\vee\neg I_{d}\) — if \(A\) and \(B\) are both false then so is \(D\), whatever \(C\) is. The one parameters \(\theta_{\bar d|\bar a\bar bc}\) and \(\theta_{\bar d|\bar a\bar b\bar c}\) have their variables and ten clauses dropped outright, losing nothing, since given \(\bar a,\bar b\) that clause forces \(\neg I_d\) and then \(I_d\vee I_{\bar d}\) forces \(I_{\bar d}\). The encoding is now \(8\) indicator and \(12\) parameter variables with \(8+1+12\cdot 5=69\) clauses: four CPT rows replaced by one clause.
(3) Also accounting for equal parameters. The twelve surviving parameters take five distinct values:
| value | parent-and-value instantiations |
|---|---|
| .9 | \(abcd\), \(ab\bar cd\), \(a\bar bcd\) |
| .1 | \(abc\bar d\), \(ab\bar c\bar d\), \(a\bar bc\bar d\) |
| .2 | \(a\bar b\bar cd\) |
| .8 | \(a\bar b\bar c\bar d\) |
| .5 | \(\bar abcd\), \(\bar abc\bar d\), \(\bar ab\bar cd\), \(\bar ab\bar c\bar d\) |
so five variables \(\eta_{.9},\eta_{.1},\eta_{.2},\eta_{.8},\eta_{.5}\) of those weights replace the twelve \(P\) variables, with defining sentences \((I_{f_1}\vee\ldots\vee I_{f_m})\iff\eta\) that the indicator clauses simplify:
\begin{equation*} \begin{aligned} \eta_{.9} &\iff (I_a\wedge I_b\wedge I_c\wedge I_d)\vee(I_a\wedge I_b\wedge I_{\bar c}\wedge I_d)\vee(I_a\wedge I_{\bar b}\wedge I_c\wedge I_d)\\ &\iff I_a\wedge I_d\wedge\bigl(I_b\wedge(I_c\vee I_{\bar c})\ \vee\ I_{\bar b}\wedge I_c\bigr)\\ &\iff I_a\wedge I_d\wedge(I_b\vee I_c), \end{aligned} \end{equation*}
using \(I_c\vee I_{\bar c}\) and absorbing \(I_{\bar b}\wedge I_c\) into \(I_c\); identically,
\begin{equation*} \eta_{.1}\iff I_a\wedge I_{\bar d}\wedge(I_b\vee I_c). \end{equation*}
The \(.5\) group holds all four combinations of \(C,D\) under \(\bar a,b\), so
\begin{equation*} \eta_{.5}\iff I_{\bar a}\wedge I_b\wedge(I_c\vee I_{\bar c})\wedge(I_d\vee I_{\bar d}) \iff I_{\bar a}\wedge I_b . \end{equation*}
The two singleton groups keep their full conjunctions,
\begin{equation*} \eta_{.2}\iff I_a\wedge I_{\bar b}\wedge I_{\bar c}\wedge I_d,\qquad \eta_{.8}\iff I_a\wedge I_{\bar b}\wedge I_{\bar c}\wedge I_{\bar d}. \end{equation*}
In CNF (Section 2.7.3):
\begin{equation*} \begin{aligned} \eta_{.5}:\quad & \neg\eta_{.5}\vee I_{\bar a},\quad \neg\eta_{.5}\vee I_b,\quad \neg I_{\bar a}\vee\neg I_b\vee\eta_{.5};\\ \eta_{.2}:\quad & \neg\eta_{.2}\vee I_a,\ \ \neg\eta_{.2}\vee I_{\bar b},\ \ \neg\eta_{.2}\vee I_{\bar c},\ \ \neg\eta_{.2}\vee I_d,\\ & \neg I_a\vee\neg I_{\bar b}\vee\neg I_{\bar c}\vee\neg I_d\vee\eta_{.2};\\ \eta_{.8}:\quad & \text{the same four unit-implication clauses with } I_{\bar d} \text{ in place of } I_d,\\ & \neg I_a\vee\neg I_{\bar b}\vee\neg I_{\bar c}\vee\neg I_{\bar d}\vee\eta_{.8};\\ \eta_{.9}:\quad & \neg\eta_{.9}\vee I_a,\quad \neg\eta_{.9}\vee I_d,\quad \neg\eta_{.9}\vee I_b\vee I_c,\\ & \neg I_a\vee\neg I_d\vee\neg I_b\vee\eta_{.9},\quad \neg I_a\vee\neg I_d\vee\neg I_c\vee\eta_{.9};\\ \eta_{.1}:\quad & \text{the same five clauses with } I_{\bar d} \text{ in place of } I_d . \end{aligned} \end{equation*}
The final encoding is \(8\) indicator clauses, the determinism clause \(\neg I_{\bar a}\vee\neg I_{\bar b}\vee\neg I_d\) and \(3+5+5+5+5=23\) parameter clauses: \(32\) clauses over \(13\) variables, against \(88\) over \(24\) in (1) and \(69\) over \(20\) in (2).
At most one \(\eta\) is ever true — \(\eta_{.5}\) demands \(I_{\bar a}\) and the others \(I_a\); \(\eta_{.9},\eta_{.2}\) demand \(I_d\) and \(\eta_{.1},\eta_{.8}\) demand \(I_{\bar d}\); and within \(\{\eta_{.9},\eta_{.2}\}\) and \(\{\eta_{.1},\eta_{.8}\}\) the first demands \(I_b\vee I_c\) and the second \(I_{\bar b}\wedge I_{\bar c}\) — so each instantiation of \(A,B,C,D\) has model weight the weight of its unique true \(\eta\), or \(1\) if there is none, which walking the blocks reproduces row by row (Check!).
Exercises 13.8–13.14
Construct an ADD for the CPT in Figure 13.21 using the variable order \(A, B, C, D\).
Figure 13.21 is the conditional probability table \(\Pr(D \mid A,B,C)\) over binary variables:
| \(A\) | \(B\) | \(C\) | \(D\) | \(\Pr(D\mid A,B,C)\) |
|---|---|---|---|---|
| true | true | true | true | .9 |
| true | true | true | false | .1 |
| true | true | false | true | .9 |
| true | true | false | false | .1 |
| true | false | true | true | .9 |
| true | false | true | false | .1 |
| true | false | false | true | .2 |
| true | false | false | false | .8 |
| false | true | true | true | .5 |
| false | true | true | false | .5 |
| false | true | false | true | .5 |
| false | true | false | false | .5 |
| false | false | true | true | 0 |
| false | false | true | false | 1 |
| false | false | false | true | 0 |
| false | false | false | false | 1 |
Recall the ADD conventions of Section 13.5.1: every nonleaf node is labeled with a binary variable and has a high child (solid edge, taken when the variable is true) and a low child (dotted edge, taken when the variable is false); leaves (sinks) are labeled with real numbers; variables must occur in the fixed order along every root-to-leaf path; and the ADD is to be reduced, i.e. it contains no node whose high and low children are identical and no two distinct nodes with the same label and the same pair of children.
Read the table as a factor \(f(A,B,C,D)\) and group its rows by the context \(A,B,C\). Each context fixes a pair of numbers \((f \text{ at } D=\text{false},\ f \text{ at } D=\text{true})\):
| \(A\) | \(B\) | \(C\) | \((D=\text{false},\, D=\text{true})\) |
|---|---|---|---|
| true | true | true | \((.1,\ .9)\) |
| true | true | false | \((.1,\ .9)\) |
| true | false | true | \((.1,\ .9)\) |
| true | false | false | \((.8,\ .2)\) |
| false | true | true | \((.5,\ .5)\) |
| false | true | false | \((.5,\ .5)\) |
| false | false | true | \((1,\ 0)\) |
| false | false | false | \((1,\ 0)\) |
Four distinct pairs occur, \((.1,.9), (.8,.2), (.5,.5), (1,0)\), and \((.5,.5)\) has equal components so its node is redundant and collapses to the sink \(.5\). This leaves three \(D\)-nodes:
\begin{equation*} \delta_1 = (\text{low }.1,\ \text{high }.9), \quad \delta_2 = (\text{low }.8,\ \text{high }.2), \quad \delta_3 = (\text{low }1,\ \text{high }0). \end{equation*}
At the \(C\)-level the four contexts \(A,B\) give: (i) \(A,B\) true, both \(C\) values reach \(\delta_1\), so the node collapses to \(\delta_1\); (ii) \(A\) true, \(B\) false, the two values reach \(\delta_1\) and \(\delta_2\), so a genuine node \(\gamma = (\text{low }\delta_2, \text{high }\delta_1)\) survives; (iii) \(A\) false, \(B\) true, both reach the sink \(.5\); (iv) both false, both reach \(\delta_3\). One level up, the \(B\)-nodes are
\begin{equation*} \beta_1 = (\text{low } \gamma,\ \text{high } \delta_1), \qquad \beta_2 = (\text{low } \delta_3,\ \text{high } .5), \end{equation*}
both genuine and distinct, and the root is \(\alpha = (\text{low }\beta_2, \text{high }\beta_1)\). The reduced ADD, node by node (a dash marks a nonleaf in the value column, a sink in the child columns):
| node | label | low child (dotted) | high child (solid) | value |
|---|---|---|---|---|
| \(\alpha\) | \(A\) | \(\beta_2\) | \(\beta_1\) | – |
| \(\beta_1\) | \(B\) | \(\gamma\) | \(\delta_1\) | – |
| \(\beta_2\) | \(B\) | \(\delta_3\) | \(s_{.5}\) | – |
| \(\gamma\) | \(C\) | \(\delta_2\) | \(\delta_1\) | – |
| \(\delta_1\) | \(D\) | \(s_{.1}\) | \(s_{.9}\) | – |
| \(\delta_2\) | \(D\) | \(s_{.8}\) | \(s_{.2}\) | – |
| \(\delta_3\) | \(D\) | \(s_{1}\) | \(s_{0}\) | – |
| \(s_{.1}\) | – | – | – | \(.1\) |
| \(s_{.9}\) | – | – | – | \(.9\) |
| \(s_{.8}\) | – | – | – | \(.8\) |
| \(s_{.2}\) | – | – | – | \(.2\) |
| \(s_{.5}\) | – | – | – | \(.5\) |
| \(s_{1}\) | – | – | – | \(1\) |
| \(s_{0}\) | – | – | – | \(0\) |
Two edges skip a variable, \(\beta_1 \to \delta_1\) skipping \(C\) and \(\beta_2 \to s_{.5}\) skipping \(C\) and \(D\), legal since a path need not mention every variable of the order; they record the context-specific independences of \(D\) from \(C\) given \(A,B\) true and of \(D\) from \(B,C\) given \(A\) false, \(B\) true. The ADD has \(7\) nonleaf nodes and \(7\) sinks against the table’s \(16\) rows, and is reduced (Check!), hence by the canonicity of Section 13.5.1 the unique ADD for this factor under \(A,B,C,D\).
Consider a factor \(f\) over binary variables \(X_1, \ldots, X_n\), where \(f(x_1,\ldots,x_n) = 1\) if exactly one value in \(x_1,\ldots,x_n\) is true and \(f(x_1,\ldots,x_n) = 0\) otherwise. Construct an ADD representation of this factor with size \(O(n)\).
Under the order \(X_1 \prec \cdots \prec X_n\), what the remaining variables must do depends on the prefix only through a two-valued summary — the number of true values so far, capped at two — so two nodes per level suffice. For \(i \in \{1,\ldots,n+1\}\) and \(c \in \{0,1\}\) put
\begin{equation*} g_i^{c}(x_i,\ldots,x_n) \;=\; \begin{cases} 1, & \text{if exactly } 1-c \text{ of } x_i,\ldots,x_n \text{ are true},\\ 0, & \text{otherwise.} \end{cases} \end{equation*}
with \(c\) the number of true values among \(X_1,\ldots,X_{i-1}\); \(c \ge 2\) makes the residual identically \(0\), so only \(c \in \{0,1\}\) is needed, and \(f = g_1^{0}\). The Shannon expansions are
\begin{equation*} \begin{aligned} g_i^{0} &= \overline{X_i}\, g_{i+1}^{0} + X_i\, g_{i+1}^{1},\\ g_i^{1} &= \overline{X_i}\, g_{i+1}^{1} + X_i\, 0, \end{aligned} \end{equation*}
for \(1 \le i \le n\), with \(g_{n+1}^{0} = 0\) and \(g_{n+1}^{1} = 1\). Writing \(A_i, B_i\) for the nodes labelled \(X_i\) representing \(g_i^{0}, g_i^{1}\) and \(s_0, s_1\) for the sinks, each expansion becomes one node:
| node | label | low child (dotted, \(X_i=\) false) | high child (solid, \(X_i=\) true) |
|---|---|---|---|
| \(A_i\), \(1 \le i \le n-1\) | \(X_i\) | \(A_{i+1}\) | \(B_{i+1}\) |
| \(B_i\), \(2 \le i \le n-1\) | \(X_i\) | \(B_{i+1}\) | \(s_0\) |
| \(A_n\) | \(X_n\) | \(s_0\) | \(s_1\) |
| \(B_n\) | \(X_n\) | \(s_1\) | \(s_0\) |
with root \(A_1\); \(B_1\) is never created, since nothing precedes \(X_1\). A path runs down the \(A\)-chain while every variable seen is false, the first true variable moves it onto the \(B\)-chain, and any further true variable drops it to \(s_0\); so a path reaches \(s_1\) exactly when it takes precisely one solid edge, and the ADD represents \(f\).
The nodes are \(A_1,\ldots,A_n\), \(B_2,\ldots,B_n\) and the two sinks: \(2n+1\) nodes and \(4n-2\) edges, against the \(2^n\) rows of the table. It is reduced — no node has identical children (the only candidates, \(A_i\) with \(i \le n-1\), have the distinct \(A_{i+1}, B_{i+1}\)), and the same-label pair \(A_i, B_i\) always differs, since \(A_n = (s_0,s_1)\) against \(B_n = (s_1,s_0)\) while for \(i \le n-1\) the high child of \(A_i\) is a nonleaf and that of \(B_i\) the sink \(s_0\).
Reduce the ADD in Figure 13.22 (see also Figure 13.14).
Figure 13.22 is an unreduced ADD – in fact a complete decision tree – over the binary variables \(X, Y, Z\) in the order \(X, Y, Z\). Its root is labeled \(X\); both of the root’s children are labeled \(Y\); all four grandchildren are labeled \(Z\); and each of the four \(Z\)-nodes points to two sinks of its own, eight sinks in all. Reading the eight sinks left to right (a left/dotted edge means the variable is false, a right/solid edge means it is true), the tree is
| \(X\) | \(Y\) | \(Z\) | \(f\) |
|---|---|---|---|
| false | false | false | .1 |
| false | false | true | .9 |
| false | true | false | .1 |
| false | true | true | .9 |
| true | false | false | .9 |
| true | false | true | .1 |
| true | true | false | .5 |
| true | true | true | .5 |
Figure 13.14 illustrates the reduction procedure: an ADD node is redundant if its high and low children are the same node, in which case the node is deleted and its parents are redirected to that common child; or if some other node in the ADD carries the same label and the same high and low children, in which case the node is deleted and its parents are redirected to that duplicate. A reduced ADD contains no redundant nodes.
Reduce bottom-up, since a deletion can only expose further merges above it. The eight sinks carry three distinct labels, so they merge to \(s_{.1}, s_{.9}, s_{.5}\), and the four \(Z\)-nodes then have child pairs \((\text{low}, \text{high})\):
| context | \(Z\)-node child pair |
|---|---|
| \(X=\text{false}, Y=\text{false}\) | \((s_{.1},\, s_{.9})\) |
| \(X=\text{false}, Y=\text{true}\) | \((s_{.1},\, s_{.9})\) |
| \(X=\text{true}, Y=\text{false}\) | \((s_{.9},\, s_{.1})\) |
| \(X=\text{true}, Y=\text{true}\) | \((s_{.5},\, s_{.5})\) |
The fourth is redundant by the first rule and is replaced by \(s_{.5}\); the first two are duplicates by the second rule and merge into \(\zeta_1 = (s_{.1}, s_{.9})\); the third survives as \(\zeta_2 = (s_{.9}, s_{.1})\), no duplicate of \(\zeta_1\) since the child pair is ordered. At the \(Y\)-level, (i) under \(X\) false the node is \((\zeta_1,\zeta_1)\), redundant, so the root’s low edge goes straight to \(\zeta_1\); (ii) under \(X\) true it is \(\eta = (\zeta_2, s_{.5})\), which survives, as does the root \(\xi = (\zeta_1, \eta)\). The reduced ADD has four nonleaf nodes and three sinks, down from fifteen:
| node | label | low child (dotted) | high child (solid) |
|---|---|---|---|
| \(\xi\) | \(X\) | \(\zeta_1\) | \(\eta\) |
| \(\eta\) | \(Y\) | \(\zeta_2\) | \(s_{.5}\) |
| \(\zeta_1\) | \(Z\) | \(s_{.1}\) | \(s_{.9}\) |
| \(\zeta_2\) | \(Z\) | \(s_{.9}\) | \(s_{.1}\) |
with sinks \(s_{.1} = .1\), \(s_{.9} = .9\), \(s_{.5} = .5\) — the ADD of Figure 13.15(a) for \(f_1\). Tracing the eight instantiations:
| \(X\) | \(Y\) | \(Z\) | path | value |
|---|---|---|---|---|
| false | false | false | \(\xi \to \zeta_1 \to s_{.1}\) | .1 |
| false | false | true | \(\xi \to \zeta_1 \to s_{.9}\) | .9 |
| false | true | false | \(\xi \to \zeta_1 \to s_{.1}\) | .1 |
| false | true | true | \(\xi \to \zeta_1 \to s_{.9}\) | .9 |
| true | false | false | \(\xi \to \eta \to \zeta_2 \to s_{.9}\) | .9 |
| true | false | true | \(\xi \to \eta \to \zeta_2 \to s_{.1}\) | .1 |
| true | true | false | \(\xi \to \eta \to s_{.5}\) | .5 |
| true | true | true | \(\xi \to \eta \to s_{.5}\) | .5 |
which agree with the eight leaves of Figure 13.22; the result is reduced (Check!), hence by the canonicity of Section 13.5.1 the unique ADD for this factor under \(X,Y,Z\).
Show how we can reduce an ADD with \(n\) nodes using an algorithm that takes \(O(n \log n)\) time (see Figure 13.14).
Recall from Section 13.5.1 that a node of an ADD is redundant if its high and low children are the same node, or if another node in the ADD carries the same label and the same high and low children; reducing an ADD means repeatedly deleting redundant nodes, redirecting their parents to the surviving child or duplicate, until none remains. Figure 13.14 shows the successive removals on a small example.
Sweep the diagram once bottom-up in the variable order, giving every node a canonical integer identifier and detecting duplicates at each level by sorting rather than pairwise comparison; the naive scan-delete-rescan is \(\Theta(n^2)\) because each deletion can expose redundancies higher up.
Setup. For the order \(X_1 \prec \cdots \prec X_k\), bucket the \(n\) nodes of \(\varphi\) by label into levels, level \(k+1\) the sinks and level \(i\) the nodes labelled \(X_i\), in \(O(n)\) by one traversal; since \(\varphi\) respects \(\prec\), every child of a level-\(i\) node lies at a level \(> i\). Write \(n_i\) for the size of level \(i\), so \(\sum_i n_i = n\). We build maps \(\mathrm{id}(\cdot)\) to integers and \(\mathrm{rep}(\cdot)\) to output nodes under the invariant that, for processed \(u,v\), \(\mathrm{id}(u) = \mathrm{id}(v)\) iff the sub-ADDs at \(u\) and \(v\) denote the same factor, and \(\mathrm{rep}(u)\) is the unique output node with that identifier.
Sinks. Sort the \(n_{k+1}\) sinks by numeric label in \(O(n_{k+1} \log n_{k+1})\) and scan, creating one output sink per distinct label and giving every input sink with that label the same fresh identifier and \(\mathrm{rep}\). Two sinks denote the same constant factor exactly when their labels agree.
Levels \(i = k, \ldots, 1\). Every child of a level-\(i\) node lies later and is already processed. For \(v\) with children \(\ell, h\): if \(\mathrm{id}(\ell) = \mathrm{id}(h)\) then \(v\) denotes the same factor independently of \(X_i\), so set \(\mathrm{id}(v) \leftarrow \mathrm{id}(\ell)\), \(\mathrm{rep}(v) \leftarrow \mathrm{rep}(\ell)\) and delete \(v\) — the first rule, applied by identifier rather than pointer, which is what lets deletions cascade upward in one pass. Otherwise give \(v\) the signature \(\sigma(v) = (\mathrm{id}(\ell), \mathrm{id}(h))\). Sort the level’s survivors lexicographically by signature in \(O(n_i \log n_i)\) and scan: each maximal run of equal signatures is a duplicate class, which gets one output node labelled \(X_i\) with children \(\mathrm{rep}(\ell), \mathrm{rep}(h)\), a common fresh identifier, and that node as every member’s \(\mathrm{rep}\) — the second rule, applied to the whole level at once.
Return \(\mathrm{rep}(\varphi)\).
Correctness. The invariant holds at the sinks by step 1. Assuming it above level \(i\), two level-\(i\) nodes \(u,v\) denote the Shannon expansions
\begin{equation*} f_v \;=\; \overline{X_i}\, f_{\mathrm{low}(v)} \;+\; X_i\, f_{\mathrm{high}(v)}, \end{equation*}
so restricting to \(X_i\) false and true gives \(f_u = f_v\) iff the corresponding children agree, which by the induction hypothesis is \(\sigma(u) = \sigma(v)\); and a node deleted by the first test has \(f_v = f_{\mathrm{low}(v)}\), so inheriting its child’s identifier is correct too. Different levels never share an identifier, legitimately: a surviving level-\(i\) node denotes a factor that genuinely depends on \(X_i\) (its two restrictions differ), whereas a later-level node denotes one not mentioning \(X_i\). At the root, then, the output denotes the input’s factor, and it is reduced — no output node has two children of equal identifier and no two share a label and child pair — hence by canonicity the unique reduced ADD under \(\prec\).
Complexity. Bucketing costs \(O(n)\) and every node is touched a constant number of times outside the sorts, which cost
\begin{equation*} \sum_{i=1}^{k+1} O\!\left(n_i \log n_i\right) \;\le\; O\!\left(\log n \sum_{i=1}^{k+1} n_i\right) \;=\; O(n \log n), \end{equation*}
using \(n_i \le n\); everything else is \(O(1)\) per node or edge, and the ADD has at most \(2n\) edges. Total: \(O(n \log n)\) time, \(O(n)\) space. (Identifiers issued consecutively lie in \(\{1,\ldots,n\}\), so counting sort on signatures gives an \(O(n)\) worst-case variant and hashing an \(O(n)\) expected one; the comparison version assumes nothing about identifiers or hashing.)
Consider the method described in Section 13.5.2 for converting a tabular representation of a factor into its ADD representation. Consider now a second method in which we construct a decision tree to represent the factor (see Figure 13.22) and then reduce the ADD using the algorithm developed in Exercise 13.11. Implement and compare the efficiency of these methods.
Recall the first method: for each row of the table one builds an ADD that maps the instantiation of that row to the row’s value and every other instantiation to \(0\) – a single path of \(k\) nonleaf nodes hanging off a sink \(0\), as in Figure 13.17(a) and (b) – and then adds all these row ADDs together with the APPLY operation of Algorithm 37, as in Figure 13.17(c).
Method 2 dominates: \(O(N \log N)\), or \(O(N)\) with radix sorting, against Method 1’s quadratic cost, where \(N = 2^k\) is the number of rows for a factor over \(k\) binary variables.
Method 1 (row ADDs plus APPLY). Building the \(N\) row ADDs, each \(k\) nonleaf nodes and two sinks, costs \(O(kN)\); the \(N\) accumulating APPLY calls dominate. With \(\varphi_j\) the accumulator after \(j\) rows, an APPLY of sizes \(a,b\) costs \(O(ab)\) by Algorithm 37 and the second argument is a path of \(O(k)\) nodes, so one call costs \(O(k\,|\varphi_j|)\) — the cache is indexed by pairs (node of \(\varphi_j\), node of the path), and the path has one node per level. Since \(|\varphi_j|\) grows until it saturates at the final ADD’s size,
\begin{equation*} \sum_{j=1}^{N} O\!\left(k\,|\varphi_j|\right) \;=\; O\!\left(k N \max_j |\varphi_j|\right) \;=\; O(k N^2), \end{equation*}
quadratic in the table size, with a large constant besides: each APPLY allocates a fresh cache, rebuilds every accumulator node, and does a unique-table lookup per node.
Method 2 (decision tree plus reduce). The complete decision tree is one bottom-up pass — level \(k+1\) is the \(N\) sinks read off the table, each higher level pairs adjacent entries below — giving \(2N-1\) nodes in \(O(N)\); reducing it by Exercise 13.11 costs \(O(n \log n)\) with \(n = 2N-1\),
\begin{equation*} O(N \log N) \;=\; O(2^k\, k), \end{equation*}
dropping to \(O(N)\) with the radix-sort variant, which is optimal since the table must be read; and the tree need never be materialized, since reducing each level as it is built keeps peak memory to the reduced levels alone.
Measurements. Both methods were implemented over a common ADD manager with a unique table and the cached APPLY of Algorithm 37, Method 2 using the hashing variant of Exercise 13.11. The instrumented cost is node-processing steps: for Method 1 the nodes built for the \(N\) row ADDs plus the distinct APPLY cache entries; for Method 2 the \(N\) sinks plus the \(N-1\) constructions of the sweep. Values were drawn from \(\{0,.1,.2,.5,.8,.9,1\}\), and “dep” is the number of leading variables the factor genuinely depends on, so dep \(=k\) has no local structure and dep \(=k/2\) a great deal. Times are seconds on one core.
| \(k\) | dep | rows \(N\) | Method 1 steps | Method 2 steps | Method 1 sec | Method 2 sec |
|---|---|---|---|---|---|---|
| 6 | 6 | 64 | 2,596 | 127 | 0.006 | 0.000 |
| 6 | 3 | 64 | 1,223 | 127 | 0.002 | 0.000 |
| 8 | 8 | 256 | 28,550 | 511 | 0.044 | 0.000 |
| 8 | 4 | 256 | 6,832 | 511 | 0.007 | 0.000 |
| 10 | 10 | 1,024 | 315,741 | 2,047 | 0.498 | 0.001 |
| 10 | 5 | 1,024 | 37,761 | 2,047 | 0.039 | 0.000 |
| 12 | 12 | 4,096 | 4,147,677 | 8,191 | 3.750 | 0.002 |
| 12 | 6 | 4,096 | 216,769 | 8,191 | 0.465 | 0.001 |
| 14 | 14 | 16,384 | 54,944,557 | 32,767 | 60.833 | 0.007 |
| 14 | 7 | 16,384 | 1,304,769 | 32,767 | 0.907 | 0.004 |
Both produce ADDs agreeing with the table on all \(2^k\) instantiations, hence by canonicity the same ADD. For the unstructured factors Method 1’s step count grows by a factor near \(16\) each time \(N\) quadruples — the predicted quadratic — while Method 2’s is exactly \(2N-1\) throughout, the \(\Theta(N)\) of the hashing variant; the times track the counts, the gap reaching four orders of magnitude at \(k=14\). Local structure cuts Method 1’s cost by about \(42\times\) at \(k=14\) but not its growth rate, there still being one APPLY per row at a cost proportional to the accumulator, while Method 2’s cost is independent of local structure, the tree being built in full before anything merges.
Construct an ADD over variables \(A\) and \(B\), which maps each instantiation to \(1\) if either \(A\) or \(B\) is true and to \(0\) otherwise. Multiply this ADD with the one constructed in Exercise 13.8.
The ADD of Exercise 13.8 represents the CPT \(\Pr(D \mid A,B,C)\) of Figure 13.21 under the order \(A,B,C,D\); its reduced form is: root \(\alpha\) labeled \(A\) with \(\text{low}(\alpha)=\beta_2\), \(\text{high}(\alpha)=\beta_1\); \(\beta_1\) labeled \(B\) with \(\text{low}(\beta_1)=\gamma\), \(\text{high}(\beta_1)=\delta_1\); \(\beta_2\) labeled \(B\) with \(\text{low}(\beta_2)=\delta_3\), \(\text{high}(\beta_2)=s_{.5}\); \(\gamma\) labeled \(C\) with \(\text{low}(\gamma)=\delta_2\), \(\text{high}(\gamma)=\delta_1\); and the three \(D\)-nodes \(\delta_1 = (s_{.1}, s_{.9})\), \(\delta_2 = (s_{.8}, s_{.2})\), \(\delta_3 = (s_{1}, s_{0})\), each written as (low, high).
The disjunction ADD. For \(g(A,B) = 1\) iff \(A \vee B\), under the same order \(A \prec B \prec C \prec D\): \(A\) true makes the disjunction hold regardless of \(B\), so the root’s high child is the sink \(1\), and \(A\) false leaves the value of \(B\). Hence
| node | label | low child | high child |
|---|---|---|---|
| \(\alpha^{\prime}\) (root) | \(A\) | \(\beta^{\prime}\) | \(t_{1}\) |
| \(\beta^{\prime}\) | \(B\) | \(t_{0}\) | \(t_{1}\) |
with sinks \(t_0 = 0\), \(t_1 = 1\); four nodes, reduced (Check!).
The product. Run APPLY (Algorithm 37) with \(\odot = {*}\) on \(\varphi_1 = \alpha\) and \(\varphi_2 = \alpha^{\prime}\). Both roots are labelled \(A\), so line 6 recurses on the two branches.
- (i) \(A\) true: \(\textsc{Apply}(\beta_1, t_1, *)\). Line 10 carries the sink \(t_1\) unchanged into every branch of \(\beta_1\) down to the sinks, where each value is multiplied by \(1\); since
unique_nodeandunique_sinkreturn the existing node whenever one matches, the branch rebuilds \(\beta_1\) itself. - (ii) \(A\) false: \(\textsc{Apply}(\beta_2, \beta^{\prime}, *)\), both labelled \(B\). On the high side \(.5 \cdot 1 = .5\); on the low side \(\textsc{Apply}(\delta_3, t_0, *)\) carries \(t_0\) into both children of \(\delta_3\), giving \(0\) twice, so line 13 returns the sink \(0\) instead of creating a node — the whole \(\delta_3\) subgraph collapses. The two results differ, so a \(B\)-node \(\beta_3 = (s_0, s_{.5})\) is created.
The two \(A\)-branches differ, so the root is an \(A\)-node with children \(\beta_3, \beta_1\), and the reduced ADD of \(h = f \cdot g\) is
| node | label | low child (dotted) | high child (solid) |
|---|---|---|---|
| \(\alpha_h\) (root) | \(A\) | \(\beta_3\) | \(\beta_1\) |
| \(\beta_1\) | \(B\) | \(\gamma\) | \(\delta_1\) |
| \(\beta_3\) | \(B\) | \(s_0\) | \(s_{.5}\) |
| \(\gamma\) | \(C\) | \(\delta_2\) | \(\delta_1\) |
| \(\delta_1\) | \(D\) | \(s_{.1}\) | \(s_{.9}\) |
| \(\delta_2\) | \(D\) | \(s_{.8}\) | \(s_{.2}\) |
with sinks \(s_0, s_{.1}, s_{.2}, s_{.5}, s_{.8}, s_{.9}\): \(12\) nodes against the \(14\) of Exercise 13.8, the node \(\delta_3\) and the sink \(1\) having gone and \(\beta_2\) having become \(\beta_3\). Multiplying by \(g\) leaves \(f\) untouched where \(A \vee B\) holds and zeroes the four rows where both are false:
| \(A\) | \(B\) | \(C\) | \(D\) | \(f\) | \(g\) | \(f \cdot g\) |
|---|---|---|---|---|---|---|
| true | true | true | true | .9 | 1 | .9 |
| true | true | true | false | .1 | 1 | .1 |
| true | true | false | true | .9 | 1 | .9 |
| true | true | false | false | .1 | 1 | .1 |
| true | false | true | true | .9 | 1 | .9 |
| true | false | true | false | .1 | 1 | .1 |
| true | false | false | true | .2 | 1 | .2 |
| true | false | false | false | .8 | 1 | .8 |
| false | true | true | true | .5 | 1 | .5 |
| false | true | true | false | .5 | 1 | .5 |
| false | true | false | true | .5 | 1 | .5 |
| false | true | false | false | .5 | 1 | .5 |
| false | false | true | true | 0 | 0 | 0 |
| false | false | true | false | 1 | 0 | 0 |
| false | false | false | true | 0 | 0 | 0 |
| false | false | false | false | 1 | 0 | 0 |
and tracing the sixteen rows through the ADD reproduces the last column (Check!).
Sum out variable \(B\) from the ADD constructed in Exercise 13.8.
That ADD represents the CPT \(\Pr(D \mid A,B,C)\) of Figure 13.21 under the order \(A,B,C,D\). Its reduced form is: root \(\alpha\) labeled \(A\) with \(\text{low}(\alpha)=\beta_2\), \(\text{high}(\alpha)=\beta_1\); \(\beta_1\) labeled \(B\) with \(\text{low}(\beta_1)=\gamma\), \(\text{high}(\beta_1)=\delta_1\); \(\beta_2\) labeled \(B\) with \(\text{low}(\beta_2)=\delta_3\), \(\text{high}(\beta_2)=s_{.5}\); \(\gamma\) labeled \(C\) with \(\text{low}(\gamma)=\delta_2\), \(\text{high}(\gamma)=\delta_1\); and the \(D\)-nodes \(\delta_1 = (s_{.1}, s_{.9})\), \(\delta_2 = (s_{.8}, s_{.2})\), \(\delta_3 = (s_{1}, s_{0})\), written as (low, high).
By the method of Section 13.5.2 (Figure 13.16), summing out a variable is done by adding two restrictions:
\begin{equation*} \sum_{B} f \;=\; f^{B=\text{true}} \;+\; f^{B=\text{false}}, \end{equation*}
each restriction by RESTRICT (Algorithm 38), the addition by APPLY (Algorithm 37) with \(\odot = {+}\).
Restrictions. RESTRICT follows the high child at a \(B\)-node (line 6) and recurses on both children elsewhere (lines 10–12). From \(\alpha\): \(\beta_1 \mapsto \delta_1\) and \(\beta_2 \mapsto s_{.5}\), which differ, so \(f^{B=\text{true}}\) is the \(A\)-node with low \(s_{.5}\) and high \(\delta_1\) — mentioning no \(C\), as the CPT’s \(B\) true half indeed does not. Taking low children instead, \(\beta_1 \mapsto \gamma\) and \(\beta_2 \mapsto \delta_3\), so \(f^{B=\text{false}}\) is the \(A\)-node with low \(\delta_3\) and high \(\gamma\).
Addition. Both roots are labelled \(A\), so APPLY recurses on matching branches.
- (i) \(A\) true: add \(\delta_1\) to \(\gamma\); since \(C \prec D\), line 10 carries \(\delta_1\) into both branches of \(\gamma\). Under \(C\) true, \(\textsc{Apply}(\delta_1,\delta_1,+)\) gives \(\varepsilon_1 = (s_{.2}, s_{1.8})\); under \(C\) false, \(\textsc{Apply}(\delta_2,\delta_1,+)\) gives \(\varepsilon_2 = (s_{.9}, s_{1.1})\). These differ, so a \(C\)-node \(\gamma^{\prime} = (\varepsilon_2, \varepsilon_1)\) is created.
- (ii) \(A\) false: add \(s_{.5}\) to \(\delta_3\); the sink follows every variable, so line 10 applies with \(\delta_3\) first, giving \(\varepsilon_3 = (s_{1.5}, s_{.5})\), independent of \(C\).
The two \(A\)-branches differ, so the reduced ADD for \(\sum_B f\), over \(A,C,D\), is
| node | label | low child (dotted) | high child (solid) |
|---|---|---|---|
| \(\alpha^{\prime\prime}\) (root) | \(A\) | \(\varepsilon_3\) | \(\gamma^{\prime}\) |
| \(\gamma^{\prime}\) | \(C\) | \(\varepsilon_2\) | \(\varepsilon_1\) |
| \(\varepsilon_1\) | \(D\) | \(s_{.2}\) | \(s_{1.8}\) |
| \(\varepsilon_2\) | \(D\) | \(s_{.9}\) | \(s_{1.1}\) |
| \(\varepsilon_3\) | \(D\) | \(s_{1.5}\) | \(s_{.5}\) |
with the six sinks \(s_{.2}, s_{1.8}, s_{.9}, s_{1.1}, s_{1.5}, s_{.5}\): \(11\) nodes, reduced, since all six sink values are distinct, \(\varepsilon_1 \ne \varepsilon_2\), and the three \(D\)-nodes have pairwise different child pairs. Summing out \(B\) from Figure 13.21 by hand,
| \(A\) | \(C\) | \(D\) | \(B=\text{true}\) | \(B=\text{false}\) | \(\sum_B\) |
|---|---|---|---|---|---|
| true | true | true | .9 | .9 | 1.8 |
| true | true | false | .1 | .1 | .2 |
| true | false | true | .9 | .2 | 1.1 |
| true | false | false | .1 | .8 | .9 |
| false | true | true | .5 | 0 | .5 |
| false | true | false | .5 | 1 | 1.5 |
| false | false | true | .5 | 0 | .5 |
| false | false | false | .5 | 1 | 1.5 |
and tracing the eight rows through the ADD reproduces the last column, the \(A\) false rows going straight to \(\varepsilon_3\) and so not depending on \(C\).
Exercises 13.15–13.21
Restrict the ADD constructed in Exercise 13.8 to \(C = \text{false}\).
Recall that Exercise 13.8 asks for an ADD representation of the CPT \(\Pr(D \mid A,B,C)\) of Figure 13.21, using the ADD variable order \(A, B, C, D\). All four variables are binary and the CPT is:
| A | B | C | D | \(\Pr(D\mid A,B,C)\) |
|---|---|---|---|---|
| true | true | true | true | .9 |
| true | true | true | false | .1 |
| true | true | false | true | .9 |
| true | true | false | false | .1 |
| true | false | true | true | .9 |
| true | false | true | false | .1 |
| true | false | false | true | .2 |
| true | false | false | false | .8 |
| false | true | true | true | .5 |
| false | true | true | false | .5 |
| false | true | false | true | .5 |
| false | true | false | false | .5 |
| false | false | true | true | 0 |
| false | false | true | false | 1 |
| false | false | false | true | 0 |
| false | false | false | false | 1 |
The CPT is viewed here as a factor \(f(A,B,C,D)\) over four binary variables. Apply the RESTRICT operation of Algorithm 38 with the instantiation \(C = \text{false}\) and report the resulting reduced ADD.
Restricting to \(C = \text{false}\) deletes the single \(C\)-node and hands its low child up. Exercise 13.8’s reduced ADD \(\varphi\) under \(A \prec B \prec C \prec D\), with \(D\)-nodes written as (high, low) pairs \(\alpha = (.9,.1)\), \(\beta = (.2,.8)\), \(\delta = (0,1)\) and the \((.5,.5)\) node collapsed to its sink, is:
| node | label | high child | low child |
|---|---|---|---|
| \(r\) (root) | \(A\) | \(b_1\) | \(b_0\) |
| \(b_1\) | \(B\) | \(\alpha\) | \(c_1\) |
| \(b_0\) | \(B\) | sink \(.5\) | \(\delta\) |
| \(c_1\) | \(C\) | \(\alpha\) | \(\beta\) |
| \(\alpha\) | \(D\) | sink \(.9\) | sink \(.1\) |
| \(\beta\) | \(D\) | sink \(.2\) | sink \(.8\) |
| \(\delta\) | \(D\) | sink \(0\) | sink \(1\) |
with sinks \(.9,.1,.2,.8,.5,0,1\): \(14\) nodes against \(16\) table rows, and \(C\) mentioned on only one path, recording that \(\Pr(D \mid A,B,C) = \Pr(D \mid A,B)\) outside the context \(A\) true, \(B\) false.
RESTRICT (Algorithm 38) walks top down, descending into the child selected by the evidence at an instantiated node and rebuilding every other node, collapsing it when the two returned children coincide. Only \(C\) is instantiated, to false, so only \(c_1\) is affected: it returns its low child \(\beta\) (line 8), whence \(b_1\) becomes \(b_1^{\prime} = (\alpha, \beta)\), which survives since \(\alpha \ne \beta\), while \(b_0, \alpha, \beta, \delta\) and the sinks are unchanged. Thus \(\varphi^{C = \text{false}}\) is
| node | label | high child | low child |
|---|---|---|---|
| \(r^{\prime}\) (root) | \(A\) | \(b_1^{\prime}\) | \(b_0\) |
| \(b_1^{\prime}\) | \(B\) | \(\alpha\) | \(\beta\) |
| \(b_0\) | \(B\) | sink \(.5\) | \(\delta\) |
| \(\alpha\) | \(D\) | sink \(.9\) | sink \(.1\) |
| \(\beta\) | \(D\) | sink \(.2\) | sink \(.8\) |
| \(\delta\) | \(D\) | sink \(0\) | sink \(1\) |
with the same seven sinks: \(6\) nonsink nodes, reduced (Check!), respecting \(A \prec B \prec D\). It represents the factor over \(A,B,D\) obtained by deleting every \(C = \text{true}\) row of the CPT:
| A | B | D | value |
|---|---|---|---|
| true | true | true | .9 |
| true | true | false | .1 |
| true | false | true | .2 |
| true | false | false | .8 |
| false | true | true | .5 |
| false | true | false | .5 |
| false | false | true | 0 |
| false | false | false | 1 |
For instance \(A\) true, \(B\) false, \(D\) true traces \(r^{\prime} \to b_1^{\prime} \to \beta \to\) the sink \(.2\), the CPT entry for \(A\) true, \(B\) false, \(C\) false, \(D\) true; the other seven rows likewise (Check!).
Let \(f_1(\mathbf{X}_1)\) and \(f_2(\mathbf{X}_2)\) be two factors and let \(\varphi_1\) and \(\varphi_2\) be their corresponding ADD representations using the same variable ordering. Show that the size of the ADD returned by \(\text{APPLY}(\varphi_1, \varphi_2, \odot)\) is \(O(\exp(|\mathbf{X}_1 \cup \mathbf{X}_2|))\).
With \(\mathbf{Z} = \mathbf{X}_1 \cup \mathbf{X}_2\), \(k = |\mathbf{Z}|\) and the common order restricted to \(\mathbf{Z}\) written \(V_1 \prec \dots \prec V_k\), the output \(\varphi = \text{APPLY}(\varphi_1,\varphi_2,\odot)\) is a reduced ADD over \(\mathbf{Z}\) respecting \(\prec\), and any such ADD has at most \(2^{k+1}-1\) nodes.
(i) Only \(\mathbf{Z}\)-variables, in order. In Algorithm 37 a nonsink node is created only by \(\text{unique\\_node}(l,h,V)\) on lines 9 and 13, with \(V = \text{var}(\varphi_1)\) for arguments that are descendants of the original \(\varphi_1,\varphi_2\), hence \(V \in \mathbf{Z}\). The order is respected: on lines 7–8 both recursive arguments lie strictly below \(\text{var}(\varphi_1)\), and on lines 11–12 line 1 with the line-10 guard forces \(\text{var}(\varphi_1) \prec \text{var}(\varphi_2)\), so again both lie strictly below.
(ii) Reduced, and every counted node reachable. Lines 9 and 13 return \(l\) whenever \(l = h\), so no node has two identical children, and \(\text{unique\\_node}/\text{unique\\_sink}\) return an existing node whenever one matches, so no two nodes share a label and child pair. An ADD is the rooted DAG at its root, so nodes built during the computation and then orphaned by a later collapse do not count towards \(|\varphi|\).
(iii) The counting bound. Let \(\psi\) be an ADD over \(V_1 \prec \dots \prec V_k\) with every node reachable, and let \(u\) be labelled \(V_i\). A root-to-\(u\) path \(\pi\) has every node above \(u\) labelled strictly before \(V_i\), so \(\pi\) fixes a partial instantiation of \(V_1,\dots,V_{i-1}\); extending it arbitrarily to a full instantiation \(\mathbf{v}\) and following \(\mathbf{v}\) from the root reaches exactly \(u\), since at each node on the way \(\mathbf{v}\) selects the child lying on \(\pi\). Hence \(\mathbf{v} \mapsto\) the first node reached whose variable is not among \(V_1,\dots,V_{i-1}\) is onto the \(V_i\)-nodes, so
\begin{equation*} \#\{\text{nodes labeled } V_i\} \;\le\; 2^{\,i-1}, \end{equation*}
and the same argument on sinks, regarded as labelled by a variable following all others, gives \(\#\{\text{sinks}\} \le 2^{k}\). Summing,
\begin{equation*} \begin{aligned} |\psi| \;&\le\; \sum_{i=1}^{k} 2^{\,i-1} \;+\; 2^{k}\\ &=\; (2^{k}-1) + 2^{k} \;=\; 2^{k+1}-1 . \end{aligned} \end{equation*}
Applying this to \(\varphi\),
\begin{equation*} |\varphi| \;\le\; 2^{\,|\mathbf{X}_1 \cup \mathbf{X}_2|+1} - 1 \;=\; O(\exp(|\mathbf{X}_1 \cup \mathbf{X}_2|)). \end{equation*}
We presented an \(O(n^2)\) algorithm for summing out a variable from an ADD, where \(n\) is the size of the given ADD. The algorithm restricts the ADD twice and then adds the two results,
\begin{equation*} \sum_X f \;=\; \Bigl(\sum_X f^{X=\text{false}}\Bigr) + \Bigl(\sum_X f^{X=\text{true}}\Bigr), \end{equation*}
using RESTRICT (Algorithm 38) twice and APPLY (Algorithm 37) once with \(\odot\) taken to be numeric addition. Assuming that the summed-out variable appears last in the ADD variable order, show how the sum-out operation can be implemented in \(O(n)\). Show that this complexity applies to summing out multiple variables as long as they appear last in the ADD order.
One bottom-up sweep does it, the summed-out variables occupying the bottom layers so that no APPLY of two large ADDs is ever needed. Throughout, all variables are binary, \(\varphi\) has \(n\) nodes (sinks included) and respects \(V_1 \prec \dots \prec V_k\), and a unique-table operation or an arithmetic operation on sink labels costs \(O(1)\) — the accounting under which APPLY is \(O(nm)\).
One variable, last in the order. With \(X = V_k\), an \(X\)-node can only have sinks as children, so the \(X\)-nodes form the layer just above the sinks and one bottom-up sweep suffices — provided sinks reached on paths bypassing \(X\) are doubled: if the path of an instantiation \(\mathbf{v}\) of \(V_1,\dots,V_{k-1}\) meets no \(X\)-node and ends at the sink \(s\), then \(f(\mathbf{v},x) = s\) for both \(x\), so \((\sum_X f)(\mathbf{v}) = 2s\). Process the nodes in reverse topological order, computing \(g(u)\):
- \(u\) a sink with label \(s\): \(g(u) \leftarrow \text{unique\\_sink}(2s)\).
- \(u\) labelled \(X\), with sink children labelled \(a\) (low) and \(b\) (high): \(g(u) \leftarrow \text{unique\\_sink}(a+b)\) — reading the children’s labels, not \(g\) of them.
- \(u\) labelled \(V_i\), \(i<k\): with \(l = g(\text{low}(u))\), \(h = g(\text{high}(u))\), set \(g(u) \leftarrow l\) if \(l = h\) and \(g(u) \leftarrow \text{unique\\_node}(l,h,V_i)\) otherwise.
Return \(g(\text{root})\). Writing \(f_u\) for the factor at \(u\), a bottom-up induction gives \(g(u) = \sum_X f_u\) for every \(u\) not labelled \(X\): a sink is constant in \(X\), so \(\sum_X f_u \equiv 2s\) as rule 1 builds; and at \(V_i\) with \(i<k\), summing out commutes with the case split \(f_u(V_i = \text{false},\cdot) = f_{\text{low}(u)}\), \(f_u(V_i = \text{true},\cdot) = f_{\text{high}(u)}\), each child being covered by rule 2 (whose \(a+b\) is the correct constant) or by the hypothesis, and rule 3 assembles them. The root is labelled \(X\) only when \(k=1\), which rule 2 handles. The output is reduced — rule 3 never builds a node with identical children and the unique table never duplicates — and respects \(V_1 \prec \dots \prec V_{k-1}\).
Each node is examined once for \(O(1)\) work, and bucketing nodes by variable index and scanning from \(k\) down gives the reverse topological order in \(O(n)\), so the total is \(O(n)\) and the result has \(O(n)\) nodes. In the general case the two restrictions are \(O(n)\) each but the closing APPLY of two size-\(O(n)\) ADDs is \(O(n^2)\); that is the step the assumption removes, the two restrictions differing only in the layer above the sinks and so combining locally.
Several variables, a suffix of the order. Let \(\mathbf{Y} = \{V_{k-m+1},\dots,V_k\}\), renamed \(W_1 \prec \dots \prec W_m\). By the ordering condition the sub-ADD at any \(\mathbf{Y}\)-labelled node mentions only \(\mathbf{Y}\)-variables, so \(\varphi\) splits into an upper part over \(V_1,\dots,V_{k-m}\) and maximal lower sub-ADDs over \(\mathbf{Y}\), each of which summing out replaces by a single number. Put \(\mathrm{lvl}(u) = j\) for \(u\) labelled \(W_j\) and \(m+1\) for a sink, and for \(\mathrm{lvl}(u) = j\) let
\begin{equation*} \sigma(u) \;=\; \sum_{W_j, \dots, W_m} f_u , \end{equation*}
the total of \(f_u\) over the \(\mathbf{Y}\)-variables at or after \(W_j\) (an empty sum-range for a sink, so \(\sigma(\text{sink}) = \) its label). If \(u\) is labeled \(W_j\) and \(c\) is one of its children with \(\mathrm{lvl}( c) = j^{\prime}\), then \(f_c\) is constant in \(W_{j+1},\dots,W_{j^{\prime}-1}\), whence
\begin{equation*} \sum_{W_{j+1},\dots,W_m} f_c \;=\; 2^{\,j^{\prime}-j-1}\,\sigma( c). \end{equation*}
Therefore, bottom up,
\begin{equation*} \sigma(u) \;=\; 2^{\,j_l-j-1}\,\sigma(\text{low}(u)) \;+\; 2^{\,j_h-j-1}\,\sigma(\text{high}(u)), \end{equation*}
where \(j_l = \mathrm{lvl}(\text{low}(u))\) and \(j_h = \mathrm{lvl}(\text{high}(u))\). Each \(\sigma(u)\) costs \(O(1)\) once the powers \(2^0, 2^1, \dots, 2^{m}\) have been tabulated, which is \(O(m) = O(n)\) work done once.
Now define \(g\) on all nodes:
- If \(\mathrm{lvl}(u) \le m+1\), i.e. \(u\) is a sink or is labeled with a \(\mathbf{Y}\)-variable, set \(g(u) \leftarrow \text{unique\\_sink}\bigl(2^{\,\mathrm{lvl}(u)-1}\,\sigma(u)\bigr)\). The factor \(2^{\,\mathrm{lvl}(u)-1}\) accounts for the \(\mathbf{Y}\)-variables \(W_1,\dots,W_{\mathrm{lvl}(u)-1}\) that the path skipped, in which \(f_u\) is constant.
- If \(u\) is labeled \(V_i\) with \(i \le k-m\), set \(l = g(\text{low}(u))\), \(h = g(\text{high}(u))\), and \(g(u) \leftarrow l\) if \(l = h\), otherwise \(g(u) \leftarrow \text{unique\\_node}(l,h,V_i)\).
Return \(g(\text{root})\).
Correctness is the same induction as before: for a node \(u\) above the \(\mathbf{Y}\)-layers, \(g(u)\) represents \(\sum_{\mathbf{Y}} f_u\), because summing out commutes with the case split at \(u\) and because rule 1 supplies precisely \(\sum_{\mathbf{Y}} f_c\) for a child \(c\) in the \(\mathbf{Y}\) region; the one-variable case is \(m=1\), where \(\sigma\) of an \(X\)-node is \(a+b\) at \(\mathrm{lvl}=1\) and \(\sigma\) of a sink is \(s\) at \(\mathrm{lvl}=2\), giving \(2s\). Every node is touched once for \(O(1)\) arithmetic and \(O(1)\) unique-table work, plus the \(O(m)\) table of powers and the \(O(n)\) bucket sort by level, so eliminating all \(m\) variables costs \(O(n)\) altogether, not \(O(mn)\).
Show how we can represent a factor over multivalued variables using an ADD with binary variables. Explain how the sum-out operation (of a multivalued variable) should be implemented in this case.
Binary-encode each value and pad with zero. For \(f(X_1,\dots,X_N)\) with \(|X_t| = k_t\), take \(b_t = \lceil \log_2 k_t\rceil\) binary ADD variables \(X_t^1,\dots,X_t^{b_t}\) and an injection \(c_t\) of \(X_t\)’s values into \(\{\text{false},\text{true}\}^{b_t}\); a bit vector is valid if it lies in the image of \(c_t\) and spurious otherwise. Set
\begin{equation*} \hat f(\mathbf{v}) \;=\; \begin{cases} f(\mathbf{x}), & \mathbf{v} \text{ restricted to } X_t\text{’s bits is } c_t(x_t) \text{ for all } t,\\ 0, & \text{some } X_t\text{’s bits are spurious in } \mathbf{v}, \end{cases} \end{equation*}
and represent \(f\) by the reduced ADD of \(\hat f\) under any order keeping each variable’s bits consecutive.
Zero padding is what makes both factor operations survive. Multiplication is unchanged: \(\text{APPLY}(\hat f_1,\hat f_2,\cdot)\) agrees with \(f_1 f_2\) on valid instantiations and is \(0 \cdot 0 = 0\) on spurious ones, so the product is again zero-padded. Sum-out of \(X_t\) is the sum-out of its \(b_t\) bits in succession,
\begin{equation*} \widehat{\textstyle\sum_{X_t} f} \;=\; \sum_{X_t^1} \cdots \sum_{X_t^{b_t}} \hat f , \end{equation*}
each an ordinary binary ADD sum-out: fixing the other bits at \(\mathbf{w}\), the right-hand side is \(\sum_{\mathbf{v}} \hat f(\mathbf{w},\mathbf{v})\) over all \(2^{b_t}\) vectors \(\mathbf{v}\), the spurious ones contributing \(0\), so the value is \(0\) when \(\mathbf{w}\) is spurious (as the encoding demands) and \(\sum_{x_t} f(\mathbf{y},x_t)\) when \(\mathbf{w}\) encodes \(\mathbf{y}\) – zero-padded again, so the invariant survives every elimination step. With \(X_t\)’s bits placed last and consecutively, Exercise 13.17 does all \(b_t\) sum-outs in one bottom-up sweep of time \(O(n)\) in the ADD size \(n\).
Consider Bayesian networks of the type given in Figure 13.4 and let \(\mathbf{e}\) be some evidence on nodes \(S_i\). Let \(m\) be the number of nodes \(S_i\) set to true by evidence \(\mathbf{e}\) and let \(k\) be the number of network edges. Show that \(\Pr(D_j \mid \mathbf{e})\) can be computed in \(O(k \exp(m))\).
Figure 13.4(a) is a two-layer network. Its roots are the binary nodes \(D_1, D_2, D_3, D_4\), each with its own prior; its leaves are the binary nodes \(S_1, S_2, S_3\), and the edges are
\begin{equation*} \begin{aligned} &D_1 \to S_1, \quad D_2 \to S_1, \quad D_3 \to S_1,\\ &D_2 \to S_2, \quad D_3 \to S_2, \quad D_4 \to S_2,\\ &D_3 \to S_3, \quad D_4 \to S_3, \end{aligned} \end{equation*}
so \(\mathbf{Pa}(S_1) = \{D_1,D_2,D_3\}\), \(\mathbf{Pa}(S_2) = \{D_2,D_3,D_4\}\) and \(\mathbf{Pa}(S_3) = \{D_3,D_4\}\), giving \(k = 8\) edges. Each leaf node \(S_i\) is a logical-or of its parents. Networks “of this type” are the general such two-layer networks: binary roots \(D_1,\dots,D_n\) with arbitrary priors, binary leaves \(S_1,\dots,S_p\) whose parents are arbitrary subsets of the roots, each leaf being the logical-or of its parents, and \(k = \sum_i |\mathbf{Pa}(S_i)|\).
Hint: prune the network and appeal to the inclusion-exclusion principle, which states that
\begin{equation*} \Pr(\alpha_1 \vee \dots \vee \alpha_n) \;=\; \sum_{t=1}^{n} (-1)^{t-1} \!\!\!\sum_{I \subseteq \{1,\dots,n\},\, |I| = t} \!\!\! \Pr\Bigl( \bigwedge_{i \in I} \alpha_i \Bigr), \end{equation*}
an equation with \(2^n - 1\) terms.
Prune to an event over the roots, then expand the \(m\) positive observations by inclusion-exclusion; the resulting \((\ast\ast)\) has \(2^m\) terms of cost \(O(k)\) each. Write \(p_j = \Pr(D_j = \text{true})\), \(\bar p_j = 1-p_j\), let \(\mathbf{e}\) set \(S_i\) false for \(i \in N\) and true for \(i \in T\) with \(|T| = m\), and put \(\alpha_i = \bigvee_{D \in \mathbf{Pa}(S_i)}(D = \text{true})\).
Unobserved leaves are barren, hence deletable (Chapter 6), and the surviving leaf CPTs are indicators, \(\Pr(s_i \mid \mathbf{d}) = [\mathbf{d} \models \alpha_i]\) and \(\Pr(\bar s_i \mid \mathbf{d}) = [\mathbf{d}\models\neg\alpha_i]\), so \(\Pr(\mathbf{e}) = \Pr(\bigwedge_{i \in N}\neg\alpha_i \wedge \bigwedge_{i \in T}\alpha_i)\), an event over the mutually independent roots alone (Section 13.2.3). Since \(\neg\alpha_i\) says every parent of \(S_i\) is false,
\begin{equation*} \bigwedge_{i \in N} \neg\alpha_i \;\equiv\; \bigwedge_{D \in \mathbf{F}} (D = \text{false}), \qquad \mathbf{F} \;=\; \bigcup_{i \in N} \mathbf{Pa}(S_i). \end{equation*}
found in \(O(k)\) by one edge scan. Conditioning on it leaves the other roots at their priors and reduces each \(\alpha_i\), \(i \in T\), to \(\alpha_i^{\prime} = \bigvee_{D \in \mathbf{Pa}(S_i)\setminus\mathbf{F}}(D = \text{true})\), whence \(\Pr(\mathbf{e}) = (\prod_{D_j\in\mathbf{F}}\bar p_j)\Pr(\bigwedge_{i\in T}\alpha_i^{\prime})\). Complementing the remaining conjunction and applying the hint,
\begin{equation*} \Pr\Bigl(\bigwedge_{i \in T} \alpha_i^{\prime}\Bigr) = 1 - \Pr\Bigl(\bigvee_{i \in T} \neg\alpha_i^{\prime}\Bigr) = \sum_{I \subseteq T} (-1)^{|I|} \Pr\Bigl(\bigwedge_{i \in I} \neg\alpha_i^{\prime}\Bigr), \end{equation*}
the \(I = \emptyset\) term being \(1\), and each remaining term a conjunction of negative literals,
\begin{equation*} \bigwedge_{i \in I} \neg\alpha_i^{\prime} \;\equiv\; \bigwedge_{D \in \mathbf{U}_I} (D = \text{false}), \qquad \mathbf{U}_I \;=\; \bigcup_{i \in I}\bigl(\mathbf{Pa}(S_i)\setminus \mathbf{F}\bigr), \end{equation*}
of probability \(\prod_{D_j \in \mathbf{U}_I}\bar p_j\) by independence of the roots. Hence
\begin{equation*} \Pr(\mathbf{e}) \;=\; \Bigl(\prod_{D_j \in \mathbf{F}} \bar p_j\Bigr) \sum_{I \subseteq T} (-1)^{|I|} \prod_{D_j \in \mathbf{U}_I} \bar p_j . \tag{\(\ast\ast\)} \end{equation*}
(Contradictory evidence – some \(\alpha_{i_0}^{\prime}\) empty – gives \(\mathbf{U}_{I \cup \{i_0\}} = \mathbf{U}_I\), so terms cancel in pairs and \((\ast\ast)\) returns \(0\).) For the joint, \(\Pr(D_j = \text{true},\mathbf{e}) = 0\) when \(D_j \in \mathbf{F}\); otherwise clamping \(D_j\) true contributes \(p_j\) and satisfies \(\alpha_i^{\prime}\) for every \(i \in T\) with \(D_j \in \mathbf{Pa}(S_i)\), leaving \(T_j = \{i \in T : D_j \notin \mathbf{Pa}(S_i)\}\), whose sets \(\mathbf{U}_I\) never contain \(D_j\):
\begin{equation*} \begin{aligned} \Pr(D_j = \text{true}, \mathbf{e}) \;=\; &\; p_j \Bigl(\prod_{D_l \in \mathbf{F}} \bar p_l\Bigr)\\ &\times \sum_{I \subseteq T_j} (-1)^{|I|} \prod_{D_l \in \mathbf{U}_I} \bar p_l , \end{aligned} \end{equation*}
with \(\Pr(D_j \mid \mathbf{e})\) the ratio of the two. Each of the \(2^m\) terms costs \(O(k)\) – mark the parents of the \(S_i\), \(i \in I\), in a Boolean array indexed by roots and read \(\prod_{D_j\in\mathbf{U}_I}\bar p_j\) off in one scan – so \(\Pr(\mathbf{e})\) and the joint both cost \(O(k\exp(m))\).
Consider Exercise 13.19. Show that the same complexity still holds if each node \(S_i\) is a noisy-or of its parents.
That is, the network is again two-layer: binary roots \(D_1,\dots,D_n\) with priors \(p_j = \Pr(D_j = \text{true})\), binary leaves \(S_1,\dots,S_p\) with \(\mathbf{Pa}(S_i) \subseteq \{D_1,\dots,D_n\}\) and \(k = \sum_i |\mathbf{Pa}(S_i)|\) edges. But now each leaf is a noisy-or (Section 5.4.1) with a suppressor probability \(q_{ij} \in [0,1]\) for each edge \(D_j \to S_i\) and a leak probability \(l_i \in [0,1]\) for \(S_i\), so that by Equation 5.2
\begin{equation*} \Pr(\bar s_i \mid \mathbf{d}) \;=\; (1 - l_i) \!\!\prod_{\substack{D_j \in \mathbf{Pa}(S_i) \\ d_j = \text{true}}}\!\! q_{ij}. \end{equation*}
Let \(\mathbf{e}\) be evidence on the nodes \(S_i\) and let \(m\) be the number of them set to true. Show that \(\Pr(D_j \mid \mathbf{e})\) can still be computed in \(O(k\exp(m))\).
Formula \((\dagger)\) below evaluates \(\Pr(\mathbf{e})\) in \(2^m\) terms of cost \(O(k)\) each. Pruning is unavailable – a false noisy-or with nonzero suppressors does not force its parents false – but the property actually needed survives: \(\Pr(\bar s_i\mid\mathbf{d})\) is a product over the parents, one factor per parent, each depending on that parent alone. As before \(\mathbf{e}\) sets \(S_i\) false for \(i \in N\) and true for \(i \in T\) with \(|T| = m\), unobserved leaves are barren, \(\bar p_j = 1 - p_j\), and for a set \(J\) of leaves
\begin{equation*} Q_j(J) \;=\; \prod_{\substack{i \in J \\ D_j \in \mathbf{Pa}(S_i)}} q_{ij} \end{equation*}
collects the suppressors on the edges from \(D_j\) into \(J\) (empty product \(= 1\)). The network factorisation gives \(\Pr(\mathbf{e}) = \sum_{\mathbf{d}}\Pr(\mathbf{d})\prod_{i\in N}\Pr(\bar s_i\mid\mathbf{d})\prod_{i\in T}(1 - \Pr(\bar s_i\mid\mathbf{d}))\); expanding the last product term by term (inclusion-exclusion, as in Exercise 13.19) and interchanging the sums,
\begin{equation*} \Pr(\mathbf{e}) \;=\; \sum_{I \subseteq T} (-1)^{|I|}\, W(N \cup I), \qquad W(J) \;=\; \sum_{\mathbf{d}} \Pr(\mathbf{d}) \prod_{i \in J} \Pr(\bar s_i \mid \mathbf{d}). \end{equation*}
By the noisy-or CPTs and root independence each \(W(J)\) decomposes over the roots,
\begin{equation*} \begin{aligned} W(J) &= \sum_{\mathbf{d}} \prod_{j=1}^{n}\Pr(d_j) \prod_{i \in J} (1-l_i) \!\!\prod_{\substack{D_j \in \mathbf{Pa}(S_i)\\ d_j = \text{true}}}\!\! q_{ij}\\ &= \Bigl(\prod_{i \in J}(1-l_i)\Bigr) \sum_{\mathbf{d}} \prod_{j=1}^{n} \Pr(d_j)\, Q_j(J)^{[\,d_j = \text{true}\,]} \\ &= \Bigl(\prod_{i \in J}(1-l_i)\Bigr) \prod_{j=1}^{n} \bigl(\bar p_j + p_j\, Q_j(J)\bigr). \end{aligned} \end{equation*}
the second line regrouping the suppressors by root rather than by leaf, the third distributing (legitimate: the summand is a product of \(n\) terms, the \(j\)-th depending on \(d_j\) alone). Hence
\begin{equation*} \Pr(\mathbf{e}) \;=\; \sum_{I \subseteq T} (-1)^{|I|} \Bigl(\prod_{i \in N \cup I}(1-l_i)\Bigr) \prod_{j=1}^{n}\bigl(\bar p_j + p_j\, Q_j(N \cup I)\bigr). \tag{\(\dagger\)} \end{equation*}
Clamping \(D_j = \text{true}\) removes the sum over \(d_j\) and replaces the \(j\)-th bracket by its true half,
\begin{equation*} \begin{aligned} \Pr(D_j = \text{true}, \mathbf{e}) \;=\; \sum_{I \subseteq T} (-1)^{|I|} &\Bigl(\prod_{i \in N \cup I}(1-l_i)\Bigr) p_j\, Q_j(N\cup I)\\ &\times \prod_{l \neq j}\bigl(\bar p_l + p_l\, Q_l(N \cup I)\bigr), \end{aligned} \end{equation*}
and \(\Pr(D_j \mid \mathbf{e})\) is the quotient by \((\dagger)\). Assuming as in Figure 13.4 that every leaf has a parent, so \(m \le p \le k\): for fixed \(I\) and \(J = N\cup I\), all the \(Q_j(J)\) come from one \(O(k)\) pass over the edges incident to \(J\) (and one to undo it), the leak factors number \(|I| \le k\), and the outer product need only run over the at most \(k\) roots with a child, a childless root having \(Q_j \equiv 1\) and bracket \(\bar p_j + p_j = 1\). So each of the \(2^m\) terms costs \(O(k)\) and both quantities cost \(O(k\exp(m))\).
Consider the problem of encoding equal parameters, as discussed in Section 13.3.2. Show that the following technique can be adopted to deal with this problem:
- Do not drop clauses for parameters with value 1.
- Replace each set of equal parameters \(\theta_i\) in the same CPT by a new parameter \(\eta\) and drop all PI clauses of parameters \(\theta_i\).
- Add the following clauses \(\neg\eta_i \vee \neg\eta_j\) for \(i \neq j\) and \(\neg\eta_i \vee \neg\theta_j\) for all \(i,j\). Here \(\eta_1,\dots,\eta_k\) are all the newly introduced parameters to a CPT and \(\theta_1,\dots,\theta_m\) are all surviving old parameters in the CPT.
In particular, show that the old and new CNF encodings agree on their weighted model counts.
Both encodings have weighted model count \(\Pr(\mathbf{e})\) under any evidence, because in each of them every model sets exactly one parameter variable per CPT true, namely the one carrying that CPT’s parameter for the instantiation encoded by the indicators.
In the notation of Section 13.3.1, a CPT with family variables \(F_1,\dots,F_n\) and family instantiation \(\mathbf{f}\) carries a variable \(P_{\mathbf{f}}\) of weight \(\theta_{\mathbf{f}}\), the IP clause \(I_{\mathbf{f}} \Rightarrow P_{\mathbf{f}}\) and the PI clauses \(\neg P_{\mathbf{f}}\vee I_{f_t}\), where \(I_{\mathbf{f}} = I_{f_1}\wedge\dots\wedge I_{f_n}\); all other literals weigh \(1\). Both \(\Delta\) (Section 13.3.2) and \(\Delta^{\prime}\) replace a zero parameter by \(\neg I_{f_1}\vee\dots\vee\neg I_{f_n}\); \(\Delta\) then drops value-\(1\) parameters and encodes a merged group by \((I_{\mathbf{f}_1}\vee\dots\vee I_{\mathbf{f}_m}) \iff \eta\), while \(\Delta^{\prime}\) gives each merged group \(G\) one \(\eta\) of the common weight (keeping each IP clause with \(P_{\mathbf{f}}\) renamed to \(\eta\), dropping the PI clauses of \(\mathbf{f}\in G\)), keeps every unmerged parameter with all its clauses – value-\(1\) ones included – and adds \(\neg\eta_i\vee\neg\eta_j\) (\(i\neq j\)) and \(\neg\eta_i\vee\neg P_{\mathbf{g}_j}\).
So each \(\mathbf{f}\) with \(\theta_{\mathbf{f}} \neq 0\) has exactly one variable \(\nu(\mathbf{f})\) in \(\Delta^{\prime}\) – the \(\eta_i\) of its group, or \(P_{\mathbf{f}}\) – of weight \(\theta_{\mathbf{f}}\) and subject to \(I_{\mathbf{f}} \Rightarrow \nu(\mathbf{f})\); this is what the first bullet buys, a dropped value-\(1\) parameter leaving \(\mathbf{f}\) with no variable at all.
Lemma. If \(A \models \Delta^{\prime}\) has indicators encoding the network instantiation \(\mathbf{z}\), and \(\mathbf{f}^\star\) is the family instantiation \(\mathbf{z}\) induces in a given CPT, then \(\theta_{\mathbf{f}^\star} \neq 0\) and \(A\) sets \(\nu(\mathbf{f}^\star)\) true and every other parameter variable of that CPT false.
Were \(\theta_{\mathbf{f}^\star} = 0\), the clause \(\neg I_{f^\star_1}\vee\dots\vee\neg I_{f^\star_n}\) would be falsified; so \(\nu = \nu(\mathbf{f}^\star)\) exists and \(I_{\mathbf{f}^\star}\Rightarrow\nu\) forces \(A(\nu) = \text{true}\). Any surviving \(P_{\mathbf{g}_j}\), \(\mathbf{g}_j \neq \mathbf{f}^\star\), is false because its retained PI clauses imply an indicator of \(\mathbf{g}_j\) that \(\mathbf{z}\) falsifies – which is why no \(\neg P_{\mathbf{g}_i}\vee\neg P_{\mathbf{g}_j}\) is needed. For the rest, by the third bullet (the merged parameters having no PI clauses, nothing else would stop a gratuitous \(\eta_i\)):
- (i) \(\nu = \eta_{i_0}\): every other \(\eta_i\) is false by \(\neg\eta_i\vee\neg\eta_{i_0}\), and every \(P_{\mathbf{g}_j}\) by \(\neg\eta_{i_0}\vee\neg P_{\mathbf{g}_j}\).
- (ii) \(\nu = P_{\mathbf{f}^\star}\): every \(\eta_i\) is false by \(\neg\eta_i\vee\neg P_{\mathbf{f}^\star}\).
For any evidence \(\mathbf{e}\), models of \(\Delta^{\prime}\) then biject with the instantiations \(\mathbf{z}\) having no zero parameter: the indicator clauses make \(A\) encode a unique \(\mathbf{z}\), and conversely \(A_{\mathbf{z}}\) – indicators per \(\mathbf{z}\), \(\nu(\mathbf{f}^\star)\) true in each CPT, all other parameter variables false – satisfies \(\Delta^{\prime}\):
- indicator clauses: immediate;
- zero-parameter clauses \(\neg I_{f_1}\vee\dots\vee\neg I_{f_n}\): here \(\mathbf{f} \neq \mathbf{f}^\star\) because \(\theta_{\mathbf{f}}= 0 \neq \theta_{\mathbf{f}^\star}\), so some indicator of \(\mathbf{f}\) is false;
- IP clauses \(I_{\mathbf{f}} \Rightarrow \nu(\mathbf{f})\): for \(\mathbf{f} \neq \mathbf{f}^\star\) the antecedent is false; for \(\mathbf{f} = \mathbf{f}^\star\) the consequent is true;
- PI clauses of surviving old parameters: the only such variable set true is \(P_{\mathbf{f}^\star}\) (when \(\mathbf{f}^\star\) was not merged), and all indicators of \(\mathbf{f}^\star\) are true;
- the added binary clauses: at most one parameter variable per CPT is true.
and by the Lemma it is the only such model. The evidence literals restrict to the \(\mathbf{z}\) compatible with \(\mathbf{e}\), and since indicator literals and negative parameter literals weigh \(1\),
\begin{equation*} \text{weight}(A_{\mathbf{z}}) \;=\; \prod_{\text{CPTs}} \theta_{\mathbf{f}^\star} \;=\; \Pr(\mathbf{z}), \end{equation*}
by the chain rule, and instantiations discarded for a zero parameter have \(\Pr(\mathbf{z}) = 0\) and may be added back for free. Therefore
\begin{equation*} \text{WMC}\bigl(\Delta^{\prime} \wedge I_{e_1}\wedge\dots\wedge I_{e_r}\bigr) \;=\; \sum_{\mathbf{z} \sim \mathbf{e}} \Pr(\mathbf{z}) \;=\; \Pr(\mathbf{e}). \end{equation*}
The same argument applied to \(\Delta\) – where \((I_{\mathbf{f}_1}\vee\dots\vee I_{\mathbf{f}_m})\iff\eta\) forces \(\eta\) true exactly when \(\mathbf{z}\) realises a merged instantiation, and a dropped value-\(1\) parameter contributes the factor \(1\) it should – gives \(\text{WMC}(\Delta\wedge I_{e_1}\wedge\dots\wedge I_{e_r}) = \Pr(\mathbf{e})\) as well, so the two encodings agree.
Exercises 13.22–13.22
Consider the problem of encoding equal parameters as discussed in Section 13.3.2.
Recall the CNF encoding of a Bayesian network from Sections 11.6.1 and 13.3.1. It uses an indicator variable \(I_x\) for each network variable \(X\) and value \(x\), and a parameter variable \(P_{x|\mathbf{u}}\) for each network parameter \(\theta_{x|\mathbf{u}}\). Its clauses are the indicator clauses, which say that exactly one indicator of each variable \(X\) is true,
\begin{equation*} I_{x_1} \vee \ldots \vee I_{x_k}, \qquad \neg I_{x_i} \vee \neg I_{x_j} \ (i \neq j), \end{equation*}
together with the parameter clauses, one group per parameter,
\begin{equation*} I_{u_1} \wedge \ldots \wedge I_{u_p} \wedge I_x \iff P_{x|\mathbf{u}} , \qquad \mathbf{u} = u_1, \ldots, u_p . \end{equation*}
The left-to-right direction of the last equivalence is a single clause, \(\neg I_{u_1} \vee \ldots \vee \neg I_{u_p} \vee \neg I_x \vee P_{x|\mathbf{u}}\), called the IP clause of the parameter; the right-to-left direction is the set of binary PI clauses \(\neg P_{x|\mathbf{u}} \vee I_{u_i}\) and \(\neg P_{x|\mathbf{u}} \vee I_x\). Literals \(I_x\), \(\neg I_x\) and \(\neg P_{x|\mathbf{u}}\) have weight \(1\), and literal \(P_{x|\mathbf{u}}\) has weight \(\theta_{x|\mathbf{u}}\).
Consider the following technique for dealing with equal parameters:
- Do not drop clauses for parameters with value 1.
- Replace each set of equal parameters \(\theta_i\) in the same CPT by a new parameter \(\eta\) and drop all the PI clauses of parameters \(\theta_i\).
Let \(f\) be the MLF encoded by the resulting CNF \(\Delta\). Recall from Section 12.4.3 that a CNF encodes an MLF by interpreting each of its models \(\omega\) as the term containing exactly those variables that \(\omega\) sets to true, and summing these terms; and recall from Exercise 12.20 that a term of \(f\) is minimal if the number of variables it contains is minimal among the terms of \(f\). Show that the minimal terms of \(f\) correspond to the network polynomial. Hence, when coupled with the procedure of Exercise 12.20, this method can be used as an alternative for exploiting equal parameters.
Every complete instantiation forces exactly \(n\) class variables, so every term of \(f\) has size at least \(2n\), and the terms of size exactly \(2n\) are one per complete instantiation – the network polynomial with each parameter replaced by its class variable.
Let \(N\) have \(n\) variables with families \(X_iU_i\), and \(\mathbf{z}\) range over complete instantiations. Partition each CPT’s parameters into classes of equal value, replacing each class of size \(\ge 2\) by a new variable (these are \(\eta_1,\ldots,\eta_K\), collected in \(H\)) and leaving singletons with their old \(P_{x|\mathbf{u}}\); write \(c(x\mathbf{u})\) for the variable now representing \(\theta_{x|\mathbf{u}}\) and \(w(v)\) for the value a class variable \(v\) carries. So \(\Delta\) is the indicator clauses, one IP clause \(\neg I_{u_1}\vee\ldots\vee\neg I_{u_p}\vee\neg I_x\vee c(x\mathbf{u})\) per family instantiation – none missing, since by the first bullet a value-\(1\) parameter still contributes one – and the PI clauses of the unmerged parameters only.
A model \(\omega\) sets exactly one indicator per network variable true, determining a complete instantiation \(\mathbf{z}_\omega\), and conversely. Fixing \(\mathbf{z}\), the IP clause of \(x\mathbf{u}\) has all its negative literals falsified precisely when \(x\mathbf{u}\sim\mathbf{z}\) and is otherwise already satisfied, so the IP clauses force exactly the variables in
\begin{equation*} E(\mathbf{z}) \;=\; \{\, c(x\mathbf{u}) \;:\; x\mathbf{u} \sim \mathbf{z} \,\}, \end{equation*}
and since classes are formed within a single CPT (distinct CPTs never share a class variable) while \(\mathbf{z}\) is compatible with exactly one family instantiation of each of the \(n\) families, \(|E(\mathbf{z})| = n\) for every \(\mathbf{z}\) – the crux. The surviving PI clauses allow \(P_{x|\mathbf{u}}\) true only when \(x\mathbf{u}\sim\mathbf{z}\), i.e. only when it already lies in \(E(\mathbf{z})\), so unmerged variables outside \(E(\mathbf{z})\) are forced false and the merged ones in \(H\setminus E(\mathbf{z})\) are free. Thus
\begin{equation*} \omega \;\longleftrightarrow\; (\mathbf{z}, S), \qquad \mathbf{z} \text{ a complete instantiation}, \quad E(\mathbf{z}) \subseteq S \subseteq E(\mathbf{z}) \cup H, \end{equation*}
with \(S\) the parameter variables \(\omega\) sets true. The term encoded by \(\omega\) (Section 12.4.3) is
\begin{equation*} t_{\mathbf{z},S} \;=\; \Bigl(\prod_{x \sim \mathbf{z}} I_x\Bigr) \prod_{v \in S} v , \end{equation*}
of size \(n + |S|\), distinct models giving distinct terms. From \(|E(\mathbf{z})| = n\) and \(E(\mathbf{z}) \subseteq S\),
\begin{equation*} |t_{\mathbf{z},S}| \;=\; n + |S| \;\ge\; n + |E(\mathbf{z})| \;=\; 2n , \end{equation*}
with equality iff \(S = E(\mathbf{z})\), and \((\mathbf{z}, E(\mathbf{z}))\) is always a model (it satisfies every IP clause, and each unmerged variable it sets true is compatible with \(\mathbf{z}\), hence satisfies its PI clauses). So the minimal terms of \(f\) are the terms of size \(2n\), one per complete instantiation:
\begin{equation*} t_{\mathbf{z}} \;=\; \prod_{x \sim \mathbf{z}} I_x \;\prod_{x\mathbf{u} \sim \mathbf{z}} c(x\mathbf{u}) . \end{equation*}
By Definition 12.1 the network polynomial is
\begin{equation*} f_N \;=\; \sum_{\mathbf{z}} \; \prod_{\lambda_x \sim \mathbf{z}} \lambda_x \prod_{\theta_{x|\mathbf{u}} \sim \mathbf{z}} \theta_{x|\mathbf{u}} , \end{equation*}
one term per complete instantiation. Under the reading of Section 12.4.3 – \(I_x \mapsto \lambda_x\), each positive parameter literal to the parameter it names – \(t_{\mathbf{z}}\) becomes the term of \(\mathbf{z}\) in \(f_N\) with every parameter replaced by its class variable (the polynomial of Exercise 12.19), and substituting \(w(v)\) for each class variable recovers that term verbatim, since \(c(x\mathbf{u})\) carries the value \(\theta_{x|\mathbf{u}}\). Hence the minimal terms of \(f\) – equivalently \(f_m\) of Exercise 12.20 – correspond one-to-one to the terms of \(f_N\), as required. (No term repeats a variable: classes live within a CPT and \(\mathbf{z}\) selects one row of each.)
Coupling with Exercise 12.20: compile \(\Delta\) into a decomposable, deterministic, smooth NNF \(\Gamma\) and run Exercise 2.13’s pruning in dual form – \(1\) at positive-literal inputs, \(0\) at negative-literal and \(\text{true}\) inputs, \(\infty\) at \(\text{false}\), sum at and-nodes, minimum at or-nodes, then delete every or-edge to a child of different integer – whose argument applies verbatim with polarities exchanged, so \(\Gamma_m\) has as models exactly those of \(\Gamma\) setting fewest variables true (smoothness making this well defined) and inherits all three properties. By Exercise 12.17 the substitutions of Section 12.4.3 turn \(\Gamma_m\) into an arithmetic circuit for \(f_m\), hence for the network polynomial with each equality class carried by its single \(\eta_j\).
Illustration on Figure 13.1, with structure \(A \rightarrow B\), \(A \rightarrow C\), all variables binary, and CPTs
| \(A\) | \(\theta_A\) |
|---|---|
| true | .5 |
| false | .5 |
| \(A\) | \(B\) | \(\theta_{B \mid A}\) |
|---|---|---|
| true | true | 1 |
| true | false | 0 |
| false | true | 0 |
| false | false | 1 |
| \(A\) | \(C\) | \(\theta_{C \mid A}\) |
|---|---|---|
| true | true | .8 |
| true | false | .2 |
| false | true | .2 |
| false | false | .8 |
Here \(n = 3\), and the classes are \(\eta_1 = \{\theta_{c|a},\theta_{\bar c|\bar a}\}\) at \(.8\), \(\eta_2 = \{\theta_{\bar c|a},\theta_{c|\bar a}\}\) at \(.2\), \(\eta_3 = \{\theta_a,\theta_{\bar a}\}\) at \(.5\), \(\eta_4 = \{\theta_{b|a},\theta_{\bar b|\bar a}\}\) at \(1\), \(\eta_5 = \{\theta_{\bar b|a},\theta_{b|\bar a}\}\) at \(0\), so \(K = 5\) and no PI clause survives. Besides the six indicator clauses, \(\Delta\) has the ten IP clauses
\begin{equation*} \begin{aligned} &\neg I_a \vee \eta_3, && \neg I_{\bar a} \vee \eta_3, \\ &\neg I_a \vee \neg I_b \vee \eta_4, && \neg I_{\bar a} \vee \neg I_{\bar b} \vee \eta_4, \\ &\neg I_a \vee \neg I_{\bar b} \vee \eta_5, && \neg I_{\bar a} \vee \neg I_b \vee \eta_5, \\ &\neg I_a \vee \neg I_c \vee \eta_1, && \neg I_{\bar a} \vee \neg I_{\bar c} \vee \eta_1, \\ &\neg I_a \vee \neg I_{\bar c} \vee \eta_2, && \neg I_{\bar a} \vee \neg I_c \vee \eta_2 . \end{aligned} \end{equation*}
So \(\Delta\) has \(8 \cdot 2^{5-3} = 32\) models and exactly \(8\) minimal terms, of size \(2n = 6\), one per instantiation of \(A,B,C\): \(\mathbf{z} = a,b,c\) gives true variables \(I_a, I_b, I_c, \eta_1, \eta_3, \eta_4\), hence \(\lambda_a\lambda_b\lambda_c\,\eta_1\eta_3\eta_4 = .8 \cdot .5 \cdot 1 = \Pr(a,b,c)\) (Check!).
Approximate Inference by Belief Propagation
Exercises 14.1–14.7
Consider the Bayesian network of Figure 14.17 and suppose that we condition on evidence \(e : D = \text{true}\). Suppose that we have run Algorithm 40, IBP, on the network, where it converges and yields the (partial) set of messages and family marginals given in Figure 14.18.
Figure 14.17. The network has four binary variables. The roots are \(A\) and \(B\); the leaves are \(C\) and \(D\); the edges are \(A \to C\), \(B \to C\), \(A \to D\), \(B \to D\). Its CPTs are:
| \(A\) | \(\Theta_A\) |
|---|---|
| true | .5 |
| false | .5 |
| \(B\) | \(\Theta_B\) |
|---|---|
| true | .25 |
| false | .75 |
| \(A\) | \(B\) | \(C\) | \(\Theta_{C \mid AB}\) |
|---|---|---|---|
| true | true | true | .9 |
| true | true | false | .1 |
| true | false | true | .8 |
| true | false | false | .2 |
| false | true | true | .7 |
| false | true | false | .3 |
| false | false | true | .6 |
| false | false | false | .4 |
| \(A\) | \(B\) | \(D\) | \(\Theta_{D \mid AB}\) |
|---|---|---|---|
| true | true | true | .6 |
| true | true | false | .4 |
| true | false | true | .4 |
| true | false | false | .6 |
| false | true | true | .3 |
| false | true | false | .7 |
| false | false | true | .3 |
| false | false | false | .7 |
Figure 14.18 (partial IBP messages and marginal approximations; a dash marks a missing entry):
| \(A\) | \(\pi_C(A)\) | \(\pi_D(A)\) | \(\lambda_C(A)\) | \(\lambda_D(A)\) |
|---|---|---|---|---|
| true | – | .5 | .5 | .6 |
| false | – | .5 | .5 | .4 |
| \(B\) | \(\pi_C(B)\) | \(\pi_D(B)\) | \(\lambda_C(B)\) | \(\lambda_D(B)\) |
|---|---|---|---|---|
| true | .3 | .25 | .5 | – |
| false | .7 | .75 | .5 | – |
| \(A\) | \(B\) | \(C\) | \(BEL(ABC)\) |
|---|---|---|---|
| true | true | true | .162 |
| true | true | false | .018 |
| true | false | true | – |
| true | false | false | .084 |
| false | true | true | .084 |
| false | true | false | .036 |
| false | false | true | .168 |
| false | false | false | .112 |
| \(A\) | \(B\) | \(D\) | \(BEL(ABD)\) |
|---|---|---|---|
| true | true | true | .2 |
| true | true | false | 0 |
| true | false | true | – |
| true | false | false | 0 |
| false | true | true | .1 |
| false | true | false | 0 |
| false | false | true | .3 |
| false | false | false | 0 |
(a) Fill in the missing values for IBP messages in Figure 14.18.
(b) Fill in the missing values for family marginals in Figure 14.18.
(c) Compute marginals \(BEL(A)\) and \(BEL(B)\) using the IBP messages in Figure 14.18 and those computed in (a).
(d) Compute marginals \(BEL(A)\) and \(BEL(B)\) by summing out the appropriate variables from the family marginals \(BEL(ABC)\) as well as \(BEL(ABD)\).
(e) Compute the joint marginal \(BEL(AB)\) by summing out the appropriate variables from family marginals \(BEL(ABC)\) as well as \(BEL(ABD)\).
Are the marginals computed in (d) consistent? What about those computed in (e)?
The missing entries are \(\pi_C(A) = (.6,.4)\), \(\lambda_D(B) = (.5625,.4375)\), \(BEL(atbfct) = .336\) and \(BEL(atbfdt) = .4\); the node marginals agree across families, the joint marginals on \(AB\) do not. Write \(\lambda_e\) for the evidence indicator (\(\lambda_e(D) = (1,0)\), \(\lambda_e \equiv 1\) elsewhere).
(a) By Algorithm 40 (line 10) at the root \(A\), with \(\Theta_A = (.5,.5)\) and \(\lambda_D(A) = (.6,.4)\),
\begin{equation*} \pi_C(A) \;=\; \eta\, \lambda_e(A)\,\Theta_A\,\lambda_D(A) \;=\; \eta\,(.30,\;.20) \;=\; (.6,\;.4), \end{equation*}
and the same equation returns the printed \(\pi_D(A) = \eta\,\Theta_A\lambda_C(A) = (.5,.5)\). By line 7, \(\lambda_D(B) = \eta\sum_{A,D}\lambda_e(D)\Theta_{D\mid AB}\pi_D(A)\), the indicator killing every \(D = \text{false}\) row, so with \(\pi_D(A) = (.5,.5)\),
\begin{equation*} \begin{aligned} \lambda_D(B=\text{true}) &= \eta\,[\,.5(.6) + .5(.3)\,] = \eta\,(.45),\\ \lambda_D(B=\text{false}) &= \eta\,[\,.5(.4) + .5(.3)\,] = \eta\,(.35). \end{aligned} \end{equation*}
i.e. \(\lambda_D(B) = (.45,.35)/.80 = (.5625,.4375)\), which reproduces the printed \(\pi_C(B) = \eta\,\Theta_B\lambda_D(B) = \eta(.140625,.328125) = (.3,.7)\). Completed:
| \(A\) | \(\pi_C(A)\) | \(\pi_D(A)\) | \(\lambda_C(A)\) | \(\lambda_D(A)\) |
|---|---|---|---|---|
| true | .6 | .5 | .5 | .6 |
| false | .4 | .5 | .5 | .4 |
| \(B\) | \(\pi_C(B)\) | \(\pi_D(B)\) | \(\lambda_C(B)\) | \(\lambda_D(B)\) |
|---|---|---|---|---|
| true | .3 | .25 | .5 | .5625 |
| false | .7 | .75 | .5 | .4375 |
(b) Line 14 of Algorithm 40 gives \(BEL(ABC) = \eta\,\lambda_e( C)\Theta_{C\mid AB}\pi_C(A)\pi_C(B)\) (\(C\) has no children, hence no \(\lambda\) factors). The products \(\pi_C(a)\pi_C(b)\) are \(.18,.42,.12,.28\) for \(ab = tt,tf,ft,ff\) and already sum to \(1\), so \(\eta = 1\) and the missing entry is \(.42\times .8 = .336\), the printed entries following likewise (Check!). Similarly \(BEL(ABD) = \eta\,\lambda_e(D)\Theta_{D\mid AB}\pi_D(A)\pi_D(B)\), all \(D = \text{false}\) rows vanishing; with \(\pi_D(A) = (.5,.5)\), \(\pi_D(B) = (.25,.75)\) the unnormalized \(D = \text{true}\) entries are
\begin{equation*} \begin{aligned} ab=tt:&\; .5(.25)(.6) = .075, & ab=tf:&\; .5(.75)(.4) = .150,\\ ab=ft:&\; .5(.25)(.3) = .0375, & ab=ff:&\; .5(.75)(.3) = .1125, \end{aligned} \end{equation*}
summing to \(.375\), so the missing entry is \(.150/.375 = .4\) and the printed \(.2,.1,.3\) follow. Completed:
| \(A\) | \(B\) | \(C\) | \(BEL(ABC)\) |
|---|---|---|---|
| true | true | true | .162 |
| true | true | false | .018 |
| true | false | true | .336 |
| true | false | false | .084 |
| false | true | true | .084 |
| false | true | false | .036 |
| false | false | true | .168 |
| false | false | false | .112 |
| \(A\) | \(B\) | \(D\) | \(BEL(ABD)\) |
|---|---|---|---|
| true | true | true | .2 |
| true | true | false | 0 |
| true | false | true | .4 |
| true | false | false | 0 |
| false | true | true | .1 |
| false | true | false | 0 |
| false | false | true | .3 |
| false | false | false | 0 |
(c) A root’s family is the variable itself, so line 14 gives
\begin{equation*} \begin{aligned} BEL(A) &= \eta\,\Theta_A\lambda_C(A)\lambda_D(A) = \eta\,(.15,\;.10) = (.6,\;.4),\\ BEL(B) &= \eta\,\Theta_B\lambda_C(B)\lambda_D(B)\\ &= \eta\,(.0703125,\;.1640625) = (.3,\;.7). \end{aligned} \end{equation*}
(d) From \(BEL(ABC)\):
\begin{equation*} \begin{aligned} BEL(A=\text{true}) &= .162+.018+.336+.084 = .6,\\ BEL(A=\text{false}) &= .084+.036+.168+.112 = .4,\\ BEL(B=\text{true}) &= .162+.018+.084+.036 = .3,\\ BEL(B=\text{false}) &= .336+.084+.168+.112 = .7. \end{aligned} \end{equation*}
From \(BEL(ABD)\):
\begin{equation*} \begin{aligned} BEL(A=\text{true}) &= .2 + .4 = .6, & BEL(A=\text{false}) &= .1+.3 = .4,\\ BEL(B=\text{true}) &= .2 + .1 = .3, & BEL(B=\text{false}) &= .4+.3 = .7. \end{aligned} \end{equation*}
(e) Summing \(C\) out of \(BEL(ABC)\) and \(D\) out of \(BEL(ABD)\):
| \(A\) | \(B\) | from \(BEL(ABC)\) | from \(BEL(ABD)\) |
|---|---|---|---|
| true | true | .18 | .2 |
| true | false | .42 | .4 |
| false | true | .12 | .1 |
| false | false | .28 | .3 |
The marginals of (d) are consistent – both families and the messages of (c) give \(BEL(A) = (.6,.4)\), \(BEL(B) = (.3,.7)\) – as an IBP fixed point must be, by the constraints \(\sum_{xu \sim y}\mu_{xu} = \mu_y\) of Theorem 14.2. Those of (e) are not: \(.18\) against \(.2\) at \(A = B = \text{true}\). Theorem 14.2 constrains only single shared variables, never shared sets, so nothing forces the two projections onto \(AB\) to agree.
Consider the following function,
\begin{equation*} f(x) \;=\; \frac{-.21x + .42}{-.12x + .54} \end{equation*}
and the problem of identifying a fixed point \(x^\star\),
\begin{equation*} x^\star = f(x^\star) \end{equation*}
using fixed point iteration. We start with some initial value \(x_0\), then at a given iteration \(t > 0\) we update our current value \(x_t\) using the value \(x_{t-1}\) from the previous iteration:
\begin{equation*} x_t = f(x_{t-1}). \end{equation*}
Starting with \(x_0 = .2\), we have \(x_1 \approx .7326\) and \(x_2 \approx .5887\). In this particular example, repeated iterations will approach the desired solution \(x^\star\).
(a) Continue evaluating \(x_t\) for \(t \ge 3\) until the four most significant digits stop changing.
Consider next the Bayesian network of Figure 14.19 and the problem of identifying a parameter \(\theta\) defining the CPT \(\Theta_{\hat{A}}\), such that
\begin{equation*} \theta = \Pr(A = \text{true} \mid e). \end{equation*}
Figure 14.19. A network over three binary variables \(A\), \(\hat{A}\), \(B\) with edges \(A \to B\) and \(\hat{A} \to B\), under evidence \(e : B = \text{true}\). Its CPTs are:
| \(A\) | \(\Theta_A\) |
|---|---|
| true | .7 |
| false | .3 |
| \(\hat{A}\) | \(\Theta_{\hat{A}}\) |
|---|---|
| true | \(\theta\) |
| false | \(1-\theta\) |
| \(A\) | \(\hat{A}\) | \(B\) | \(\Theta_{B \mid A\hat{A}}\) |
|---|---|---|---|
| true | true | true | .3 |
| true | true | false | .7 |
| true | false | true | .6 |
| true | false | false | .4 |
| false | true | true | .7 |
| false | true | false | .3 |
| false | false | true | .4 |
| false | false | false | .6 |
(b) Suppose we set \(\theta = .2\). What is \(\Pr(A = \text{true} \mid e)\)? Suppose we now reset \(\theta\) to \(\Pr(A = \text{true} \mid e)\). What is the new value of \(\Pr(A = \text{true} \mid e)\)?
(c) Design a fixed point iterative method to find such a \(\theta\).
(a) The iterates freeze at \(x_t = .6219\) from \(t = 7\) on (four significant digits):
| \(t\) | \(x_t\) |
|---|---|
| 0 | .2000 |
| 1 | .7326 |
| 2 | .5887 |
| 3 | .6314 |
| 4 | .6191 |
| 5 | .6227 |
| 6 | .6216 |
| 7 | .6219 |
| 8 | .6219 |
| 9 | .6219 |
The limit is exact: \(x = f(x)\) reads \(4x^2 - 25x + 14 = 0\), and of the roots \((25\pm\sqrt{401})/8\) only \(x^\star = (25-\sqrt{401})/8 \approx .621877\) lies in \([0,1]\).
(b) With \(A\) and \(\hat A\) independent roots and \(B\) their common child under \(e : B = \text{true}\),
\begin{equation*} \begin{aligned} \Pr(A{=}\text{t}, e) &= \Theta_A(\text{t}) \sum_{\hat{a}} \Theta_{\hat{A}}(\hat{a})\, \theta_{b \mid \text{t},\hat{a}}\\ &= .7\,[\,\theta(.3) + (1-\theta)(.6)\,]\\ &= .7\,(.6 - .3\theta) = .42 - .21\theta, \end{aligned} \end{equation*}
and likewise \(\Pr(A{=}\text{f}, e) = .3(.4 + .3\theta) = .12 + .09\theta\). Adding, \(\Pr(e) = .54 - .12\theta\), and therefore
\begin{equation*} \Pr(A = \text{true} \mid e) \;=\; \frac{.42 - .21\theta}{.54 - .12\theta} \;=\; \frac{-.21\theta + .42}{-.12\theta + .54} \;=\; f(\theta), \end{equation*}
the function \(f\) of part (a). So \(\theta = .2\) gives \(f(.2) = .378/.516 \approx .7326\), and resetting \(\theta = .7326\) gives \(f(.7326) \approx .5887\).
(c) The requirement is the fixed-point equation \(\theta = f(\theta)\), so iterate: start from any \(\theta_0 \in [0,1]\) (ED BP initializes at \(.5\)); at step \(t\) run exact inference in Figure 14.19 with \(\Theta_{\hat A}\) set to \(\theta_{t-1}\) and put \(\theta_t = \Pr_{\theta_{t-1}}(A = \text{true}\mid e)\); stop when \(|\theta_t - \theta_{t-1}|\) is below threshold. This is \(\theta_t = f(\theta_{t-1})\) and converges from every \(\theta_0\) to \(\theta^\star \approx .6219\): since
\begin{equation*} f^{\prime}(x) = \frac{(-.21)(.54) - (.42)(-.12)}{(-.12x+.54)^2} = \frac{-.063}{(-.12x + .54)^2}, \end{equation*}
we get \(|f^{\prime}| \le .063/.42^2 = .357 < 1\) on \([0,1]\) (denominator in \([.42,.54]\)), and \(f\), decreasing, maps \([0,1]\) into \([f(1),f(0)] = [.5,.7778]\), so Banach applies. The loop is lines 5–11 of Algorithm 42 with line 8 as the inference step.
Consider the modified belief propagation algorithm (with normalizing constants), applied to a polytree network \(N\) inducing distribution \(\Pr\). For an edge \(U \to X\), let \(e^{+}_{UX}\) be the evidence instantiating nodes on the \(U\)-side of edge \(U \to X\) and let \(e^{-}_{UX}\) be the evidence instantiating nodes on the \(X\)-side of the edge. Prove the following:
\begin{equation*} \pi_X(U) = \Pr(U \mid e^{+}_{UX}), \end{equation*}
\begin{equation*} \lambda_X(U) = \eta \Pr(e^{-}_{UX} \mid U), \end{equation*}
where \(\eta\) is a constant that normalizes message \(\lambda_X(U)\).
Induction on the number of nodes on the relevant side of the edge, the inductive step a regrouping of the chain-rule factorization of that side. The normalized message equations of Section 14.2, for \(X\) with parents \(U = U_1,\ldots,U_m\) and children \(Y_1,\ldots,Y_n\), are
\begin{equation*} \lambda_X(U_i) = \eta \!\!\sum_{XU \setminus \{U_i\}}\!\! \lambda_e(X)\,\Theta_{X \mid U} \prod_{k \ne i}\pi_X(U_k) \prod_j \lambda_{Y_j}(X), \end{equation*}
\begin{equation*} \pi_{Y_j}(X) = \eta \sum_{U} \lambda_e(X)\,\Theta_{X \mid U} \prod_i \pi_X(U_i) \prod_{k \ne j}\lambda_{Y_k}(X), \end{equation*}
with \(\lambda_e\) the evidence indicator and each \(\eta\) normalizing to sum one. Call \(\mathbf{V}\) parent-closed if every parent of every \(V \in \mathbf{V}\) lies in \(\mathbf{V}\), and parent-closed modulo \(Z \notin \mathbf{V}\) if every such parent lies in \(\mathbf{V}\cup\{Z\}\).
Lemma. If \(\mathbf{V}\) is parent-closed modulo \(Z\) and no member of \(\mathbf{V}\) is an ancestor of \(Z\), then
\begin{equation*} \Pr(\mathbf{V} \mid Z) = \prod_{V \in \mathbf{V}} \Theta_{V \mid \mathbf{Pa}(V)} . \end{equation*}
(If \(\mathbf{V}\) is parent-closed outright, the identity holds without the conditioning and without the ancestor proviso.)
Proof. \(\mathbf{V}\), \(\{Z\}\), \(\mathrm{An}(Z)\) are pairwise disjoint and \(\mathbf{W} = \mathbf{V}\cup\{Z\}\cup\mathrm{An}(Z)\) is parent-closed, so summing the chain rule \(\Pr(\mathbf{X}) = \prod_X\Theta_{X\mid\mathbf{Pa}(X)}\) over \(\mathbf{X}\setminus\mathbf{W}\) gives \(\Pr(\mathbf{W}) = \prod_{V\in\mathbf{W}}\Theta_{V\mid\mathbf{Pa}(V)}\) (each summed-out variable is a non-parent of everything retained, so its CPT sums to one, innermost first). No factor of a \(\mathbf{V}\)-node mentions a variable of \(\mathrm{An}(Z)\), parents of \(\mathbf{V}\)-nodes lying in \(\mathbf{V}\cup\{Z\}\), so summing over \(\mathrm{An}(Z)\) yields
\begin{equation*} \Pr(\mathbf{V}, Z) = \Big(\prod_{V \in \mathbf{V}} \Theta_{V \mid \mathbf{Pa}(V)}\Big)\Pr(Z), \end{equation*}
and dividing by \(\Pr(Z)\) gives the claim. \(\square\)
Deleting \(U \to X\) from the skeleton splits \(N\) into the \(U\)-side \(\mathbf{V}\), parent-closed, and the \(X\)-side \(\mathbf{M}\), parent-closed modulo \(U\); no node of \(\mathbf{M}\) is an ancestor of \(U\), since such a directed path ends with an edge into \(U\), cannot traverse \(U \to X\), and would be a second undirected route between the sides. So the Lemma applies to \(\mathbf{M}\) with \(Z = U\), and to every piece below – each one side of a deleted edge, conditioned on the far endpoint. Here \(e^{+}_{UX}\) is the part of \(e\) in \(\mathbf{V}\) and \(e^{-}_{UX}\) the part in \(\mathbf{M}\), and both claims go by simultaneous induction on the size of the relevant side, legitimately: each message on the right of a message equation crosses an edge with a strictly smaller relevant side.
The \(\pi\) message. Let \(U\) have parents \(W_1,\ldots,W_m\) and children \(X, Y_1,\ldots,Y_n\). Removing \(U\) from \(\mathbf{V}\) disconnects it, again by single-connectedness, into
\begin{equation*} \mathbf{V} \setminus \{U\} \;=\; \biguplus_i \mathbf{V}^{W}_i \;\uplus\; \biguplus_j \mathbf{V}^{Y}_j , \end{equation*}
with \(\mathbf{V}^{W}_i\) the \(W_i\)-side of \(W_i \to U\) and \(\mathbf{V}^{Y}_j\) the \(Y_j\)-side of \(U \to Y_j\). By the Lemma on \(\mathbf{V}\), grouping factors by piece,
\begin{equation*} \begin{aligned} &\Pr(U, e^{+}_{UX}) = \sum_{\mathbf{V}\setminus\{U\}} \prod_{V \in \mathbf{V}} \lambda_e(V)\,\Theta_{V \mid \mathbf{Pa}(V)}\\ &= \lambda_e(U) \sum_{W} \Theta_{U \mid W} \prod_i \Big[\textstyle\sum_{\mathbf{V}^{W}_i \setminus \{W_i\}} \prod \lambda_e \Theta\Big] \prod_j \Big[\textstyle\sum_{\mathbf{V}^{Y}_j} \prod \lambda_e \Theta\Big]\\ &= \lambda_e(U) \sum_{W} \Theta_{U \mid W} \prod_i \Pr(W_i, e^{+}_{W_i U}) \prod_j \Pr(e^{-}_{U Y_j} \mid U), \end{aligned} \end{equation*}
the last line by the Lemma on each piece, the interchange of sum and product legitimate because the pieces are disjoint and share only the fixed \(U\). By the induction hypotheses \(\pi_U(W_i) \propto \Pr(W_i, e^{+}_{W_iU})\) and \(\lambda_{Y_j}(U) = \eta_j\Pr(e^{-}_{UY_j}\mid U)\), the message equation for \(\pi_X(U)\) therefore returns \(\eta^{\prime}\Pr(U, e^{+}_{UX})\) with \(\eta^{\prime}\) independent of \(U\); normalization over \(U\) forces \(\eta^{\prime} = 1/\Pr(e^{+}_{UX})\) and
\begin{equation*} \pi_X(U) = \Pr(U \mid e^{+}_{UX}) . \end{equation*}
The base case \(m = n = 0\) is the same display with empty products: \(\eta\lambda_e(U)\Theta_U = \Pr(U \mid e_U)\), and \(e^{+}_{UX} = e_U\) there.
The \(\lambda\) message. Fix \(U_i \to X\), with \(X\) having parents \(U_1,\ldots,U_m\) and children \(Y_1,\ldots,Y_n\). Removing \(X\) decomposes \(\mathbf{M}\) as
\begin{equation*} \mathbf{M}\setminus\{X\} \;=\; \biguplus_{k \ne i} \mathbf{M}^{k} \;\uplus\; \biguplus_j \mathbf{M}^{j}, \end{equation*}
with \(\mathbf{M}^{k}\) the \(U_k\)-side of \(U_k \to X\) and \(\mathbf{M}^{j}\) the \(Y_j\)-side of \(X \to Y_j\). By the Lemma on \(\mathbf{M}\), parent-closed modulo \(U_i\),
\begin{equation*} \begin{aligned} &\Pr(e^{-}_{U_iX} \mid U_i) = \sum_{\mathbf{M}} \prod_{V \in \mathbf{M}} \lambda_e(V)\,\Theta_{V\mid\mathbf{Pa}(V)}\\ &= \!\!\sum_{XU\setminus\{U_i\}}\!\! \lambda_e(X)\,\Theta_{X\mid U} \prod_{k \ne i}\Pr(U_k, e^{+}_{U_kX}) \prod_j \Pr(e^{-}_{XY_j}\mid X), \end{aligned} \end{equation*}
by the same grouping. Comparing with the equation for \(\lambda_X(U_i)\), and using \(\pi_X(U_k) \propto \Pr(U_k, e^{+}_{U_kX})\) and \(\lambda_{Y_j}(X) \propto \Pr(e^{-}_{XY_j}\mid X)\) with constants independent of \(U_i\),
\begin{equation*} \lambda_X(U_i) = \eta\, \Pr(e^{-}_{U_iX} \mid U_i) \end{equation*}
for the \(\eta\) normalizing \(\lambda_X(U_i)\), independent of \(U_i\). The base case \(m = 1\), \(n = 0\) is direct: \(\lambda_X(U_1) = \eta\sum_X\lambda_e(X)\Theta_{X\mid U_1} = \eta\Pr(e^{-}_{U_1X}\mid U_1)\). \(\square\)
Consider a polytree network \(N\) with families \(XU\) that induces a distribution \(\Pr(\mathbf{X})\).
(a) Prove that the distribution \(\Pr(\mathbf{X} \mid e)\) factorizes as
\begin{equation*} \Pr(\mathbf{X}\mid e) \;=\; \prod_{XU} \frac{\Pr(XU \mid e)}{\prod_{U \in U} \Pr(U \mid e)} . \end{equation*}
(b) Prove that the factorization of (a) is equivalent to
\begin{equation*} \Pr(\mathbf{X}\mid e) \;=\; \prod_{XU} \frac{\Pr(XU \mid e)}{\Pr(X\mid e)^{\,n_X}}, \end{equation*}
where \(n_X\) is the number of children that variable \(X\) has in network \(N\).
(a) The family structure of a polytree is a jointree with single-parent separators, and (a) is then the jointree factorization. Let \(T\) have the variables of \(N\) as nodes, an undirected edge \(X - Y\) per directed edge \(X \to Y\), cluster \(C_X = XU\) at node \(X\) and separator \(S_{XY} = \{X\}\) at edge \(X - Y\); \(T\) is a tree since \(N\) is a polytree, and it is a jointree in the sense of Definition 9.13:
- Every family \(XU\) sits in the cluster \(C_X\).
- (Running intersection.) If \(Z \in C_X \cap C_Y\) then \(Z\) is equal or adjacent to each of \(X, Y\) in the skeleton, so by single-connectedness the unique \(T\)-path from \(X\) to \(Y\) is \(X - Z - Y\) (degenerate when \(Z \in \{X,Y\}\)); every cluster and separator on it contains \(Z\), separators being singletons of their edges’ endpoints.
- Hence \(C_X \cap C_Y = \{X\}\) for an edge \(X - Y\): any further shared variable would force a second path between \(X\) and \(Y\).
Now
\begin{equation*} \Pr(\mathbf{X}\mid e) \;=\; \eta \prod_{XU} \lambda_e(X)\,\Theta_{X\mid U}, \end{equation*}
with each factor \(\lambda_e(X)\Theta_{X\mid U}\) a function of the cluster \(C_X = XU\) alone, so \(\Pr(\mathbf{X}\mid e)\) factorizes over the clusters of \(T\) and Theorem 9.12 gives
\begin{equation*} \Pr(\mathbf{X}\mid e) \;=\; \frac{\prod_{i} \Pr(C_i \mid e)}{\prod_{i-j}\Pr(S_{ij}\mid e)} , \end{equation*}
the general form (14.5). Theorem 9.12 is stated for a network-induced distribution while \(\Pr(\mathbf{X}\mid e)\) is a conditional, so run its induction in the generality used – \(\Pr(\mathbf{X}\mid e) = \prod_i\psi_i(C_i)\) for nonnegative \(\psi_i\) on the clusters of a running-intersection tree, here \(\psi_{C_X} = \lambda_e(X)\Theta_{X\mid U}\) with \(\eta\) folded in. One cluster is trivial; otherwise take a leaf \(\ell\) with neighbour \(p\), separator \(S = S_{\ell p}\), \(R = C_\ell\setminus S\). Running intersection puts no variable of \(R\) in another cluster, so the factorization makes \(R\) independent of \(\mathbf{X}\setminus C_\ell\) given \(S\), whence
\begin{equation*} \begin{aligned} \Pr(\mathbf{X}\mid e) &= \Pr(R \mid S, e)\,\Pr(\mathbf{X}\setminus R \mid e)\\ &= \frac{\Pr(C_\ell\mid e)}{\Pr(S\mid e)}\,\Pr(\mathbf{X}\setminus R\mid e). \end{aligned} \end{equation*}
and summing \(R\) out leaves \(\Pr(\mathbf{X}\setminus R\mid e)\) factorizing over \(T\) minus \(\ell\) (the factor \(\sum_R\psi_\ell\) is a function of \(S \subseteq C_p\), absorbed into \(\psi_p\)), to which the hypothesis applies. Here the clusters are the families and the tree edge from \(U \to X\) carries separator \(\{U\}\), so grouping tree edges by their head \(X\),
\begin{equation*} \prod_{i-j}\Pr(S_{ij}\mid e) \;=\; \prod_{XU}\ \prod_{U \in U} \Pr(U \mid e). \end{equation*}
Substituting,
\begin{equation*} \begin{aligned} \Pr(\mathbf{X}\mid e) &= \frac{\prod_{XU}\Pr(XU\mid e)}{\prod_{XU}\prod_{U\in U}\Pr(U\mid e)}\\ &= \prod_{XU}\frac{\Pr(XU\mid e)}{\prod_{U\in U}\Pr(U\mid e)}, \end{aligned} \end{equation*}
as required – the form assumed for \(\Pr^{\prime}\) in Equation 14.3.
(b) Only the denominator’s bookkeeping differs. Grouping it by parent rather than by family, \(\Pr(Z\mid e)\) appears in the inner product of family \(XU\) exactly when \(X\) is a child of \(Z\), hence \(n_Z\) times in all, so
\begin{equation*} \prod_{XU}\ \prod_{U\in U}\Pr(U\mid e) \;=\; \prod_{Z \in \mathbf{X}} \Pr(Z\mid e)^{\,n_Z}, \end{equation*}
leaves (\(n_Z = 0\)) contributing nothing. Each \(X\) heads one family, so pushing \(\Pr(X\mid e)^{n_X}\) into that family’s term,
\begin{equation*} \begin{aligned} \Pr(\mathbf{X}\mid e) &= \frac{\prod_{XU}\Pr(XU\mid e)}{\prod_{X}\Pr(X\mid e)^{\,n_X}}\\ &= \prod_{XU}\frac{\Pr(XU\mid e)}{\Pr(X\mid e)^{\,n_X}} , \end{aligned} \end{equation*}
which is (b). \(\square\)
Consider Theorem 14.1. Let \(N\) and \(N^{\prime}\) be two Bayesian networks over the same set of variables \(\mathbf{X}\), possibly having different structures, inducing distributions \(\Pr\) and \(\Pr^{\prime}\) respectively, and let \(e\) be evidence. Prove that
\begin{equation*} \log \Pr(e) \;\ge\; ENT^{\prime}(\mathbf{X}\mid e) + \sum_{XU} AVG^{\prime}\big(\log \lambda_e(X)\,\Theta_{X\mid U}\big). \end{equation*}
Here \(XU\) ranges over the families of \(N\), \(ENT^{\prime}(\mathbf{X}\mid e)\) is the entropy of \(\Pr^{\prime}(\mathbf{X}\mid e)\), and \(AVG^{\prime}(\log \lambda_e(X)\Theta_{X\mid U}) = \sum_{xu}\Pr^{\prime}(xu\mid e)\log \lambda_e(x)\theta_{x\mid u}\). Thus, if a distribution \(\Pr^{\prime}(\mathbf{X}\mid e)\) is induced by a sufficiently simple Bayesian network \(N^{\prime}\), we can compute a lower bound on the probability of evidence \(\Pr(e)\).
Drop the nonnegative \(KL\) term from Theorem 14.1, whose identity uses nothing about \(\Pr^{\prime}\) beyond its being a distribution over \(\mathbf{X}\) – in particular it covers the one induced by \(N^{\prime}\), whatever that structure is. Indeed, the chain rule for \(N\) with the evidence indicators gives \(\Pr(x,e) = \prod_{XU}\lambda_e(x)\theta_{x\mid u}\) for complete \(x\), the indicator product being \(1\) exactly on the \(x\) compatible with \(e\); hence \(\log\Pr(x\mid e) = \sum_{XU}\log\lambda_e(x)\theta_{x\mid u} - \log\Pr(e)\) and
\begin{equation*} \begin{aligned} &KL\big(\Pr^{\prime}(\mathbf{X}\mid e),\Pr(\mathbf{X}\mid e)\big) = \sum_x \Pr^{\prime}(x \mid e)\log\frac{\Pr^{\prime}(x\mid e)}{\Pr(x\mid e)}\\ &= -ENT^{\prime}(\mathbf{X}\mid e)
- \sum_{XU} AVG^{\prime}\big(\log \lambda_e(X)\Theta_{X\mid U}\big) + \log\Pr(e), \end{aligned} \end{equation*}
the last step summing over the completions of \(xu\), legitimate because \(\log\lambda_e(x)\theta_{x\mid u}\) depends on \(x\) only through \(xu\). Since \(KL \ge 0\) (Section 14.4.1), solving for \(\log\Pr(e)\) and dropping that term,
\begin{equation*} \log\Pr(e) \;\ge\; ENT^{\prime}(\mathbf{X}\mid e) + \sum_{XU} AVG^{\prime}\big(\log\lambda_e(X)\Theta_{X\mid U}\big), \end{equation*}
as required. \(\square\)
Consider running Algorithm 40, IBP, on a network \(N\) that does not have any evidence. Further, suppose that all IBP messages are initialized uniformly.
(a) Show that all \(\lambda\) messages are neutral. That is, for any given message \(\lambda_X(U)\), show that all values \(\lambda_X(u)\) are the same.
(b) Argue that when there is no evidence, IBP need not propagate any \(\lambda\) messages.
(c) Design a sequential message passing schedule where IBP is guaranteed to converge in a single iteration.
Hint: It may be useful to analyze how Algorithm 42, ED BP, parameterizes a fully disconnected network when the original network \(N\) has no evidence.
With \(e\) empty every indicator is \(\lambda_e(x) \equiv 1\), and the normalized equations of Algorithm 40 (lines 7, 10, 14) make every \(\pi\) message sum to one.
(a) Induct on \(t\); at \(t = 0\) every \(\lambda^0_X(U)\) is uniform. Suppose \(\lambda^{t-1}_{Y_j}(X) \equiv c_j\) for all \(j\), and let \(X\) have parents \(U_1,\ldots,U_m\) and children \(Y_1,\ldots,Y_n\). Line 7 reads
\begin{equation*} \lambda^t_X(U_i) = \eta \!\!\sum_{XU\setminus\{U_i\}}\!\! \lambda_e(X)\,\Theta_{X\mid U}\prod_{k\ne i}\pi^{t-1}_X(U_k)\prod_j \lambda^{t-1}_{Y_j}(X), \end{equation*}
and the constants \(c_j\) come out of the sum, so for each value \(u_i\),
\begin{equation*} \begin{aligned} \lambda^t_X(u_i) &= \eta\Big(\prod_j c_j\Big)\sum_{x}\sum_{u_{-i}} \theta_{x\mid u}\prod_{k\ne i}\pi^{t-1}_X(u_k)\\ &= \eta^{\prime}\sum_{u_{-i}}\Big(\prod_{k\ne i}\pi^{t-1}_X(u_k)\Big)\underbrace{\sum_x \theta_{x\mid u}}_{=\,1}\\ &= \eta^{\prime}\prod_{k\ne i}\underbrace{\Big(\sum_{u_k}\pi^{t-1}_X(u_k)\Big)}_{=\,1} \;=\; \eta^{\prime} , \end{aligned} \end{equation*}
with \(u_{-i}\) the other parents, the two cancellations being that \(\Theta_{X\mid U}\) is a conditional distribution and that the \(\pi\) messages are normalized. As \(\eta^{\prime}\) does not depend on \(u_i\), \(\lambda^t_X(U_i)\) is neutral, and after normalization uniform again. \(\square\)
(b) Each \(\lambda\) message being constant, wherever one appears in Algorithm 40 it contributes a multiplicative constant that \(\eta\) absorbs:
- In the \(\pi\) update (line 10), \(\pi^t_{Y_j}(X) = \eta\sum_U \Theta_{X\mid U}\prod_i \pi^{t-1}_X(U_i)\prod_{k\ne j}\lambda^{t-1}_{Y_k}(X)\); the trailing product is a constant \(\prod_{k\ne j}c_k\), so
\begin{equation*} \pi^t_{Y_j}(X) = \eta \sum_U \Theta_{X\mid U}\prod_i \pi^{t-1}_X(U_i), \end{equation*}
independent of \(j\), so every node sends the same \(\pi\) message to all its children.
- In the family marginal (line 14), \(BEL(XU) = \eta\,\Theta_{X\mid U}\prod_i \pi_X(U_i)\prod_j \lambda_{Y_j}(X) = \eta\,\Theta_{X\mid U}\prod_i \pi_X(U_i)\), again with the \(\lambda\) factors absorbed.
- In the \(\lambda\) update itself, by (a) the output is uniform no matter what the inputs are.
No \(\pi\) message and no \(BEL\) therefore depends on the \(\lambda\) messages, which may be omitted: with no evidence IBP is pure causal propagation.
(c) Propagate only \(\pi\) messages, in topological order. Fix an order \(X_1,\ldots,X_n\) of the variables with every parent before its children (\(N\) is acyclic); leave all \(\lambda\) messages at their uniform values; and for \(r = 1,\ldots,n\) compute the single outgoing message
\begin{equation*} \pi(X_r) \;=\; \eta \sum_{U_r} \Theta_{X_r \mid U_r}\prod_{U \in U_r}\pi(U), \end{equation*}
from the \(\pi(U)\) computed earlier in the same sweep, sending it to every child of \(X_r\) (a root gets \(\Theta_{X_r}\) from the empty product); finish with \(BEL(X_rU_r) = \eta\,\Theta_{X_r\mid U_r}\prod_{U\in U_r}\pi(U)\). Writing \(\pi(X)\) for the common value of the \(\pi_{Y_j}(X)\) and ignoring \(\lambda\) messages is licensed by (b).
One sweep suffices: \(\pi(X_r)\) depends only on the parent messages \(\pi(U)\) and on the never-changing \(\lambda\) messages (through a constant \(\eta\) absorbs), and the \(\pi(U)\) were computed strictly earlier, so by induction along the order recomputation returns the same value, while recomputing any \(\lambda\) message returns uniform by (a). Every message is stationary, the convergence test of line 3. (Sequential is essential – under the parallel schedule a root’s influence takes as many iterations to reach a node as that node’s depth.) In the ED BP picture of the hint, Theorem 14.6 identifies \(\pi_X(U) = \Theta_{\hat U}\) and \(\lambda_X(U) = \Theta_{\hat s\mid U}\), so (a) makes \(\hat S\) independent of \(U\), \(e^{\prime}\) vacuous, and Equation 14.8 collapses to \(\Theta_{\hat U} = \Pr^{\prime}(U)\) – the one ancestral sweep above.
Let \(N\) and \(N^{\prime}\) be two Bayesian networks over the same set of variables \(\mathbf{X}\), where \(N^{\prime}\) is fully disconnected. That is, \(N^{\prime}\) induces the distribution
\begin{equation*} \Pr{}^{\prime}(\mathbf{X}) \;=\; \prod_{X \in \mathbf{X}} \Theta^{\prime}_X . \end{equation*}
Identify CPTs \(\Theta^{\prime}_X\) for network \(N^{\prime}\) that minimize \(KL(\Pr, \Pr^{\prime})\).
Take \(\Theta^{\prime}_X = \Pr(X)\) for every \(X\); this is the unique minimizer. (The divergence here is weighted by \(\Pr\), the reverse of the direction in Theorem 14.1.) With \(\mathbf{x}\) a complete instantiation, \(\mathbf{x}[X]\) its value at \(X\), and \(\Pr^{\prime}(\mathbf{x}) = \prod_X \theta^{\prime}_{\mathbf{x}[X]}\),
\begin{equation*} \begin{aligned} KL(\Pr,\Pr{}^{\prime}) &= \sum_{\mathbf{x}}\Pr(\mathbf{x})\log\Pr(\mathbf{x}) - \sum_{\mathbf{x}}\Pr(\mathbf{x})\sum_{X}\log\theta^{\prime}_{\mathbf{x}[X]}\\ &= -ENT(\mathbf{X}) \;-\; \sum_{X\in\mathbf{X}}\ \sum_{x}\Big(\sum_{\mathbf{x}\sim x}\Pr(\mathbf{x})\Big)\log\theta^{\prime}_{x}\\ &= -ENT(\mathbf{X}) \;-\; \sum_{X\in\mathbf{X}}\ \sum_{x}\Pr(x)\log\theta^{\prime}_{x}, \end{aligned} \end{equation*}
with \(\mathbf{x}\sim x\) the completions of \(x\). Here \(ENT(\mathbf{X})\) is constant and the objective separates, each \(\Theta^{\prime}_X\) occurring in one term constrained only by \(\sum_x\theta^{\prime}_x = 1\), \(\theta^{\prime}_x \ge 0\). So maximize \(\sum_x\Pr(x)\log\theta^{\prime}_x\) per variable; against the candidate \(\theta^{\prime}_x = \Pr(x)\),
\begin{equation*} \begin{aligned} \sum_x \Pr(x)\log\theta^{\prime}_x - \sum_x \Pr(x)\log\Pr(x) &= \sum_x \Pr(x)\log\frac{\theta^{\prime}_x}{\Pr(x)}\\ &= -KL\big(\Pr(X), \Theta^{\prime}_X\big) \;\le\; 0 \end{aligned} \end{equation*}
by nonnegativity of the KL divergence between the single-variable distributions \(\Pr(X)\) and \(\Theta^{\prime}_X\) (Section 14.4.1), with equality iff \(\Theta^{\prime}_X = \Pr(X)\). So each subproblem has the unique maximizer \(\theta^{\prime}_x = \Pr(x)\), giving \(\Pr^{\prime}(\mathbf{X}) = \prod_X \Pr(X)\).
Exercises 14.8–14.14
Figure 14.6(a) depicts a Bayesian network \(\mathcal{N}\) drawn as two three-by-two blocks of nodes joined by a single vertical edge. The upper block contains the labelled nodes \(A\), \(B\), \(U\) and three unlabelled nodes; the lower block contains the labelled nodes \(X\), \(C\) and four unlabelled nodes. The edge \(U \to X\) is the only edge of \(\mathcal{N}\) joining the two blocks, so deleting it splits \(\mathcal{N}\) into two disconnected pieces. The evidence is \(\mathbf{e} = \bar{a}, b, \bar{c}\), so \(\bar{a}, b\) lies on the \(U\)-side of the deleted edge and \(\bar{c}\) lies on the \(X\)-side.
Figure 14.6(b) depicts the approximate network \(\mathcal{N}^{\prime}\) obtained by deleting \(U \to X\): the edge is removed, a clone \(\hat{U}\) (a root with CPT \(\Theta_{\hat{U}}\), having the same values as \(U\)) is made the parent of \(X\), and a binary node \(\hat{S}\) with CPT \(\Theta_{\hat{S}|U}\) is made a child of \(U\) and is assumed observed. The approximate evidence is \(\mathbf{e}^{\prime} = \bar{a}, b, \bar{c}, \hat{s}\).
For this network the edge-parameter conditions of Theorem 14.5,
\begin{equation*} \theta_{\hat{U}} = \Pr{}^{\prime}(U \mid \mathbf{e}^{\prime} - \hat{S}), \qquad \theta_{\hat{s}|U} = \eta \Pr{}^{\prime}(\mathbf{e}^{\prime} \mid \hat{U}), \end{equation*}
(Equations 14.8 and 14.9) become
\begin{equation*} \theta_{\hat{U}} = \Pr{}^{\prime}(U \mid \bar{a}, b, \bar{c}) \quad (14.10) \end{equation*}
\begin{equation*} \theta_{\hat{s}|U} = \eta \Pr{}^{\prime}(\bar{a}, b, \bar{c}, \hat{s} \mid \hat{U}). \quad (14.11) \end{equation*}
Show that Equations 14.10 and 14.11 reduce to
\begin{equation*} \theta_{\hat{U}} = \Pr{}^{\prime}(U \mid \bar{a}, b) \quad (14.12) \end{equation*}
\begin{equation*} \theta_{\hat{s}|U} = \eta \Pr{}^{\prime}(\bar{c} \mid \hat{U}). \quad (14.13) \end{equation*}
Both reductions come from \(\mathcal{N}^{\prime}\) having two connected components. Deleting \(U \to X\) severs the only link between the halves of \(\mathcal{N}\), and the added nodes attach to opposite halves – \(\hat{S}\) a child of \(U\), \(\hat{U}\) a root and parent of \(X\) – so
\begin{equation*} \mathcal{C}_U = \{A, B, U, \hat{S}, \ldots\}, \qquad \mathcal{C}_X = \{\hat{U}, X, C, \ldots\}, \end{equation*}
and the product of CPTs splits by component, making every set of \(\mathcal{C}_U\)-variables independent of every set of \(\mathcal{C}_X\)-variables under \(\Pr^{\prime}\).
Equation 14.10 to 14.12. Here \(U, A, B \in \mathcal{C}_U\) and \(C \in \mathcal{C}_X\), so \(\Pr^{\prime}(U,\bar a, b,\bar c) = \Pr^{\prime}(U,\bar a,b)\Pr^{\prime}(\bar c)\); dividing by \(\Pr^{\prime}(\bar a,b,\bar c) = \Pr^{\prime}(\bar a,b)\Pr^{\prime}(\bar c)\) and cancelling \(\Pr^{\prime}(\bar c) > 0\) gives \(\Pr^{\prime}(U \mid \bar a,b,\bar c) = \Pr^{\prime}(U\mid\bar a,b)\), which is Equation 14.12.
Equation 14.11 to 14.13. Condition on a value \(\hat u\) of the clone; \(A, B, \hat{S} \in \mathcal{C}_U\) and \(\hat{U} \in \mathcal{C}_X\), so splitting \(\mathbf{e}^{\prime}\) along the components,
\begin{equation*} \begin{aligned} \Pr{}^{\prime}(\bar{a}, b, \bar{c}, \hat{s} \mid \hat{u}) &= \Pr{}^{\prime}(\bar{a}, b, \hat{s} \mid \hat{u}) \cdot \Pr{}^{\prime}(\bar{c} \mid \hat{u}) \\ &= \Pr{}^{\prime}(\bar{a}, b, \hat{s}) \cdot \Pr{}^{\prime}(\bar{c} \mid \hat{u}). \end{aligned} \end{equation*}
the first equality by component independence, the second dropping a conditioning irrelevant to a \(\mathcal{C}_U\)-event. Since \(\alpha = \Pr^{\prime}(\bar a, b, \hat s)\) is a positive constant independent of \(\hat u\), and \(\eta\) in Equation 14.9 need only be positive, absorbing \(\alpha\) into \(\eta^{\prime} = \eta\alpha > 0\) turns Equation 14.11 into \(\theta_{\hat s|U} = \eta^{\prime}\Pr^{\prime}(\bar c\mid\hat U)\), which is Equation 14.13. The constant’s value is immaterial by Exercise 14.9, \(\hat{S}\) being a leaf with the single parent \(U\).
Let \(\mathcal{N}\) be a Bayesian network that induces a distribution \(\Pr(\mathbf{X})\) and let \(S\) be a leaf node in network \(\mathcal{N}\) that has a single parent \(U\). Show that the conditional distribution \(\Pr(\mathbf{X} \setminus \{S\} \mid s)\) is the same for any two CPTs \(\Theta_{S|U}\) and \(\Theta^{\prime}_{S|U}\) of node \(S\) as long as \(\theta_{s|U} = \eta \cdot \theta^{\prime}_{s|U}\) for some constant \(\eta > 0\).
The CPT of \(S\) enters the slice \(S = s\) only through the single factor \(\theta_{s\mid u}\), so rescaling that column rescales the whole slice and cancels in the conditional. Write \(\mathbf{Y} = \mathbf{X}\setminus\{S\}\) and let \(\Pr_{-S}\) be induced by \(\mathcal{N}\) with \(S\) deleted – a legitimate network over \(\mathbf{Y}\), the leaf \(S\) occurring in no other family. By the chain rule, for every \(\mathbf{y}\),
\begin{equation*} \Pr(\mathbf{y}, s) = \Big( \prod_{Z \in \mathbf{Y}} \theta_{z|\mathbf{u}_Z} \Big) \cdot \theta_{s|u(\mathbf{y})} = \Pr{}_{-S}(\mathbf{y}) \cdot \theta_{s \mid u(\mathbf{y})}, \end{equation*}
with \(u(\mathbf{y})\) the value \(\mathbf{y}\) assigns to \(U\), the first factor running over the families of \(\mathbf{Y}\) alone and hence independent of \(\Theta_{S|U}\). Let \(\Pr\), \(\Pr^{\prime}\) be induced by the two CPTs, all else fixed; they share \(\Pr_{-S}\) and \(\theta_{s|u} = \eta\theta^{\prime}_{s|u}\) for every \(u\), so \(\Pr(\mathbf{y},s) = \eta\Pr^{\prime}(\mathbf{y},s)\) for every \(\mathbf{y}\). Summing gives \(\Pr(s) = \eta\Pr^{\prime}(s)\), positive since \(\eta > 0\), and dividing,
\begin{equation*} \Pr(\mathbf{y} \mid s) = \frac{\eta \Pr{}^{\prime}(\mathbf{y}, s)}{\eta \Pr{}^{\prime}(s)} = \Pr{}^{\prime}(\mathbf{y} \mid s). \qquad \square \end{equation*}
Consider again Figure 14.7, which defines a network \(\mathcal{N}\), and another network \(\mathcal{N}^{\prime}\) that results from deleting edge \(A \to B\).
Network \(\mathcal{N}\) of Figure 14.7(a) has nodes \(A, B, C, D\) and edges \(A \to B\), \(A \to C\), \(B \to D\), \(C \to D\). Evidence is \(\mathbf{e}: D = \text{true}\). Its CPTs are
| \(A\) | \(\theta_A\) |
|---|---|
| true | .8 |
| false | .2 |
| \(A\) | \(B\) | \(\theta_{B\mid A}\) |
|---|---|---|
| true | true | .8 |
| true | false | .2 |
| false | true | .4 |
| false | false | .6 |
| \(A\) | \(C\) | \(\theta_{C\mid A}\) |
|---|---|---|
| true | true | .5 |
| true | false | .5 |
| false | true | 1.0 |
| false | false | .0 |
| \(B\) | \(C\) | \(D\) | \(\theta_{D\mid BC}\) |
|---|---|---|---|
| true | true | true | .1 |
| true | true | false | .9 |
| true | false | true | .3 |
| true | false | false | .7 |
| false | true | true | .9 |
| false | true | false | .1 |
| false | false | true | .8 |
| false | false | false | .2 |
Network \(\mathcal{N}^{\prime}\) of Figure 14.7(b) results from deleting \(A \to B\): a clone \(\hat{A}\) (a root) becomes the parent of \(B\), with \(\Theta_{B|\hat{A}}\) equal to the table \(\Theta_{B|A}\) above, and an observed binary node \(\hat{S}\) becomes a child of \(A\). All other edges (\(A \to C\), \(B \to D\), \(C \to D\)) are retained, so \(\mathcal{N}^{\prime}\) is a polytree. The evidence is \(\mathbf{e}^{\prime}: D = \text{true}, \hat{S} = \text{true}\). Figure 14.8 depicts the edge parameters for \(\mathcal{N}^{\prime}\) computed using Algorithm 42, ED-BP, which converge after four iterations to
| \(\hat{A}\) | \(\theta_{\hat{A}}\) |
|---|---|
| true | .8262 |
| false | .1738 |
| \(A\) | \(\hat{S}\) | \(\theta_{\hat{S}\mid A}\) |
|---|---|---|
| true | true | .3438 |
| true | false | .6562 |
| false | true | .6562 |
| false | false | .3438 |
Figure 14.20 depicts the messages computed by Algorithm 40, IBP, after converging on the original network \(\mathcal{N}\):
Edge \(A \to B\), then edge \(A \to C\):
| \(A\) | \(\pi_B(A)\) | \(\lambda_B(A)\) | \(\pi_C(A)\) | \(\lambda_C(A)\) |
|---|---|---|---|---|
| true | .8262 | .3438 | .6769 | .5431 |
| false | .1738 | .6562 | .3231 | .4569 |
Edge \(B \to D\):
| \(B\) | \(\pi_D(B)\) | \(\lambda_D(B)\) |
|---|---|---|
| true | .7305 | .1622 |
| false | .2695 | .8378 |
Edge \(C \to D\):
| \(C\) | \(\pi_D( C)\) | \(\lambda_D( C)\) |
|---|---|---|
| true | .6615 | .4206 |
| false | .3384 | .5794 |
(a) Identify how edge parameters in \(\mathcal{N}^{\prime}\) correspond to IBP messages in \(\mathcal{N}\).
(b) Consider the following correspondence between the approximations for family marginals computed by IBP in \(\mathcal{N}\) and by ED-BP in \(\mathcal{N}^{\prime}\):
| \(A\) | \(B\) | \(\mathrm{BEL}(AB) = \Pr^{\prime}(\hat{A}B \mid \mathbf{e}^{\prime})\) |
|---|---|---|
| true | true | .3114 |
| true | false | .4021 |
| false | true | .0328 |
| false | false | .2537 |
Compute \(\mathrm{BEL}(A) = \Pr^{\prime}(\hat{A} \mid \mathbf{e}^{\prime})\).
(c) Given the results of (b), argue that we must have \(\Pr^{\prime}(\hat{A} \mid \mathbf{e}^{\prime}) = \Pr^{\prime}(A \mid \mathbf{e}^{\prime})\).
(d) Identify a pair of variables in \(\mathcal{N}^{\prime}\) whose joint marginal can be easily computed in \(\mathcal{N}^{\prime}\) but cannot be computed using IBP in \(\mathcal{N}\).
(a) The two edge parameters of a deleted edge are the two IBP messages along it – Theorem 14.6 for full deletion, the discussion following it for any deletion leaving a polytree, as here:
\begin{equation*} \pi_X(U) = \theta_{\hat{U}}, \qquad \lambda_X(U) = \theta_{\hat{s}|U}. \end{equation*}
The only deleted edge is \(A \to B\), and the numbers confirm it:
\begin{equation*} \begin{aligned} \pi_B(A) &= (.8262, .1738) = (\theta_{\hat{a}}, \theta_{\bar{\hat{a}}}), \\ \lambda_B(A) &= (.3438, .6562) = (\theta_{\hat{s}|a}, \theta_{\hat{s}|\bar{a}}). \end{aligned} \end{equation*}
The messages on the retained edges have no counterpart among the edge parameters; their effect in \(\mathcal{N}^{\prime}\) comes from exact inference in the polytree.
(b) Sum \(B\) out of the family marginal:
\begin{equation*} \begin{aligned} \Pr{}^{\prime}(\hat{A} = \text{true} \mid \mathbf{e}^{\prime}) &= .3114 + .4021 = .7135, \\ \Pr{}^{\prime}(\hat{A} = \text{false} \mid \mathbf{e}^{\prime}) &= .0328 + .2537 = .2865. \end{aligned} \end{equation*}
So \(\mathrm{BEL}(A) = (.7135,.2865)\), which is also the normalized \(\pi_B(A)\lambda_B(A) = (.28405,.11405)\) that IBP computes on the edge \(A \to B\).
(c) Theorem 14.6, in its polytree form, gives two identities per variable \(X\) at a fixed point:
\begin{equation*} \mathrm{BEL}(X) = \Pr{}^{\prime}(X \mid \mathbf{e}^{\prime}), \qquad \mathrm{BEL}(X\mathbf{U}) = \Pr{}^{\prime}(X\hat{\mathbf{U}} \mid \mathbf{e}^{\prime}), \end{equation*}
the second replacing each parent by its clone. At \(X = B\) the second identity is the table of (b), whose \(B\)-sum is \(\Pr^{\prime}(\hat A\mid\mathbf{e}^{\prime})\); that sum is \(\mathrm{BEL}(A)\) by the consistency constraints of Theorem 14.2; and the first identity at \(X = A\) gives \(\mathrm{BEL}(A) = \Pr^{\prime}(A\mid\mathbf{e}^{\prime})\). Chaining,
\begin{equation*} \Pr{}^{\prime}(\hat{A} \mid \mathbf{e}^{\prime}) = \sum_B \mathrm{BEL}(AB) = \mathrm{BEL}(A) = \Pr{}^{\prime}(A \mid \mathbf{e}^{\prime}), \end{equation*}
the node and its clone carrying the same posterior – the first equation of Exercise 14.12(b). Exact inference in the polytree confirms it: \(.71357\) against \(.71349\), the discrepancy being the four-digit rounding of Figure 14.8.
(d) The pair \(\{A,\hat{A}\}\). Exact inference in the polytree \(\mathcal{N}^{\prime}\) gives \(\Pr^{\prime}(A\hat{A}\mid\mathbf{e}^{\prime})\) directly, which is what Section 14.8.4 needs to score the deleted edge by
\begin{equation*} \mathrm{MI}(A; \hat{A} \mid \mathbf{e}^{\prime}) = \sum_{a\hat{a}} \Pr{}^{\prime}(a\hat{a} \mid \mathbf{e}^{\prime}) \log \frac{\Pr{}^{\prime}(a\hat{a} \mid \mathbf{e}^{\prime})} {\Pr{}^{\prime}(a \mid \mathbf{e}^{\prime})\Pr{}^{\prime}(\hat{a} \mid \mathbf{e}^{\prime})}. \end{equation*}
IBP in \(\mathcal{N}\) produces only node and family marginals, and \(\hat{A}\) is not a variable of \(\mathcal{N}\) – the two ends of \(A \to B\) are a single node there.
Let \(\mathcal{N}^{\prime}\) be a network that results from deleting a single edge \(U \to X\) from the network \(\mathcal{N}\) and suppose that this edge splits the network \(\mathcal{N}\) into two disconnected subnetworks. As in Section 14.8.1, deletion removes the edge, adds a clone \(\hat{U}\) (a root with CPT \(\Theta_{\hat{U}}\), taking the same values as \(U\)) as the new parent of \(X\), and adds an observed binary node \(\hat{S}\) with CPT \(\Theta_{\hat{S}|U}\) as a child of \(U\). Show that \(\Pr(\mathbf{e}_X \mid u) = \Pr^{\prime}(\mathbf{e}_X \mid \hat{u})\), where \(\mathbf{e}_X\) is evidence that instantiates nodes on the \(X\)-side of edge \(U \to X\) and \(u\) and \(\hat{u}\) denote the same value of \(U\) and of its clone.
Both sides equal \(L(u) = \sum_{\mathbf{x}_X \sim \mathbf{e}_X}\Phi_X(\mathbf{x}_X, u)\), the likelihood the \(X\)-side subnetwork assigns to \(\mathbf{e}_X\) as a function of the value crossing the deleted edge. Write \(\mathbf{X}_U\), \(\mathbf{X}_X\) for the nodes of the two subnetworks. Since \(U \to X\) is the only edge across the split, every node of \(\mathbf{X}_U\) has all its parents in \(\mathbf{X}_U\), and every node of \(\mathbf{X}_X\) has all its parents in \(\mathbf{X}_X\) except \(X\), whose parents are \(\mathbf{P}\cup\{U\}\) with \(\mathbf{P} \subseteq \mathbf{X}_X\). So the chain rule for \(\mathcal{N}\) splits as
\begin{equation*} \Pr(\mathbf{x}_U, \mathbf{x}_X) = \Phi_U(\mathbf{x}_U)\cdot \Phi_X(\mathbf{x}_X, u), \end{equation*}
where
\begin{equation*} \Phi_U(\mathbf{x}_U) = \prod_{V \in \mathbf{X}_U} \theta_{v|\mathbf{u}_V}, \qquad \Phi_X(\mathbf{x}_X, u) = \prod_{V \in \mathbf{X}_X} \theta_{v|\mathbf{u}_V}, \end{equation*}
with \(u\) the value \(\mathbf{x}_U\) assigns to \(U\), entering \(\Phi_X\) only through \(X\)’s CPT. Both pieces normalize – \(\Phi_U\) is the joint of \(\mathcal{N}_U\) and \(\Phi_X(\cdot,u)\) that of \(\mathcal{N}_X\) with \(U = u\) fixed – so summing the joint of \(\mathcal{N}\) over instantiations consistent with \(u\) and \(\mathbf{e}_X\),
\begin{equation*} \begin{aligned} \Pr(\mathbf{e}_X, u) &= \sum_{\mathbf{x}_U \sim u} \sum_{\mathbf{x}_X \sim \mathbf{e}_X} \Phi_U(\mathbf{x}_U)\Phi_X(\mathbf{x}_X, u) \\ &= \Big(\sum_{\mathbf{x}_U \sim u} \Phi_U(\mathbf{x}_U)\Big) \cdot L(u) = \Pr(u)\, L(u), \end{aligned} \end{equation*}
the factorization being legitimate because \(\Phi_X(\cdot,u)\) does not depend on \(\mathbf{x}_U\) once \(u\) is fixed, and \(\sum_{\mathbf{x}_U \sim u}\Phi_U = \Pr(u)\) because summing \(\Phi_X\) out of the joint gives \(1\). Hence \(\Pr(\mathbf{e}_X\mid u) = L(u)\). In \(\mathcal{N}^{\prime}\) the components are \(\mathbf{X}_U \cup \{\hat{S}\}\) and \(\mathbf{X}_X \cup \{\hat{U}\}\), and the chain rule reads
\begin{equation*} \Pr{}^{\prime}(\mathbf{x}_U, \hat{s}^\ast, \hat{u}, \mathbf{x}_X) = \Phi_U(\mathbf{x}_U)\,\theta_{\hat{s}^\ast|u} \cdot \theta_{\hat{u}}\, \Phi_X(\mathbf{x}_X, \hat{u}), \end{equation*}
since every CPT of \(\mathcal{N}\) carries over unchanged, \(X\)’s now indexed by \(\hat{u}\) – the same \(\Phi_X\), evaluated at \(\hat u\). As \(\mathbf{e}_X\) mentions no variable outside \(\mathbf{X}_X\), summing out \(\mathbf{X}_U\) and \(\hat{S}\), which contribute \(\sum_{\mathbf{x}_U}\Phi_U\sum_{\hat s^\ast}\theta_{\hat s^\ast|u} = 1\), leaves \(\Pr^{\prime}(\mathbf{e}_X,\hat u) = \theta_{\hat u}L(\hat u)\); and \(\hat U\) is a root, so \(\Pr^{\prime}(\hat u) = \theta_{\hat u}\) and \(\Pr^{\prime}(\mathbf{e}_X\mid\hat u) = L(\hat u)\). Both sides therefore equal \(L(u)\) at \(u = \hat u\), for every choice of edge parameters – neither appears in \(L\). \(\square\)
Consider Equations 14.8 and 14.9, which govern the parameters of a deleted edge \(U \to X\) in the approximate network \(\mathcal{N}^{\prime}\) (recall that \(\hat{U}\) is a root of \(\mathcal{N}^{\prime}\) and the new parent of \(X\), and \(\hat{S}\) is a leaf of \(\mathcal{N}^{\prime}\) whose single parent is \(U\) and which is observed at value \(\hat{s}\) in \(\mathbf{e}^{\prime}\)):
\begin{equation*} \theta_{\hat{U}} = \Pr{}^{\prime}(U \mid \mathbf{e}^{\prime} - \hat{S}), \qquad \theta_{\hat{s}|U} = \eta \Pr{}^{\prime}(\mathbf{e}^{\prime} \mid \hat{U}). \end{equation*}
(a) Show that Equations 14.8 and 14.9 are equivalent to
\begin{equation*} \theta_{\hat{u}} = \frac{\partial \Pr^{\prime}(\mathbf{e}^{\prime})}{\partial \theta_{\hat{s}|u}}, \qquad \theta_{\hat{s}|u} = \frac{\partial \Pr^{\prime}(\mathbf{e}^{\prime})}{\partial \theta_{\hat{u}}}, \end{equation*}
where \(u = \hat{u}\).
(b) Show that Equations 14.8 and 14.9 are equivalent to
\begin{equation*} \begin{aligned} \Pr{}^{\prime}(U \mid \mathbf{e}^{\prime}) &= \Pr{}^{\prime}(\hat{U} \mid \mathbf{e}^{\prime}) \\ \Pr{}^{\prime}(U \mid \mathbf{e}^{\prime} - \hat{S}) &= \Pr{}^{\prime}(\hat{U}). \end{aligned} \end{equation*}
Both characterizations follow from two structural facts (throughout \(\theta_{\hat u} > 0\) and \(\Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S}, u) > 0\)).
Fact 1. \(\hat{S}\) is a leaf with sole parent \(U\), and \(\hat s \in \mathbf{e}^{\prime}\), so
\begin{equation*} \Pr{}^{\prime}(\mathbf{e}^{\prime}, u) = \Pr{}^{\prime}(\mathbf{e}^{\prime} - \hat{S}, \hat{s}, u) = \theta_{\hat{s}|u}\,\Pr{}^{\prime}(\mathbf{e}^{\prime} - \hat{S}, u), \end{equation*}
(\(\hat{S}\) is independent of the rest given \(U\), and retracting it leaves it barren, so \(\Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S}, u)\) does not depend on \(\Theta_{\hat{S}|U}\)).
Fact 2. \(\hat{U}\) is a root, so \(\Pr^{\prime}(\hat u) = \theta_{\hat u}\) and \(\Pr^{\prime}(\mathbf{e}^{\prime}, \hat u) = \theta_{\hat u}\Pr^{\prime}(\mathbf{e}^{\prime}\mid\hat u)\).
(a) By Theorem 12.2 in the form of Equation 12.5, for \(\theta_{x|\mathbf{u}} \neq 0\),
\begin{equation*} \frac{\partial \Pr(\mathbf{e})}{\partial \theta_{x|\mathbf{u}}} = \frac{\Pr(x, \mathbf{u}, \mathbf{e})}{\theta_{x|\mathbf{u}}}. \end{equation*}
For \(\theta_{\hat{s}|u}\), whose family is \(\hat{S}U\),
\begin{equation*} \frac{\partial \Pr^{\prime}(\mathbf{e}^{\prime})}{\partial \theta_{\hat{s}|u}} = \frac{\Pr^{\prime}(\hat{s}, u, \mathbf{e}^{\prime})}{\theta_{\hat{s}|u}} = \frac{\Pr^{\prime}(\mathbf{e}^{\prime}, u)}{\theta_{\hat{s}|u}} = \Pr{}^{\prime}(\mathbf{e}^{\prime} - \hat{S}, u), \end{equation*}
the middle step by \(\hat s \in \mathbf{e}^{\prime}\) and the last by Fact 1; splitting \(\Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S}, u) = \Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S}) \Pr^{\prime}(u\mid\mathbf{e}^{\prime} - \hat{S})\),
\begin{equation*} \frac{\partial \Pr^{\prime}(\mathbf{e}^{\prime})}{\partial \theta_{\hat{s}|u}} = \Pr{}^{\prime}(\mathbf{e}^{\prime} - \hat{S}) \cdot \Pr{}^{\prime}(u \mid \mathbf{e}^{\prime} - \hat{S}). \quad (\ast) \end{equation*}
For \(\theta_{\hat{u}}\), whose family is the singleton \(\hat{U}\),
\begin{equation*} \frac{\partial \Pr^{\prime}(\mathbf{e}^{\prime})}{\partial \theta_{\hat{u}}} = \frac{\Pr^{\prime}(\hat{u}, \mathbf{e}^{\prime})}{\theta_{\hat{u}}} = \Pr{}^{\prime}(\mathbf{e}^{\prime} \mid \hat{u}), \quad (\ast\ast) \end{equation*}
by Fact 2. Now \((\ast\ast)\) is Equation 14.9 with \(\eta = 1\), and \(\eta\) is immaterial for conditional queries by Exercise 14.9; while \((\ast)\) makes the derivative proportional in \(u\) to \(\Pr^{\prime}(U\mid\mathbf{e}^{\prime} - \hat{S})\) with \(u\)-independent constant \(\Pr^{\prime}(\mathbf{e}^{\prime} - \hat S)\), so normalization of \(\Theta_{\hat U}\) forces Equation 14.8, and conversely 14.8 makes \((\ast)\) equal \(\Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S})\theta_{\hat u}\). Both derivative equations are thus read up to positive rescaling – harmlessly, since rescaling \(\Theta_{\hat{U}}\) by \(c > 0\) multiplies every chain-rule term of \(\mathcal{N}^{\prime}\) by \(c\) (each instantiation uses exactly one \(\theta_{\hat u}\)), and rescaling \(\Theta_{\hat{S}|U}\) is covered by Exercise 14.9.
(b) By Fact 2, \(\Pr^{\prime}(\hat U) = \theta_{\hat U}\), so the second equation of (b) is Equation 14.8 verbatim (read at \(u = \hat u\), as always). For the first, Fact 1 gives
\begin{equation*} \Pr{}^{\prime}(u \mid \mathbf{e}^{\prime}) = \frac{\Pr^{\prime}(\mathbf{e}^{\prime}, u)}{\Pr^{\prime}(\mathbf{e}^{\prime})} = \frac{\theta_{\hat{s}|u}\,\Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S}, u)}{\Pr^{\prime}(\mathbf{e}^{\prime})}, \end{equation*}
and Fact 2 gives \(\Pr^{\prime}(\hat u\mid\mathbf{e}^{\prime}) = \theta_{\hat u} \Pr^{\prime}(\mathbf{e}^{\prime}\mid\hat u)/\Pr^{\prime}(\mathbf{e}^{\prime})\), so, cancelling \(\Pr^{\prime}(\mathbf{e}^{\prime})\), the first equation holds iff for every \(u = \hat u\),
\begin{equation*} \theta_{\hat{s}|u}\,\Pr{}^{\prime}(\mathbf{e}^{\prime} - \hat{S}, u) = \theta_{\hat{u}}\,\Pr{}^{\prime}(\mathbf{e}^{\prime} \mid \hat{u}). \quad (\dagger) \end{equation*}
Assume Equation 14.8, i.e. \(\theta_{\hat u} = \Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S}, u)/ \Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S})\); substituting into the right of \((\dagger)\) and cancelling the positive \(\Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S}, u)\) turns \((\dagger)\) into
\begin{equation*} \theta_{\hat{s}|u} = \frac{1}{\Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S})}\,\Pr{}^{\prime}(\mathbf{e}^{\prime} \mid \hat{u}), \end{equation*}
Equation 14.9 with \(\eta = 1/A\), \(A = \Pr^{\prime}(\mathbf{e}^{\prime} - \hat{S}) > 0\). Conversely \(\eta\) is not free once 14.8 is imposed: under 14.8 and 14.9 with some \(\eta > 0\) the two sides of \((\dagger)\) are \(\eta\Pr^{\prime}(\mathbf{e}^{\prime}\mid\hat u) \Pr^{\prime}(\mathbf{e}^{\prime} - \hat S, u)\) and \(A^{-1}\Pr^{\prime}(\mathbf{e}^{\prime} - \hat S, u)\Pr^{\prime}(\mathbf{e}^{\prime}\mid\hat u)\), a ratio of \(\eta A\) at every \(u\); but summing either side over \(u\) gives \(\Pr^{\prime}(\mathbf{e}^{\prime})\) in both cases (by Fact 1 on the left, Fact 2 on the right), so \(\eta A = 1\) and \((\dagger)\) holds term by term. Hence 14.8 and 14.9 give both equations of (b), and conversely the second gives 14.8 and then \((\dagger)\) gives 14.9. \(\square\)
Let \(\mathcal{N}\) be a Bayesian network and \(\mathcal{N}^{\prime}\) be the result of deleting a set \(\Delta\) of edges in \(\mathcal{N}\) (each deleted edge \(U \to X\) contributing a root clone \(\hat{U}\) as the new parent of \(X\), with CPT \(\Theta_{\hat{U}}\), and an observed leaf \(\hat{S}\) with parent \(U\) and CPT \(\Theta_{\hat{S}|U}\); the evidence is \(\mathbf{e}^{\prime}\), which is \(\mathbf{e}\) extended by \(\hat{s}\) for every added node \(\hat{S}\)). Show how an ED-BP fixed point in \(\mathcal{N}^{\prime}\) corresponds to a fixed point of IJGP. In particular, show how to construct a joingraph that allows IJGP, Algorithm 41, to simulate Algorithm 42, ED-BP.
Take a jointree for \(\mathcal{N}^{\prime}\), relabel away the auxiliary nodes, and restore each deleted edge as one extra joingraph edge whose two messages are its two edge parameters; IJGP’s exclusion rule (a message out of an edge is computed without the message that came in on it) is then exactly the retraction \(\mathbf{e}^{\prime} - \hat{S}\) of Equation 14.8 and the division by \(\theta_{\hat{u}}\) of Equation 14.9.
Construction. Let \(T^{\prime}\) be a jointree for \(\mathcal{N}^{\prime}\). By the jointree property every family of \(\mathcal{N}^{\prime}\) sits in some cluster, so for each deleted edge \(U \to X\) there are:
- a cluster \(C_{i}\) containing the family \(\{U, \hat{S}\}\), to which \(\Theta_{\hat{S}|U}\) and the indicator \(\lambda_{\hat{s}}\) are assigned;
- a cluster \(C_{j}\) containing the family \(\{X\} \cup \hat{\mathbf{U}}\) of \(X\) in \(\mathcal{N}^{\prime}\), hence containing \(\hat{U}\), to which \(\Theta_{\hat{U}}\) is assigned.
Build \(G\) as follows. (1) One node per cluster of \(T^{\prime}\); delete every \(\hat{S}\) from every cluster and separator and rename every clone \(\hat{U}\) back to \(U\), keeping the edges of \(T^{\prime}\) with their relabelled separators. (2) For each deleted edge \(U \to X\), add an edge between the relabelled \(i\) and \(j\) above, with separator \(S_{ij} = \{U\}\). (3) Assign each CPT and indicator of \(\mathcal{N}\) to the cluster that carried the corresponding factor of \(\mathcal{N}^{\prime}\) (same table, reindexed by the renaming); discard \(\Theta_{\hat{U}}\), \(\Theta_{\hat{S}|U}\) and \(\lambda_{\hat{s}}\).
\(G\) satisfies Definition 14.1. Property 1 holds by construction. Property 2: the family \(\{V\}\cup\hat{\mathbf{U}}\) of \(V\) in \(\mathcal{N}^{\prime}\) lies in some cluster of \(T^{\prime}\), and renaming clones back turns it into \(V\)’s family in \(\mathcal{N}\). Property 4: retained separators still sit inside the relabelled cluster intersections, and a new edge’s \(\{V\}\) lies in both its endpoints.
Property 3 is the substantive one. If no edge out of \(V\) was deleted, \(V\)’s clusters form a connected subtree of \(T^{\prime}\) and relabelling does not disturb it. If \(V \to X_1,\ldots,V \to X_m\) were deleted, the occurrences of \(V\) form a subtree \(T_V\) and those of each clone \(\hat{V}_k\) a subtree \(T_{\hat{V}_k}\), so after renaming \(V\) occupies the disconnected \(T_V \cup T_{\hat V_1}\cup\cdots\cup T_{\hat V_m}\). But step 2 adds, for each \(k\), an edge of separator \(\{V\}\) from \(i_k \in T_V\) (home of the family \(\{V,\hat S_k\}\), hence containing \(V\)) to \(j_k \in T_{\hat V_k}\) (containing \(\hat V_k\)), attaching every clone subtree to \(T_V\). Two clusters containing \(V\) are then joined either by a jointree path inside one subtree, or by walking to \(j_k\), crossing the new edge to \(i_k\), and walking inside \(T_V\) (concatenating two such walks for two distinct clone subtrees); every cluster and separator on such a path contains \(V\). (Check!)
IJGP on \(G\) simulates ED-BP on \(\mathcal{N}^{\prime}\). Fix edge parameters \(\Theta_{\hat{U}}, \Theta_{\hat{S}|U}\) for every deleted edge, let \(\Pr^{\prime}\) be the distribution they induce, and define candidate IJGP messages:
- On a new edge \(i-j\) created for the deleted edge \(U \to X\): \(M_{ij} := \Theta_{\hat{U}}\) (the message from the \(U\)-side to the \(X\)-side) and \(M_{ji} := \Theta_{\hat{s}|U}\) (the message from the \(X\)-side back to the \(U\)-side). Both are functions of the single separator variable \(U\), as required.
- On a retained \(T^{\prime}\)-edge: the corresponding jointree message computed by exact inference in \(\mathcal{N}^{\prime}\) with these parameters.
These are consistent: the only difference between \(C_i\) in \(T^{\prime}\) and in \(G\) is that \(G\) strips the factor \(\Theta_{\hat{S}|U}\lambda_{\hat{s}}\) – a function of \(U\) alone, of value \(\theta_{\hat{s}|U}\) – and supplies exactly that function as the incoming \(M_{ji}\), and likewise at \(C_j\) the factor \(\Theta_{\hat{U}}\) is replaced by the incoming \(M_{ij}\). Both algorithms multiply the cluster factor by the incoming messages before summing out, so by induction along \(T^{\prime}\) every retained-edge IJGP message equals the corresponding jointree message. From \(i\) to \(j\) the IJGP update excludes \(M_{ji} = \theta_{\hat{s}|U}\):
\begin{equation*} M_{ij} \;=\; \eta \sum_{C_i \setminus \{U\}} \Phi_i \prod_{k \neq j} M_{ki}. \end{equation*}
The right-hand side is the jointree computation of \(\Pr^{\prime}(U,\mathbf{e}^{\prime} - \hat{S})\) at \(C_i\) – it uses every factor and message of \(\mathcal{N}^{\prime}\) except the CPT and indicator of \(\hat{S}\), and dropping those is exactly retraction, \(\hat{S}\) being then a barren leaf – so after normalization \(M_{ij} = \Pr^{\prime}(U\mid\mathbf{e}^{\prime} - \hat{S})\), the ED-BP update for \(\Theta_{\hat{U}}\). From \(j\) to \(i\) the update excludes \(M_{ij} = \theta_{\hat{u}}\):
\begin{equation*} M_{ji} \;=\; \eta \sum_{C_j \setminus \{U\}} \Phi_j \prod_{k \neq i} M_{kj}. \end{equation*}
Its right-hand side is the jointree computation of \(\Pr^{\prime}(\hat{U},\mathbf{e}^{\prime})\) at \(C_j\) with \(\Theta_{\hat{U}}\) omitted, i.e. \(\Pr^{\prime}(\hat U,\mathbf{e}^{\prime})/ \theta_{\hat U} = \Pr^{\prime}(\mathbf{e}^{\prime}\mid\hat U)\) – legitimate since \(\hat U\) is a root, so \(\Theta_{\hat U}\) is a function of the separator variable alone and factors out of the summation. Hence \(M_{ji} = \eta\Pr^{\prime}(\mathbf{e}^{\prime}\mid\hat U)\), Equation 14.9.
Fixed points therefore correspond. If the edge parameters satisfy 14.8 and 14.9, the messages above reproduce themselves – retained-edge ones as jointree messages of a converged exact computation, new-edge ones by the two displays – so they are an IJGP fixed point on \(G\); conversely, setting \(\Theta_{\hat{U}} := M_{ij}\) and \(\Theta_{\hat{s}|U} := M_{ji}\) at an IJGP fixed point makes the retained-edge messages the jointree messages of \(\mathcal{N}^{\prime}\) under those parameters, and the same two displays turn the new-edge equations into 14.8 and 14.9. The joingraph beliefs are then the exact approximate-network marginals,
\begin{equation*} \mathrm{BEL}(C_i) = \Pr{}^{\prime}(C_i \mid \mathbf{e}^{\prime}), \qquad \mathrm{BEL}(S_{ij}) = \eta\,\theta_{\hat{U}}\theta_{\hat{s}|U} = \Pr{}^{\prime}(U \mid \mathbf{e}^{\prime}) \end{equation*}
on a new edge, each variable of \(G\) read as the \(\mathcal{N}^{\prime}\) variable it was renamed from, so that a cluster \(C_j\) carrying the family of \(X\) reports \(\Pr^{\prime}(X\hat{\mathbf{U}}\mid\mathbf{e}^{\prime})\). The second equality is the separator form of Exercise 14.12(b): \(\theta_{\hat u}\theta_{\hat s|u} \propto \Pr^{\prime}(u\mid \mathbf{e}^{\prime} - \hat S)\Pr^{\prime}(\mathbf{e}^{\prime}\mid\hat u) \propto \Pr^{\prime}(\mathbf{e}^{\prime} - \hat S, u)\theta_{\hat s|u} = \Pr^{\prime}(\mathbf{e}^{\prime}, u)\) by Fact 1 of that exercise. (Per-iteration correspondence additionally requires a schedule completing a full inward-outward sweep of the tree part of \(G\) between successive new-edge updates; Algorithm 41’s parallel schedule does not, though any sequential one with that property does.)
Let \(\mathcal{N}^{\prime}\) be a Bayesian network that results from deleting an edge \(U \to X\) that splits network \(\mathcal{N}\) into two disconnected subnetworks: \(\mathcal{N}_U\) containing \(U\) and \(\mathcal{N}_X\) containing \(X\). Let \(\mathbf{X}_U\) be the variables of subnetwork \(\mathcal{N}_U\) and \(\mathbf{X}_X\) be the variables of subnetwork \(\mathcal{N}_X\). As usual, deletion adds a root clone \(\hat{U}\) with CPT \(\Theta_{\hat{U}}\) as the new parent of \(X\), and an observed leaf \(\hat{S}\) with CPT \(\Theta_{\hat{S}|U}\) as a child of \(U\); the evidence \(\mathbf{e}\) of \(\mathcal{N}\) splits as \(\mathbf{e} = \mathbf{e}_U, \mathbf{e}_X\) over the two sides, and \(\mathbf{e}^{\prime} = \mathbf{e}, \hat{s}\).
If the parameters \(\Theta_{\hat{U}}\) and \(\Theta_{\hat{S}|U}\) are determined by Equations 14.8 and 14.9, show that the marginal distributions for each approximate subnetwork are exact:
\begin{equation*} \begin{aligned} \Pr{}^{\prime}(\mathbf{X}_U \mid \mathbf{e}^{\prime}) &= \Pr(\mathbf{X}_U \mid \mathbf{e}) \\ \Pr{}^{\prime}(\mathbf{X}_X \mid \mathbf{e}^{\prime}) &= \Pr(\mathbf{X}_X \mid \mathbf{e}). \end{aligned} \end{equation*}
Each side’s joint is a constant multiple of the corresponding joint in \(\mathcal{N}\); the constant cancels on normalizing. As in Exercise 14.11, the deleted edge is the only edge of \(\mathcal{N}\) crossing between \(\mathbf{X}_U\) and \(\mathbf{X}_X\), so the chain rule splits as
\begin{equation*} \Pr(\mathbf{x}_U, \mathbf{x}_X) = \Phi_U(\mathbf{x}_U)\,\Phi_X(\mathbf{x}_X, u), \end{equation*}
with \(\Phi_U\) the product of the CPTs of \(\mathcal{N}_U\), \(\Phi_X\) the product of the CPTs of \(\mathcal{N}_X\) (the value \(u\) entering only through \(X\)’s own CPT), and \(\sum_{\mathbf{x}_U}\Phi_U = 1\), \(\sum_{\mathbf{x}_X}\Phi_X(\cdot, u) = 1\) for each \(u\). In \(\mathcal{N}^{\prime}\) the same two factors reappear, with \(\hat{u}\) in place of \(u\):
\begin{equation*} \Pr{}^{\prime}(\mathbf{x}_U, \hat{s}, \hat{u}, \mathbf{x}_X) = \Phi_U(\mathbf{x}_U)\,\theta_{\hat{s}|u}\cdot \theta_{\hat{u}}\,\Phi_X(\mathbf{x}_X, \hat{u}), \end{equation*}
where \(u\) is the value \(\mathbf{x}_U\) assigns to \(U\). With \(L(u) = \sum_{\mathbf{x}_X \sim \mathbf{e}_X}\Phi_X(\mathbf{x}_X, u)\), Exercise 14.11 gives \(L(u) = \Pr(\mathbf{e}_X\mid u) = \Pr^{\prime}(\mathbf{e}_X\mid\hat u)\).
The edge parameters. The components of \(\mathcal{N}^{\prime}\) are \(\mathbf{X}_U\cup\{\hat S\}\) and \(\mathbf{X}_X\cup\{\hat U\}\), so splitting \(\mathbf{e}^{\prime} = \mathbf{e}_U,\hat s, \mathbf{e}_X\) across them gives \(\Pr^{\prime}(\mathbf{e}^{\prime}\mid\hat u) = \Pr^{\prime}(\mathbf{e}_U,\hat s)L(\hat u)\) with the first factor independent of \(\hat u\); so Equation 14.9 says
\begin{equation*} \theta_{\hat{s}|u} = \eta_1 L(u) \quad \text{for a constant } \eta_1 > 0. \quad (1) \end{equation*}
For Equation 14.8, \(\mathbf{e}^{\prime} - \hat{S} = \mathbf{e}_U,\mathbf{e}_X\) and \(U\) lies in the component carrying \(\mathbf{e}_U\), so \(\Pr^{\prime}(U\mid\mathbf{e}_U,\mathbf{e}_X) = \Pr^{\prime}(U\mid\mathbf{e}_U)\); and retracting \(\hat S\) makes it barren, so within its component the distribution is that of \(\mathcal{N}_U\), giving \(\Pr^{\prime}(u,\mathbf{e}_U) = \sum_{\mathbf{x}_U \sim u,\mathbf{e}_U}\Phi_U = \Pr(u,\mathbf{e}_U)\). Hence
\begin{equation*} \theta_{\hat{u}} = \Pr(u \mid \mathbf{e}_U) = \frac{\Pr(u, \mathbf{e}_U)}{\Pr(\mathbf{e}_U)}. \quad (2) \end{equation*}
The \(U\)-side. Let \(\mathbf{x}_U\) be consistent with \(\mathbf{e}_U\) (otherwise both sides vanish). Summing the \(\mathcal{N}^{\prime}\) joint over \(\hat{U}\) and over the \(\mathbf{x}_X\) consistent with \(\mathbf{e}_X\),
\begin{equation*} \begin{aligned} \Pr{}^{\prime}(\mathbf{x}_U, \mathbf{e}^{\prime}) &= \Phi_U(\mathbf{x}_U)\,\theta_{\hat{s}|u} \sum_{\hat{u}} \theta_{\hat{u}} \sum_{\mathbf{x}_X \sim \mathbf{e}_X}\Phi_X(\mathbf{x}_X, \hat{u}) \\ &= \Phi_U(\mathbf{x}_U)\,\theta_{\hat{s}|u} \cdot K, \qquad K := \sum_{\hat{u}} \theta_{\hat{u}} L(\hat{u}). \end{aligned} \end{equation*}
Substituting (1) gives \(\Pr^{\prime}(\mathbf{x}_U,\mathbf{e}^{\prime}) = \eta_1 K\, \Phi_U(\mathbf{x}_U)L(u)\), whereas in \(\mathcal{N}\), \(\Pr(\mathbf{x}_U,\mathbf{e}) = \Phi_U(\mathbf{x}_U)\sum_{\mathbf{x}_X\sim\mathbf{e}_X}\Phi_X(\mathbf{x}_X,u) = \Phi_U(\mathbf{x}_U)L(u)\). So \(\Pr^{\prime}(\mathbf{x}_U,\mathbf{e}^{\prime}) = \eta_1 K \Pr(\mathbf{x}_U,\mathbf{e})\) with \(\eta_1 K > 0\) independent of \(\mathbf{x}_U\); summing over \(\mathbf{x}_U\) gives \(\Pr^{\prime}(\mathbf{e}^{\prime}) = \eta_1 K\Pr(\mathbf{e})\), and dividing, \(\Pr^{\prime}(\mathbf{x}_U\mid\mathbf{e}^{\prime}) = \Pr(\mathbf{x}_U\mid\mathbf{e})\) – the first claim, using only Equation 14.9.
The \(X\)-side. Let \(\mathbf{x}_X\) be consistent with \(\mathbf{e}_X\). Summing the \(\mathcal{N}^{\prime}\) joint over \(\hat{U}\) and over the \(\mathbf{x}_U\) consistent with \(\mathbf{e}_U\), the two components factor:
\begin{equation*} \begin{aligned} \Pr{}^{\prime}(\mathbf{x}_X, \mathbf{e}^{\prime}) &= \Big(\sum_{\mathbf{x}_U \sim \mathbf{e}_U} \Phi_U(\mathbf{x}_U)\theta_{\hat{s}|u}\Big) \cdot \sum_{\hat{u}} \theta_{\hat{u}} \Phi_X(\mathbf{x}_X, \hat{u}) \\ &= C \sum_{u} \theta_{\hat{u}} \Phi_X(\mathbf{x}_X, u), \end{aligned} \end{equation*}
where \(C = \Pr^{\prime}(\mathbf{e}_U, \hat{s}) > 0\) does not depend on \(\mathbf{x}_X\). Substituting (2) turns this into \(\bigl(C/\Pr(\mathbf{e}_U)\bigr)\sum_u \Pr(u,\mathbf{e}_U) \Phi_X(\mathbf{x}_X,u)\), whereas in \(\mathcal{N}\), grouping the \(\mathbf{x}_U\) by the value \(u\) they assign to \(U\),
\begin{equation*} \Pr(\mathbf{x}_X, \mathbf{e}) = \sum_{\mathbf{x}_U \sim \mathbf{e}_U} \Phi_U(\mathbf{x}_U)\Phi_X(\mathbf{x}_X, u) = \sum_u \Pr(u, \mathbf{e}_U)\,\Phi_X(\mathbf{x}_X, u). \end{equation*}
Hence \(\Pr^{\prime}(\mathbf{x}_X, \mathbf{e}^{\prime}) = \big(C/\Pr(\mathbf{e}_U)\big) \Pr(\mathbf{x}_X, \mathbf{e})\), again with a constant independent of \(\mathbf{x}_X\); summing over \(\mathbf{x}_X\) and dividing gives \(\Pr^{\prime}(\mathbf{x}_X\mid\mathbf{e}^{\prime}) = \Pr(\mathbf{x}_X\mid\mathbf{e})\), the second claim, using only Equation 14.8. \(\square\)
Exercises 14.15–14.20
Recall the edge-deletion construction of Section 14.8: deleting an edge \(U \to X\) from network \(\mathrm{N}\) removes the edge and adds two variables — a clone \(\hat{U}\) that has the same values as \(U\) and becomes a parent of \(X\) (a root node with CPT \(\theta_{\hat u}\)), and a binary variable \(\hat{S}\) that is a child of \(U\) (with CPT \(\theta_{\hat s|u}\)) and is observed to \(\hat s\). The extended evidence is \(e^{\prime}\), consisting of the original evidence \(e\) together with the value \(\hat s\) for each added variable \(\hat S\).
Let \(\mathrm{N}^{\prime}\) be a polytree that results from deleting edges in network \(\mathrm{N}\), and suppose that the parameter edges of \(\mathrm{N}^{\prime}\) satisfy Equations 14.8 and 14.9,
\begin{equation*} \Theta_{\hat U} \;=\; Pr^{\prime}(U \mid e^{\prime} - \hat S), \qquad \Theta_{\hat s|U} \;=\; \eta\, Pr^{\prime}(e^{\prime} \mid \hat U) \ \ \text{for some } \eta > 0 . \end{equation*}
Suppose further that we are using the polytree algorithm (i.e., belief propagation) to compute the MI scores in Algorithm 43, where a deleted edge \(U \to X\) is ranked by
\begin{equation*} \mathrm{MI}(U; \hat U \mid e^{\prime}) \;=\; \sum_{u \hat u} Pr^{\prime}(u\hat u \mid e^{\prime}) \log \frac{Pr^{\prime}(u\hat u \mid e^{\prime})}{Pr^{\prime}(u \mid e^{\prime})\,Pr^{\prime}(\hat u \mid e^{\prime})} . \end{equation*}
To compute the MI score for each edge \(U \to X\) that we delete, we need two types of values:
- Node marginals \(Pr^{\prime}(u \mid e^{\prime})\) and \(Pr^{\prime}(\hat u \mid e^{\prime})\).
- Joint marginals \(Pr^{\prime}(u\hat u \mid e^{\prime})\).
If network \(\mathrm{N}\) has \(n\) nodes and \(m\) edges, and since \(\mathrm{N}^{\prime}\) is a polytree, at most \(n-1\) edges are left undeleted. Thus, we may need to score \(O(n^2)\) deleted edges in the worst case. Luckily, to compute every node marginal we only need to run belief propagation once. However, if we naively computed joint marginals \(Pr^{\prime}(u\hat u \mid e^{\prime})\), we could have run belief propagation \(O(m \max_U |U|^2)\) times: for each of our \(O(m)\) deleted edges, we could have run belief propagation once for each of the \(|U|^2\) instantiations \(u\hat u\). Consider the following:
\begin{equation*} Pr^{\prime}(u \hat u \mid e^{\prime}) \;=\; Pr^{\prime}(\hat u \mid u, e^{\prime})\, Pr^{\prime}(u \mid e^{\prime}) . \end{equation*}
Show that we can compute \(Pr^{\prime}(\hat u \mid u, e^{\prime})\) for all instantiations \(u\hat u\) using only \(O(n \max_U |U|)\) runs of belief propagation, thus showing that we need only the same number of runs of belief propagation to score all edges in Algorithm 43.
Index the runs by tail variables, not by deleted edges or by pairs: one run of belief propagation on the polytree \(\mathrm{N}^{\prime}\) returns the exact marginal of every node simultaneously, clones included, for whatever evidence it is conditioned on. Let \(\mathcal{T}\) be the set of tails of deleted edges, so \(|\mathcal{T}| \le n\), every tail being a node of \(\mathrm{N}\), and run:
- Run \(0\): evidence \(e^{\prime}\).
- For each \(U \in \mathcal{T}\) and each state \(u\) with \(Pr^{\prime}(u \mid e^{\prime}) > 0\): one run with evidence \(e^{\prime} \cup \{U = u\}\).
That is \(1 + \sum_{U\in\mathcal{T}}|U| \le 1 + n\max_U |U| = O(n\max_U|U|)\) runs. Run \(0\) delivers \(Pr^{\prime}(u \mid e^{\prime})\) and \(Pr^{\prime}(\hat u\mid e^{\prime})\) for every tail and every clone at once. Adding evidence leaves the structure a polytree, so belief propagation under \(e^{\prime} \cup \{U=u\}\) is still exact, and that single run reports \(Pr^{\prime}(\hat u \mid u, e^{\prime})\) for every clone \(\hat U\) of \(U\) and every \(\hat u\) simultaneously – so the \(|U|\) runs indexed by the states of \(U\) serve all deleted edges with tail \(U\), replacing the \(|U|^2\) runs indexed by pairs. States with \(Pr^{\prime}(u\mid e^{\prime}) = 0\) may be skipped: they make \(Pr^{\prime}(u\hat u\mid e^{\prime}) = 0\), which contributes nothing to \(\mathrm{MI}\) under \(0\log 0 = 0\).
The chain rule \(Pr^{\prime}(u\hat u\mid e^{\prime}) = Pr^{\prime}(\hat u\mid u,e^{\prime})Pr^{\prime}(u\mid e^{\prime})\) then assembles every score from stored numbers, at \(O(|U|^2)\) arithmetic per edge and no further inference – \(O(n^2\max_U|U|^2)\) arithmetic overall, but only \(O(n\max_U|U|)\) runs of belief propagation, as claimed.
Let \(\mathrm{N}\) and \(\mathrm{N}^{\prime}\) be two Bayesian networks that have the same structure but possibly different CPTs. Let \(Pr\) and \(Pr^{\prime}\) be their induced distributions, and recall that the KL divergence between two distributions over the same set of variables \(\mathbf{X}\) is
\begin{equation*} KL(Pr, Pr^{\prime}) \;=\; \sum_{\mathbf{x}} Pr(\mathbf{x}) \log \frac{Pr(\mathbf{x})}{Pr^{\prime}(\mathbf{x})} . \end{equation*}
Prove that
\begin{equation*} \begin{aligned} KL(Pr, Pr^{\prime}) &\;=\; \sum_{X\mathbf{U}} \sum_{\mathbf{u}} Pr(\mathbf{u}) \cdot KL\!\left(\Theta_{X|\mathbf{u}},\, \Theta^{\prime}_{X|\mathbf{u}}\right) \\ &\;=\; \sum_{X\mathbf{U}} \sum_{\mathbf{u}} Pr(\mathbf{u}) \cdot \sum_{x} \theta_{x|\mathbf{u}} \log \frac{\theta_{x|\mathbf{u}}}{\theta^{\prime}_{x|\mathbf{u}}}, \end{aligned} \end{equation*}
where \(\Theta_{X|\mathbf{U}}\) are CPTs in network \(\mathrm{N}\), \(\Theta^{\prime}_{X|\mathbf{U}}\) are the corresponding CPTs in network \(\mathrm{N}^{\prime}\), and \(X\mathbf{U}\) ranges over the families of the (shared) network structure.
Substitute the chain rule into the definition of \(KL\) and regroup by family. The shared structure gives the same families in both networks, so by Equation 4.2 \(Pr(\mathbf{x}) = \prod_{X\mathbf{U}}\theta_{x|\mathbf{u}}\) and \(Pr^{\prime}(\mathbf{x}) = \prod_{X\mathbf{U}}\theta^{\prime}_{x|\mathbf{u}}\) with \(x\mathbf{u} \sim \mathbf{x}\); if \(\theta^{\prime}_{x|\mathbf{u}} = 0 < \theta_{x|\mathbf{u}}\) for some family both sides are \(+\infty\), so assume not, and use \(0\log 0 = 0\). Taking logarithms, \(\log(Pr(\mathbf{x})/Pr^{\prime}(\mathbf{x})) = \sum_{X\mathbf{U}}\log(\theta_{x|\mathbf{u}}/ \theta^{\prime}_{x|\mathbf{u}})\), whence
\begin{equation*} \begin{aligned} KL(Pr, Pr^{\prime}) &= \sum_{X\mathbf{U}} \sum_{\mathbf{x}} Pr(\mathbf{x}) \log \frac{\theta_{x|\mathbf{u}}}{\theta^{\prime}_{x|\mathbf{u}}} \\ &= \sum_{X\mathbf{U}} \sum_{x\mathbf{u}} Pr(x\mathbf{u}) \log \frac{\theta_{x|\mathbf{u}}}{\theta^{\prime}_{x|\mathbf{u}}} \\ &= \sum_{X\mathbf{U}} \sum_{\mathbf{u}} Pr(\mathbf{u}) \sum_{x} \theta_{x|\mathbf{u}} \log \frac{\theta_{x|\mathbf{u}}}{\theta^{\prime}_{x|\mathbf{u}}} , \end{aligned} \end{equation*}
the second line grouping complete instantiations by the value they assign \(X\mathbf{U}\) (the summand depending on \(\mathbf{x}\) only through \(x\mathbf{u}\)), the third using \(Pr(x\mathbf{u}) = Pr(\mathbf{u})\theta_{x|\mathbf{u}}\) – the Bayesian network semantics of Chapter 4, and trivially true when \(Pr(\mathbf{u}) = 0\). Each CPT column being a distribution over the values of \(X\), the inner sum is \(KL(\Theta_{X|\mathbf{u}},\Theta^{\prime}_{X|\mathbf{u}})\), which is the first identity. \(\square\)
Suppose we have a network \(\mathrm{N}\) with a variable \(X\) that has parents \(Y\) and \(\mathbf{U}\). Suppose that deleting the edge \(Y \to X\) results in a network \(\mathrm{N}^{\prime}\) where
- \(\mathrm{N}^{\prime}\) has the same structure as \(\mathrm{N}\) except that edge \(Y \to X\) is removed.
- The CPT for variable \(X\) in \(\mathrm{N}^{\prime}\) is given by \(\theta^{\prime}_{x|\mathbf{u}} \stackrel{\text{def}}{=} Pr(x \mid \mathbf{u})\).
- The CPTs for variables other than \(X\) in \(\mathrm{N}^{\prime}\) are the same as those in \(\mathrm{N}\).
(a) Prove that when we delete a single edge \(Y \to X\), we have
\begin{equation*} \begin{aligned} KL(Pr, Pr^{\prime}) &\;=\; \mathrm{MI}(X; Y \mid \mathbf{U}) \\ &\;=\; \sum_{xy\mathbf{u}} Pr(xy\mathbf{u}) \log \frac{Pr(xy \mid \mathbf{u})}{Pr(x \mid \mathbf{u}) Pr(y \mid \mathbf{u})} . \end{aligned} \end{equation*}
(b) Prove that when we delete multiple edges but at most one edge \(Y \to X\) incoming into \(X\) is deleted, the error is additive:
\begin{equation*} KL(Pr, Pr^{\prime}) \;=\; \sum_{Y \to X} \mathrm{MI}(X; Y \mid \mathbf{U}) . \end{equation*}
(c) Identify a small network conditioned on some evidence \(e\) where the KL divergence \(KL(Pr(X|e), Pr^{\prime}(X|e))\) can be made arbitrarily large even when the divergence \(KL(Pr, Pr^{\prime})\) can be made arbitrarily close to zero. Hint: a two-node network \(A \to B\) suffices.
Exercise 14.16 needs a shared structure, so replace \(\mathrm{N}^{\prime}\) by the network \(\mathrm{N}^{\prime\prime}\) with the structure of \(\mathrm{N}\), the CPT \(\theta^{\prime\prime}_{x|y\mathbf{u}} = Pr(x\mid\mathbf{u})\) for \(X\) (the same value for every \(y\), so every column sums to one) and the CPTs of \(\mathrm{N}\) elsewhere: its chain-rule product is term by term that of \(\mathrm{N}^{\prime}\), the \(X\)-factor merely carrying a vacuous extra argument \(y\), so \(Pr^{\prime\prime} = Pr^{\prime}\).
(a) Exercise 14.16 writes \(KL(Pr,Pr^{\prime}) = KL(Pr,Pr^{\prime\prime})\) as a sum over the families \(Z\mathbf{V}\) of \(\mathrm{N}\), and every family other than \(X\,Y\mathbf{U}\) has \(\theta^{\prime\prime}_{z|\mathbf{v}} = \theta_{z|\mathbf{v}}\), hence zero inner divergence. Only the family of \(X\) survives:
\begin{equation*} \begin{aligned} KL(Pr, Pr^{\prime}) &= \sum_{y\mathbf{u}} Pr(y\mathbf{u}) \sum_{x} \theta_{x|y\mathbf{u}} \log \frac{\theta_{x|y\mathbf{u}}}{\theta^{\prime\prime}_{x|y\mathbf{u}}} \\ &= \sum_{xy\mathbf{u}} Pr(y\mathbf{u})\, Pr(x \mid y\mathbf{u}) \log \frac{Pr(x \mid y\mathbf{u})}{Pr(x \mid \mathbf{u})} \\ &= \sum_{xy\mathbf{u}} Pr(xy\mathbf{u}) \log \frac{Pr(x \mid y\mathbf{u})}{Pr(x \mid \mathbf{u})}, \end{aligned} \end{equation*}
using \(\theta_{x|y\mathbf{u}} = Pr(x \mid y\mathbf{u})\) and \(Pr(y\mathbf{u})Pr(x \mid y\mathbf{u}) = Pr(xy\mathbf{u})\). The chain rule inside the conditioning event \(\mathbf{u}\) gives \(Pr(x\mid y\mathbf{u}) = Pr(xy\mid\mathbf{u})/ Pr(y\mid\mathbf{u})\), so the summand’s ratio is \(Pr(xy\mid\mathbf{u})/[Pr(x\mid\mathbf{u})Pr(y\mid\mathbf{u})]\), which makes the sum \(\mathrm{MI}(X;Y\mid\mathbf{U})\) by definition, since \(\sum_{xy\mathbf{u}}Pr(xy\mathbf{u})f = \sum_{\mathbf{u}}Pr(\mathbf{u})\sum_{xy}Pr(xy\mid\mathbf{u})f\).
(b) Let \(\mathcal{D}\) be the deleted edges, no two sharing a head. For \(Y \to X \in \mathcal{D}\) write \(\mathbf{U}\) for \(X\)’s other parents in \(\mathrm{N}\); by the stipulation these are exactly \(X\)’s parents in \(\mathrm{N}^{\prime}\), so \(\theta^{\prime}_{x|\mathbf{u}} = Pr(x\mid\mathbf{u})\) is well posed. Form \(\mathrm{N}^{\prime\prime}\) as before, putting \(\theta^{\prime\prime}_{x|y\mathbf{u}} = Pr(x\mid\mathbf{u})\) at each head; again \(Pr^{\prime\prime} = Pr^{\prime}\). Exercise 14.16 makes the divergence a sum over families in which a family contributes zero unless its CPT changed, and the changed families are exactly those of the heads – pairwise distinct, so no family is changed twice. The contribution of the family of head \(X\) is, by the computation of (a) verbatim,
\begin{equation*} \sum_{y\mathbf{u}} Pr(y\mathbf{u}) \sum_{x} \theta_{x|y\mathbf{u}} \log \frac{\theta_{x|y\mathbf{u}}}{Pr(x \mid \mathbf{u})} \;=\; \mathrm{MI}(X; Y \mid \mathbf{U}). \end{equation*}
Summing over families,
\begin{equation*} KL(Pr, Pr^{\prime}) \;=\; \sum_{Y \to X \,\in\, \mathcal{D}} \mathrm{MI}(X; Y \mid \mathbf{U}), \end{equation*}
which is the claimed additivity. The hypothesis is needed: two deleted edges \(Y_1 \to X\), \(Y_2 \to X\) into the same child would give the family of \(X\) one divergence term \(\sum_{\mathbf{u}}Pr(\mathbf{u})KL(\Theta_{X|y_1y_2\mathbf{u}},\Theta^{\prime}_{X|\mathbf{u}})\) that does not in general split into two mutual informations.
(c) Take \(A \to B\) with \(A, B\) binary and \(\delta \in (0,1/2)\):
\begin{equation*} \theta_a = \delta, \qquad \theta_{\bar a} = 1 - \delta, \qquad \theta_{b|a} = 1, \qquad \theta_{b|\bar a} = \delta^2 . \end{equation*}
Delete \(A \to B\), so \(\mathrm{N}^{\prime}\) has two roots, \(A\) keeping its CPT and \(B\) getting \(\theta^{\prime}_b = Pr(b) = \delta + (1-\delta)\delta^2\); take \(e = b\) and query \(A\). In \(\mathrm{N}^{\prime}\) the two variables are independent, so \(Pr^{\prime}(a\mid b) = Pr(a) = \delta\), while by Bayes’ rule
\begin{equation*} Pr(a \mid b) = \frac{\delta}{\delta + (1-\delta)\delta^2} = \frac{1}{1 + (1-\delta)\delta} \;\longrightarrow\; 1 \quad (\delta \to 0). \end{equation*}
With \(p = Pr(a \mid b)\),
\begin{equation*} KL\!\left(Pr(A|b), Pr^{\prime}(A|b)\right) = p \log \frac{p}{\delta} + (1-p) \log \frac{1-p}{1-\delta} \;\ge\; p \log \frac{p}{\delta} - \tfrac{1}{e} , \end{equation*}
using \(t\log t \ge -1/e\) and \(\log\frac{1}{1-\delta} > 0\); since \(p \ge 1/2\) for small \(\delta\), the first term is at least \(\tfrac12\log\frac{1}{2\delta} \to +\infty\). Meanwhile by (a) with \(\mathbf{U} = \emptyset\), \(KL(Pr,Pr^{\prime}) = \mathrm{MI}(A;B)\), which is the average of the conditional divergences,
\begin{equation*} \mathrm{MI}(A;B) \;=\; Pr(b)\, KL\!\left(Pr(A|b), Pr(A)\right) \;+\; Pr(\bar b)\, KL\!\left(Pr(A|\bar b), Pr(A)\right) . \end{equation*}
The first term is \(O(\delta\log(1/\delta))\), since \(Pr(b) \le 2\delta\) multiplies a divergence of order \(\log(1/\delta)\); the second is \(O(\delta)\), since \(\theta_{\bar b|a} = 0\) forces \(Pr(a\mid\bar b) = 0\), whence \(KL(Pr(A|\bar b),Pr(A)) = \log\frac{1}{1-\delta}\). So \(\mathrm{MI}(A;B) \to 0\). Numerically:
| \(\delta\) | \(KL(Pr,Pr^{\prime}) = \mathrm{MI}(A;B)\) | \(KL(Pr(A \mid b), Pr^{\prime}(A \mid b))\) |
|---|---|---|
| \(10^{-2}\) | \(0.0554\) | \(4.505\) |
| \(10^{-3}\) | \(0.00790\) | \(6.893\) |
| \(10^{-4}\) | \(0.00102\) | \(9.208\) |
| \(10^{-6}\) | \(1.48 \times 10^{-5}\) | \(13.815\) |
(natural logarithms). Thus \(KL(Pr, Pr^{\prime})\) can be driven to zero while \(KL(Pr(A|b), Pr^{\prime}(A|b))\) grows without bound.
Recall the edge-deletion construction: deleting an edge \(U \to X\) from network \(\mathrm{N}\) removes the edge, adds a clone \(\hat U\) (a root with the same values as \(U\) and CPT \(\theta_{\hat u}\)) as a parent of \(X\), and adds a binary child \(\hat S\) of \(U\) (with CPT \(\theta_{\hat s|u}\)) that is observed to \(\hat s\). The evidence \(e^{\prime}\) is the original evidence \(e\) plus \(\hat s\) for each added \(\hat S\).
Let \(\mathrm{N}^{\prime}\) be a Bayesian network that results from deleting edges \(U \to X\) from network \(\mathrm{N}\). Show that the edge parameters of network \(\mathrm{N}^{\prime}\) satisfy Equations 14.8 and 14.9,
\begin{equation*} \Theta_{\hat U} = Pr^{\prime}(U \mid e^{\prime} - \hat S), \qquad \Theta_{\hat s|U} = \eta\, Pr^{\prime}(e^{\prime} \mid \hat U) \ \ \text{for some constant } \eta > 0, \end{equation*}
if and only if the edge parameters are a stationary point of \(Pr^{\prime}(e^{\prime}) \cdot \frac{1}{z}\), where \(z\) is given by Equation 14.16,
\begin{equation*} z \;=\; \prod_{U \to X} z_{UX}, \qquad z_{UX} \;=\; \sum_{u = \hat u} \theta_{\hat u}\, \theta_{\hat s|u}, \end{equation*}
the product ranging over all deleted edges.
Both conditions reduce to the single system \((\mathrm{F})\) below, \(\theta_{\hat u}\theta_{\hat s|u} = z_{UX}Pr^{\prime}(u\mid e^{\prime}) = z_{UX}Pr^{\prime}(\hat u\mid e^{\prime})\). The free variables are the edge parameters \(\theta_{\hat u}\) (one per state of each clone) and \(\theta_{\hat s|u}\) (one per state of each tail), one group per deleted edge; all other CPTs are inherited and fixed, and we work at an interior point, every such parameter strictly positive and \(Pr^{\prime}(e^{\prime}) > 0\). Write \(G = P/z\) with \(P = Pr^{\prime}(e^{\prime})\), \(z = \prod_{U\to X} z_{UX}\).
\(P\) is multilinear in the edge parameters. Expanding the network polynomial of \(\mathrm{N}^{\prime}\) under evidence \(e^{\prime}\),
\begin{equation*} P \;=\; \sum_{\mathbf{z}} \lambda_{e^{\prime}}(\mathbf{z}) \prod_{V\mathbf{W}} \theta_{v|\mathbf{w}}, \end{equation*}
with \(\lambda_{e^{\prime}}(\mathbf{z}) \in \{0,1\}\) recording compatibility, each surviving term carries exactly one factor \(\theta_{\hat u}\) per clone and one \(\theta_{\hat s|u}\) per \(\hat S\) (terms with \(\hat S = \bar{\hat s}\) being killed by \(\lambda_{e^{\prime}}\)). Collecting the terms with \(\hat U = \hat u\) and dividing by \(\theta_{\hat u}\), and likewise for \(\theta_{\hat s|u}\), gives
\begin{equation*} \begin{aligned} \frac{\partial P}{\partial \theta_{\hat u}} &= \frac{Pr^{\prime}(e^{\prime}, \hat u)}{\theta_{\hat u}}, \\ \frac{\partial P}{\partial \theta_{\hat s|u}} &= \frac{Pr^{\prime}(e^{\prime}, \hat s, u)}{\theta_{\hat s|u}} = \frac{Pr^{\prime}(e^{\prime}, u)}{\theta_{\hat s|u}}, \end{aligned} \end{equation*}
the last step because \(\hat s\) already belongs to \(e^{\prime}\).
\(G\) is scale-invariant, so the simplex constraint carries no multiplier. Scaling \(\theta_{\hat u} \mapsto \alpha\theta_{\hat u}\) for all \(\hat u\) at one deleted edge sends \(P \mapsto \alpha P\) (one such factor per term) and \(z_{UX} \mapsto \alpha z_{UX}\), hence \(z \mapsto \alpha z\), leaving \(G\) unchanged; the same holds for the group \(\{\theta_{\hat s|u}\}_u\). Euler’s relation for a degree-\(0\) homogeneous function gives
\begin{equation*} \sum_{\hat u} \theta_{\hat u} \frac{\partial G}{\partial \theta_{\hat u}} = 0, \qquad \sum_{u} \theta_{\hat s|u} \frac{\partial G}{\partial \theta_{\hat s|u}} = 0 . \end{equation*}
The \(\theta_{\hat s|u}\) are unconstrained coordinates (\(\hat S\) being observed, the values \(\theta_{\bar{\hat s}|u}\) never appear in \(G\)), so stationarity there is \(\partial G/\partial\theta_{\hat s|u} = 0\). The \(\theta_{\hat u}\) lie on the simplex, so stationarity is \(\partial G/\partial\theta_{\hat u} = \mu_{UX}\) for a common multiplier; multiplying by \(\theta_{\hat u}\) and summing, Euler gives \(0 = \mu_{UX}\sum_{\hat u} \theta_{\hat u} = \mu_{UX}\). So stationarity is exactly \(\partial G/\partial\theta_{\hat u} = \partial G/\partial\theta_{\hat s|u} = 0\) at every deleted edge and state. Since \(\partial z/\partial\theta_{\hat s|u} = (z/z_{UX})\theta_{\hat u}\) and \(\partial z/\partial\theta_{\hat u} = (z/z_{UX})\theta_{\hat s|u}\) (states \(u = \hat u\)), the quotient rule gives
\begin{equation*} \frac{\partial G}{\partial \theta_{\hat s|u}} = \frac{1}{z^2}\left[ \frac{Pr^{\prime}(e^{\prime}, u)}{\theta_{\hat s|u}} \, z \;-\; P \, \frac{z}{z_{UX}} \, \theta_{\hat u} \right]. \end{equation*}
Setting this to zero and multiplying through by \(z_{UX}\theta_{\hat s|u}/z\) gives \(Pr^{\prime}(e^{\prime},u)z_{UX} = P\theta_{\hat u}\theta_{\hat s|u}\), i.e. \(\theta_{\hat u} \theta_{\hat s|u} = z_{UX}Pr^{\prime}(u\mid e^{\prime})\); in the same way \(\partial G/ \partial\theta_{\hat u} = 0\) gives \(\theta_{\hat u}\theta_{\hat s|u} = z_{UX} Pr^{\prime}(\hat u\mid e^{\prime})\). So stationarity of \(Pr^{\prime}(e^{\prime})/z\) is equivalent to
\begin{equation*} \begin{aligned} \theta_{\hat u} \theta_{\hat s|u} &\;=\; z_{UX}\, Pr^{\prime}(u \mid e^{\prime}) \;=\; z_{UX}\, Pr^{\prime}(\hat u \mid e^{\prime}) \\ &\quad \text{for every deleted edge and every } u = \hat u, \end{aligned} \tag{F} \end{equation*}
which is Equation 14.26 from the proof of Lemma 14.1; it remains to prove (F) \(\iff\) (14.8) and (14.9). Two facts recur: \(\hat U\) is a root, so \(Pr^{\prime}(\hat u) = \theta_{\hat u}\); and \(\hat S\) is a leaf whose only parent is \(U\), hence d-separated from everything else by \(U\), so
\begin{equation*} \begin{aligned} Pr^{\prime}(\hat s \mid u, e^{\prime} - \hat S) &\;=\; Pr^{\prime}(\hat s \mid u) \;=\; \theta_{\hat s|u}, \\ \text{hence} \quad Pr^{\prime}(u, e^{\prime}) &\;=\; Pr^{\prime}(u, e^{\prime} - \hat S)\, \theta_{\hat s|u} . \end{aligned} \tag{C} \end{equation*}
(14.8) and (14.9) imply (F). Fix a deleted edge. Using (14.9) and \(Pr^{\prime}(\hat u) = \theta_{\hat u}\),
\begin{equation*} \theta_{\hat u} \theta_{\hat s|u} = \theta_{\hat u} \cdot \eta\, Pr^{\prime}(e^{\prime} \mid \hat u) = \eta\, Pr^{\prime}(\hat u, e^{\prime}) = \eta\, Pr^{\prime}(e^{\prime})\, Pr^{\prime}(\hat u \mid e^{\prime}). \tag{D} \end{equation*}
Using (14.8) and then (C),
\begin{equation*} \begin{aligned} \theta_{\hat u} \theta_{\hat s|u} &= Pr^{\prime}(u \mid e^{\prime} - \hat S)\, \theta_{\hat s|u} = \frac{Pr^{\prime}(u, e^{\prime} - \hat S)\, \theta_{\hat s|u}}{Pr^{\prime}(e^{\prime} - \hat S)} \\ &= \frac{Pr^{\prime}(u, e^{\prime})}{Pr^{\prime}(e^{\prime} - \hat S)} = Pr^{\prime}(u \mid e^{\prime}) \cdot \frac{Pr^{\prime}(e^{\prime})}{Pr^{\prime}(e^{\prime} - \hat S)} . \end{aligned} \tag{E} \end{equation*}
Summing (D) and (E) over the states \(u = \hat u\), both left sides being \(z_{UX}\) by definition and both posteriors summing to \(1\), gives \(z_{UX} = \eta Pr^{\prime}(e^{\prime}) = Pr^{\prime}(e^{\prime})/Pr^{\prime}(e^{\prime} - \hat S)\), so \(\eta = [Pr^{\prime}(e^{\prime} - \hat S)]^{-1}\); substituting back into (D) and (E) yields (F).
(F) implies (14.8) and (14.9). The second equality of (F) with \(Pr^{\prime}(\hat u) = \theta_{\hat u}\), and the first with (C), give
\begin{equation*} \begin{aligned} \theta_{\hat u}\theta_{\hat s|u} &= z_{UX}\frac{\theta_{\hat u}\,Pr^{\prime}(e^{\prime}\mid\hat u)}{Pr^{\prime}(e^{\prime})}, \\ \theta_{\hat u}\theta_{\hat s|u} &= z_{UX}\frac{Pr^{\prime}(u, e^{\prime} - \hat S)\,\theta_{\hat s|u}}{Pr^{\prime}(e^{\prime})} . \end{aligned} \end{equation*}
Dividing the first by \(\theta_{\hat u} > 0\) gives \(\theta_{\hat s|u} = \eta Pr^{\prime}(e^{\prime}\mid \hat u)\) with \(\eta = z_{UX}/Pr^{\prime}(e^{\prime}) > 0\) independent of \(u\), Equation 14.9. Dividing the second by \(\theta_{\hat s|u} > 0\) gives \(\theta_{\hat u} = c\,Pr^{\prime}(u\mid e^{\prime} - \hat S)\) with \(c\) independent of \(u\); summing over the states and using \(\sum_{\hat u}\theta_{\hat u} = 1\) and \(\sum_u Pr^{\prime}(u\mid e^{\prime} - \hat S) = 1\) gives \(c = 1\), Equation 14.8 – at every deleted edge simultaneously, hence for the whole parameterization. \(\square\)
Prove Equation 14.27 on Page 376. That is, let \(\mathrm{N}^{\prime}\) be the network that results from deleting every edge of a Bayesian network \(\mathrm{N}\) — so that for each deleted edge \(U \to X\) a clone \(\hat U\) (a root, parent of \(X\)) and an observed leaf \(\hat S\) (a child of \(U\)) are added, and \(e^{\prime}\) is the original evidence \(e\) together with \(\hat s\) for every added \(\hat S\). Let
\begin{equation*} \mathrm{ENT} \;=\; -\sum_{\mathbf{x}} Pr^{\prime}(\mathbf{x} \mid e^{\prime}) \log Pr^{\prime}(\mathbf{x} \mid e^{\prime}) \end{equation*}
be the entropy of the distribution \(Pr^{\prime}(\mathbf{X} \mid e^{\prime})\), where \(\mathbf{X}\) is the set of all variables of \(\mathrm{N}^{\prime}\). Show that, because \(\mathrm{N}^{\prime}\) is fully disconnected, this entropy decomposes as
\begin{equation*} \mathrm{ENT} \;=\; -\sum_{X\hat{\mathbf{U}}} \sum_{x\hat{\mathbf{u}}} Pr^{\prime}(x\hat{\mathbf{u}} \mid e^{\prime}) \log Pr^{\prime}(x\hat{\mathbf{u}} \mid e^{\prime}), \end{equation*}
where \(X\) ranges over the variables of the original network \(\mathrm{N}\) and \(\hat{\mathbf{U}}\) are the cloned parents of \(X\) in \(\mathrm{N}^{\prime}\).
Every edge being deleted, \(\mathrm{N}^{\prime}\) splits into one component per variable \(X\) of \(\mathrm{N}\),
\begin{equation*} C_X \;=\; \{X\} \cup \{\hat U_1, \ldots, \hat U_k\} \cup \{\hat S_1, \ldots, \hat S_m\}, \end{equation*}
where \(U_1,\ldots,U_k\) are \(X\)’s parents and \(Y_1,\ldots,Y_m\) its children in \(\mathrm{N}\): each clone \(\hat U_i\) is a root whose only child is \(X\), each \(\hat S_j\) a leaf whose only parent is \(X\) (observed at \(\hat s_j\)), so \(X\)’s neighbours are exactly these and theirs is exactly \(X\). Every variable of \(\mathrm{N}^{\prime}\) lies in exactly one such component – clones and auxiliaries are created fresh, one per deleted edge, each attached to one original variable – so \(\mathbf{X} = \biguplus_X C_X\).
By the chain rule \(Pr^{\prime}\) is the product of all CPTs, and each CPT belongs to one component (a family never straddles two, being a node plus its parents), so for a complete instantiation \(\mathbf{x} = (c_X)_X\),
\begin{equation*} Pr^{\prime}(\mathbf{x}) \;=\; \prod_{X} Pr^{\prime}(c_X), \end{equation*}
where \(Pr^{\prime}(c_X)\) is the marginal over \(C_X\) – the product of that component’s CPTs, itself a normalized distribution. The evidence splits likewise, \(e^{\prime} = \biguplus_X e^{\prime}_X\), so writing \(\lambda_{e^{\prime}}(\mathbf{x}) = \prod_X \lambda_{e^{\prime}_X}(c_X)\) and normalizing,
\begin{equation*} \begin{aligned} Pr^{\prime}(\mathbf{x} \mid e^{\prime}) &= \frac{\prod_X Pr^{\prime}(c_X)\lambda_{e^{\prime}_X}(c_X)}{\prod_X Pr^{\prime}(e^{\prime}_X)} \\ &= \prod_X Pr^{\prime}(c_X \mid e^{\prime}_X) = \prod_X Pr^{\prime}(c_X \mid e^{\prime}), \end{aligned} \end{equation*}
the last equality because \(C_X\) is d-separated from the rest by the empty set. Entropy is additive over such blocks: for \(P(\mathbf{x}) = \prod_i P_i(w_i)\) over disjoint \(W_1,\ldots,W_r\), with \(0\log 0 = 0\),
\begin{equation*} \begin{aligned} -\sum_{\mathbf{x}} P(\mathbf{x}) \log P(\mathbf{x}) &= -\sum_i \sum_{w_i} \Bigl( \sum_{\mathbf{x} \sim w_i} P(\mathbf{x}) \Bigr) \log P_i(w_i)\\ &= -\sum_i \sum_{w_i} P_i(w_i) \log P_i(w_i), \end{aligned} \end{equation*}
the inner sum marginalizing \(P\) down to \(P_i(w_i)\). With \(P = Pr^{\prime}(\cdot\mid e^{\prime})\) and blocks \(C_X\), this makes \(\mathrm{ENT} = -\sum_X\sum_{c_X}Pr^{\prime}(c_X\mid e^{\prime})\log Pr^{\prime}(c_X\mid e^{\prime})\). Finally write \(c_X = (x,\hat{\mathbf{u}},\hat{\mathbf{s}})\). Every \(\hat S_j\) is instantiated by \(e^{\prime}\), so \(Pr^{\prime}(c_X\mid e^{\prime}) = 0\) unless \(\hat{\mathbf{s}}\) is the observed instantiation, in which case it equals \(Pr^{\prime}(x\hat{\mathbf{u}}\mid e^{\prime})\); the vanishing terms contribute nothing under \(0\log 0 = 0\), so the inner sum collapses to one over \(x\hat{\mathbf{u}}\). Since \(X\hat{\mathbf{U}}\) is exactly the family of \(X\) in \(\mathrm{N}^{\prime}\),
\begin{equation*} \mathrm{ENT} \;=\; -\sum_{X\hat{\mathbf{U}}} \sum_{x\hat{\mathbf{u}}} Pr^{\prime}(x\hat{\mathbf{u}} \mid e^{\prime}) \log Pr^{\prime}(x\hat{\mathbf{u}} \mid e^{\prime}), \end{equation*}
which is Equation 14.27. \(\square\)
Consider a Bayesian network with families \(X\mathbf{U}\) and distribution \(Pr(\mathbf{X})\), and let \(\lambda_e(x)\) denote the evidence indicator of variable \(X\) at value \(x\), that is, \(\lambda_e(x) = 0\) if evidence \(e\) sets \(X\) to a value other than \(x\) and \(\lambda_e(x) = 1\) otherwise. Show that for evidence \(e\) with \(Pr(e) > 0\), we have \(\log Pr(e) = \mathrm{ENT} + \mathrm{AVG}\) where
- \(\mathrm{ENT} = -\sum_{\mathbf{x}} Pr(\mathbf{x} \mid e) \log Pr(\mathbf{x} \mid e)\) is the entropy of distribution \(Pr(\mathbf{X} \mid e)\).
- \(\mathrm{AVG} = \sum_{X\mathbf{U}} \sum_{x\mathbf{u}} Pr(x\mathbf{u} \mid e) \log \lambda_e(x)\theta_{x|\mathbf{u}}\) is a sum of expectations over network parameters.
Average the pointwise identity \(\log Pr(e) = \log Pr(\mathbf{x},e) - \log Pr(\mathbf{x}\mid e)\) against \(Pr(\mathbf{x}\mid e)\). Throughout \(p\log q\) is read as \(0\) whenever \(p = 0\), which makes the terms with \(\lambda_e(x) = 0\) or \(\theta_{x|\mathbf{u}} = 0\) harmless: both force \(Pr(x\mathbf{u}\mid e) = 0\). By the chain rule \(Pr(\mathbf{x}) = \prod_{X\mathbf{U}} \theta_{x|\mathbf{u}}\) with \(x\mathbf{u}\sim\mathbf{x}\), while \(\prod_X\lambda_e(x)\) is \(1\) exactly when \(\mathbf{x} \sim e\) and \(0\) otherwise, and \(Pr(\mathbf{x},e)\) is \(Pr(\mathbf{x})\) or \(0\) accordingly. Hence
\begin{equation*} Pr(\mathbf{x}, e) \;=\; \prod_{X\mathbf{U}} \lambda_e(x)\, \theta_{x|\mathbf{u}}, \qquad x\mathbf{u} \sim \mathbf{x}, \end{equation*}
one factor per variable, so \(\log Pr(\mathbf{x},e) = \sum_{X\mathbf{U}}\log\lambda_e(x) \theta_{x|\mathbf{u}}\) whenever \(Pr(\mathbf{x},e) > 0\). Multiplying the pointwise identity by \(Pr(\mathbf{x}\mid e)\) and summing over the \(\mathbf{x}\) with \(Pr(\mathbf{x}\mid e) > 0\), the left side becomes \(\log Pr(e)\) since \(\sum_{\mathbf{x}}Pr(\mathbf{x}\mid e) = 1\), and
\begin{equation*} \begin{aligned} \log Pr(e) \;=\;& \sum_{\mathbf{x}} Pr(\mathbf{x} \mid e) \log Pr(\mathbf{x}, e) \\ &-\; \sum_{\mathbf{x}} Pr(\mathbf{x} \mid e) \log Pr(\mathbf{x} \mid e) . \end{aligned} \end{equation*}
The second sum is, with its minus sign, the entropy \(\mathrm{ENT}\) of \(Pr(\mathbf{X}\mid e)\). For the first, substitute the parameter product and exchange the two finite sums,
\begin{equation*} \begin{aligned} \sum_{\mathbf{x}} Pr(\mathbf{x} \mid e) \log Pr(\mathbf{x}, e) &= \sum_{\mathbf{x}} Pr(\mathbf{x} \mid e) \sum_{X\mathbf{U}} \log \lambda_e(x)\theta_{x|\mathbf{u}} \\ &= \sum_{X\mathbf{U}} \sum_{\mathbf{x}} Pr(\mathbf{x} \mid e) \log \lambda_e(x)\theta_{x|\mathbf{u}} . \end{aligned} \end{equation*}
and for a fixed family the summand depends on \(\mathbf{x}\) only through \(x\mathbf{u}\), so group the complete instantiations accordingly:
\begin{equation*} \begin{aligned} \sum_{\mathbf{x}} Pr(\mathbf{x} \mid e) \log \lambda_e(x)\theta_{x|\mathbf{u}} &= \sum_{x\mathbf{u}} \left( \sum_{\mathbf{x} \sim x\mathbf{u}} Pr(\mathbf{x} \mid e) \right) \log \lambda_e(x)\theta_{x|\mathbf{u}} \\ &= \sum_{x\mathbf{u}} Pr(x\mathbf{u} \mid e) \log \lambda_e(x)\theta_{x|\mathbf{u}}, \end{aligned} \end{equation*}
the inner sum being the family marginal \(Pr(x\mathbf{u}\mid e)\). Summing over families, the first sum is \(\mathrm{AVG}\), so \(\log Pr(e) = \mathrm{ENT} + \mathrm{AVG}\). \(\square\)
Approximate Inference by Stochastic Sampling
Exercises 15.1–15.7
Let \(N_a\) be the number of students in a class having age \(a\):
| Age \(a\) | \(N_a\) |
|---|---|
| 18 | 5 |
| 19 | 15 |
| 20 | 21 |
| 21 | 30 |
| 22 | 20 |
| 23 | 6 |
| 24 | 3 |
What is the expected age of a student chosen randomly from this class? Formulate this problem by defining a function \(f\) where the expected value of the function corresponds to the answer. Compute the variance of the identified function.
Expected age \(20.75\) years, variance \(1.9075\). Take \(X\) ranging over the students with \(\Pr(X)\) uniform and \(f(x)\) the age of student \(x\); the answer is \(\mathrm{Ex}(f)\). Grouping the \(N = \sum_a N_a = 100\) equiprobable students by age gives \(\Pr(f = a) = N_a/N\), so by Equation 15.1
\begin{equation*} \mathrm{Ex}(f) \;=\; \sum_{x} f(x)\Pr(x) \;=\; \sum_{a} a\,\frac{N_a}{N} \;=\; \frac{1}{100}\sum_a a\,N_a . \end{equation*}
Term by term:
| \(a\) | 18 | 19 | 20 | 21 | 22 | 23 | 24 | sum |
|---|---|---|---|---|---|---|---|---|
| \(N_a\) | 5 | 15 | 21 | 30 | 20 | 6 | 3 | 100 |
| \(aN_a\) | 90 | 285 | 420 | 630 | 440 | 138 | 72 | 2075 |
\begin{equation*} \mathrm{Ex}(f) \;=\; \frac{2075}{100} \;=\; 20.75 \text{ years}. \end{equation*}
By \(\mathrm{Va}(f) = \mathrm{Ex}(f^2) - \mathrm{Ex}(f)^2\) (Exercise 15.2):
| \(a\) | 18 | 19 | 20 | 21 | 22 | 23 | 24 | sum |
|---|---|---|---|---|---|---|---|---|
| \(a^2N_a\) | 1620 | 5415 | 8400 | 13230 | 9680 | 3174 | 1728 | 43247 |
so \(\mathrm{Ex}(f^2) = 43247/100 = 432.47\), and
\begin{equation*} \mathrm{Va}(f) \;=\; 432.47 - (20.75)^2 \;=\; 1.9075 . \end{equation*}
Show that the variance of function \(f(X)\) with respect to distribution \(\Pr(X)\) satisfies
\begin{equation*} \mathrm{Va}(f) \;=\; \mathrm{Ex}(f^2) - \mathrm{Ex}(f)^2 . \end{equation*}
Expand the square in the definition of variance, Equation 15.2, writing \(\mu = \mathrm{Ex}(f)\) for the constant \(\sum_x f(x)\Pr(x)\) of Equation 15.1:
\begin{equation*} \begin{aligned} \mathrm{Va}(f) &= \sum_x \bigl(f(x) - \mu\bigr)^2 \Pr(x)\\ &= \sum_x f(x)^2 \Pr(x) - 2\mu \sum_x f(x)\Pr(x) + \mu^2 \sum_x \Pr(x)\\ &= \mathrm{Ex}(f^2) - 2\mu^2 + \mu^2 \;=\; \mathrm{Ex}(f^2) - \mathrm{Ex}(f)^2 , \end{aligned} \end{equation*}
since the middle sum is \(\mu\) by Equation 15.1 and \(\sum_x \Pr(x) = 1\).
Let \(\mu\) and \(\sigma^2\) be the expectation and variance of a function and let \(v\) be one of its observed values. Using Chebyshev’s inequality (Theorem 15.2), what is the value of \(\epsilon\) that allows us to state that \(\mu\) lies in the interval \((v - \epsilon, v + \epsilon)\) with confidence \(\ge 95\%\)? Compare this with the value of \(\epsilon\) based on Theorem 15.3.
Recall the two results. Theorem 15.2 (Chebyshev’s inequality): for any \(\epsilon > 0\),
\begin{equation*} P(|v - \mu| < \epsilon) \;\ge\; 1 - \frac{\sigma^2}{\epsilon^2}. \end{equation*}
Theorem 15.3: if the values of the function are normally distributed, then \(P(|v - \mu| < \epsilon) = \alpha\) where
\begin{equation*} \epsilon \;=\; \Phi^{-1}\!\left(\frac{1+\alpha}{2}\right)\sigma , \end{equation*}
with \(\Phi(\cdot)\) the CDF of the standard Normal distribution.
Chebyshev needs \(\epsilon = \sqrt{20}\,\sigma \approx 4.472\,\sigma\); Theorem 15.3 needs only \(\epsilon = 1.96\,\sigma\). Both theorems bound \(P(|v-\mu|<\epsilon)\), and \(|v-\mu| < \epsilon\) is exactly the event \(\mu \in (v-\epsilon, v+\epsilon)\).
(i) Chebyshev (Theorem 15.2). The confidence is at least \(1 - \sigma^2/\epsilon^2\), so
\begin{equation*} \begin{aligned} 1 - \frac{\sigma^2}{\epsilon^2} \;\ge\; 0.95 &\iff \epsilon^2 \;\ge\; 20\,\sigma^2\\ &\iff \epsilon \;\ge\; 2\sqrt{5}\,\sigma \;\approx\; 4.472\,\sigma . \end{aligned} \end{equation*}
(ii) Theorem 15.3. With the values normally distributed and \(\alpha = 0.95\), \(\Phi^{-1}((1+\alpha)/2) = \Phi^{-1}(0.975) = 1.96\), and the confidence is then exactly \(0.95\) rather than a lower bound:
\begin{equation*} \epsilon \;=\; 1.96\,\sigma . \end{equation*}
The Normal-based interval is narrower by \(\sqrt{20}/1.96 \approx 2.28\).
Let \(f\) be a function with expectation \(\mu\) and variance \(\sigma^2 = 4\). Suppose we wish to estimate the expectation \(\mu\) using Monte Carlo simulation (Equation 15.5) and a sample of size \(n\). How large should \(n\) be if we want to guarantee that expectation \(\mu\) falls in the interval \((\mathrm{Av}_n(f) - 1,\; \mathrm{Av}_n(f) + 1)\) with confidence \(\ge 99\%\)? Use Chebyshev’s inequality (Theorem 15.2).
Here \(\mathrm{Av}_n(f) = \frac{1}{n}\sum_{i=1}^{n} f(x_i)\) is the sample mean of Equation 15.5.
\(n = 400\). Chebyshev is applied not to \(f\) but to the sample mean, which is itself a function of the sample space and by Theorem 15.5 has expectation \(\mu\) and variance \(\sigma^2/n = 4/n\). Theorem 15.2 with these two numbers gives, for every \(\epsilon > 0\),
\begin{equation*} P\bigl(|\mathrm{Av}_n(f) - \mu| < \epsilon\bigr) \;\ge\; 1 - \frac{4}{n\epsilon^2}, \end{equation*}
and as in Exercise 15.3 the event on the left is \(\mu \in (\mathrm{Av}_n(f)-\epsilon,\, \mathrm{Av}_n(f)+\epsilon)\). Setting \(\epsilon = 1\) and demanding confidence \(0.99\),
\begin{equation*} 1 - \frac{4}{n} \;\ge\; 0.99 \quad\Longleftrightarrow\quad \frac{4}{n} \;\le\; 0.01 \quad\Longleftrightarrow\quad n \;\ge\; 400 . \end{equation*}
Prove the law of large numbers (Theorem 15.6): let \(\mathrm{Av}_n(f)\) be a sample mean where the function \(f\) has expectation \(\mu\). For every \(\epsilon > 0\),
\begin{equation*} \lim_{n \to \infty} P\bigl(|\mathrm{Av}_n(f) - \mu| \le \epsilon\bigr) \;=\; 1 . \end{equation*}
Here \(\mathrm{Av}_n(f) = \frac{1}{n}\sum_{i=1}^n f(x_i)\) (Equation 15.5), where \(x_1,\dots,x_n\) is a random sample drawn independently from the distribution \(\Pr(X)\).
Apply Chebyshev to the sample mean and squeeze. Since \(X\) is a finite set of discrete variables, \(\sigma^2 = \mathrm{Va}(f)\) is finite; the sample mean is itself a function of the sample space \((x_1,\dots,x_n)\) and by Theorem 15.5 (the \(x_i\) drawn independently) has expectation \(\mu\) and variance \(\sigma^2/n\). Hence Theorem 15.2 applied to it, with monotonicity of probability, gives for every \(\epsilon > 0\) and every \(n\)
\begin{equation*} 1 - \frac{\sigma^2}{n\epsilon^2} \;\le\; P\bigl(|\mathrm{Av}_n(f) - \mu| < \epsilon\bigr) \;\le\; P\bigl(|\mathrm{Av}_n(f) - \mu| \le \epsilon\bigr) \;\le\; 1 . \end{equation*}
With \(\epsilon\) fixed the left end tends to \(1\), so the squeeze gives \(\lim_{n\to\infty} P(|\mathrm{Av}_n(f) - \mu| \le \epsilon) = 1\). \(\blacksquare\)
Consider the Bayesian network in Figure 15.1 and the parameter \(\theta_{\bar a}\) representing the probability of \(A = \mathrm{false}\) (i.e., it is not winter). For each of the following values of this parameter, \(.01\), \(.4\), and \(.99\), do the following:
- (a) Compute the probability \(\Pr(d, e)\): wet grass and slippery road.
- (b) Estimate \(\Pr(d,e)\) using direct sampling with sample sizes ranging from \(n = 100\) to \(n = 15{,}000\).
- (c) Generate a plot with \(n\) on the \(x\)-axis and the exact value of \(\Pr(d,e)\) and the estimate for \(\Pr(d,e)\) on the \(y\)-axis.
- (d) Generate a plot with \(n\) on the \(x\)-axis and the exact variance of the estimate for \(\Pr(d,e)\) and the sample variance on the \(y\)-axis.
The network of Figure 15.1 has five binary variables: \(A\) (Winter?), \(B\) (Sprinkler?), \(C\) (Rain?), \(D\) (Wet Grass?), \(E\) (Slippery Road?), with edges
\begin{equation*} A \to B,\quad A \to C,\quad B \to D,\quad C \to D,\quad C \to E . \end{equation*}
Its CPTs are:
| \(A\) | \(\Theta_A\) |
|---|---|
| true | .6 |
| false | .4 |
| \(A\) | \(B\) | \(\Theta_{B\mid A}\) |
|---|---|---|
| true | true | .2 |
| true | false | .8 |
| false | true | .75 |
| false | false | .25 |
| \(A\) | \(C\) | \(\Theta_{C\mid A}\) |
|---|---|---|
| true | true | .8 |
| true | false | .2 |
| false | true | .1 |
| false | false | .9 |
| \(B\) | \(C\) | \(D\) | \(\Theta_{D\mid BC}\) |
|---|---|---|---|
| true | true | true | .95 |
| true | true | false | .05 |
| true | false | true | .9 |
| true | false | false | .1 |
| false | true | true | .8 |
| false | true | false | .2 |
| false | false | true | 0 |
| false | false | false | 1 |
| \(C\) | \(E\) | \(\Theta_{E\mid C}\) |
|---|---|---|
| true | true | .7 |
| true | false | .3 |
| false | true | 0 |
| false | false | 1 |
In this exercise \(\Theta_A\) is varied: \(\theta_{\bar a} \in \{.01, .4, .99\}\) and \(\theta_a = 1 - \theta_{\bar a}\). Lowercase \(a,b,c,d,e\) denote the value true and \(\bar a, \bar b, \bar c, \bar d, \bar e\) the value false.
(a) \(\Pr(d,e) = .4648 - .400925\,\theta_{\bar a}\), a decreasing linear function of \(\theta_{\bar a}\). Eliminate \(E\) and then \(B\) from the network factorization \(\Pr(A)\Pr(B|A)\Pr(C|A)\Pr(D|B,C)\Pr(E|C)\): every \(C = \bar c\) term vanishes since \(\Pr(e|\bar c) = 0\), leaving the constant factor \(\Pr(e|c) = .7\), so with \(g(A) = \sum_B \Pr(B|A)\Pr(d|B,c)\),
\begin{equation*} \begin{aligned} g(a) &= (.2)(.95) + (.8)(.8) = .83,\\ g(\bar a) &= (.75)(.95) + (.25)(.8) = .9125,\\ \Pr(d,e) &= .7\bigl[\theta_a(.8)(.83) + \theta_{\bar a}(.1)(.9125)\bigr]\\ &= .7\bigl[.664 - .57275\,\theta_{\bar a}\bigr] \;=\; .4648 - .400925\,\theta_{\bar a}, \end{aligned} \end{equation*}
using \(\theta_a = 1 - \theta_{\bar a}\). At the three requested values:
| \(\theta_{\bar a}\) | \(\Pr(d,e)\) exact |
|---|---|
| .01 | \(.46079075\) |
| .4 | \(.30443\) |
| .99 | \(.06788425\) |
(b) Algorithm 45 with \(\alpha : d \wedge e\), each trial simulated in the order \(A,B,C,D,E\) (Algorithm 44) and scored by \(\breve\alpha\) of Definition 15.1, returns \(\mathrm{Av}_n(\breve\alpha)\) of Equation 15.7. One run at selected sample sizes:
| \(n\) | \(\theta_{\bar a}=.01\) | \(\theta_{\bar a}=.4\) | \(\theta_{\bar a}=.99\) |
|---|---|---|---|
| 100 | .3700 | .2700 | .0800 |
| 500 | .4260 | .2960 | .0640 |
| 1000 | .4590 | .3010 | .0550 |
| 2500 | .4648 | .3148 | .0668 |
| 5000 | .4624 | .3058 | .0686 |
| 10000 | .4631 | .3052 | .0693 |
| 15000 | .4619 | .3080 | .0691 |
| exact | .4607907 | .3044300 | .0678842 |
(c) Each panel plots the horizontal line \(\Pr(d,e)\) against \(n \mapsto \mathrm{Av}_n(\breve\alpha)\), which fluctuates for small \(n\) (absolute errors \(.091\), \(.034\), \(.012\) at \(n = 100\)) and settles onto the line by Theorem 15.6. Superimpose the funnel \(\Pr(d,e) \pm 1.96\sqrt{\Pr(\alpha)\Pr(\neg\alpha)/n}\), since by Corollary 4 the estimate has standard deviation \(\sqrt{\Pr(\alpha)\Pr(\neg\alpha)/n}\) and Theorem 15.7 puts roughly \(95\%\) of the trajectory inside; at \(n = 15{,}000\) its half-widths are \(.0080\), \(.0074\), \(.0040\), and all three estimates above fall inside.
(d) By Corollary 4 the exact variance of the estimate is
\begin{equation*} \mathrm{Va}\bigl(\mathrm{Av}_n(\breve\alpha)\bigr) = \frac{\Pr(\alpha)\Pr(\neg\alpha)}{n}, \end{equation*}
and its empirical counterpart is the sample variance of Equation 15.6 divided by \(n\). Since \(\breve\alpha(x_i) \in \{0,1\}\), writing \(\hat p = \mathrm{Av}_n(\breve\alpha)\) gives \(\sum_i \breve\alpha(x_i)^2 = n\hat p\), so by the one-pass identity of Exercise 15.7,
\begin{equation*} S^2_n(\breve\alpha) = \frac{n\hat p - n\hat p^2}{n-1} = \frac{n}{n-1}\,\hat p(1-\hat p), \qquad \frac{S^2_n(\breve\alpha)}{n} = \frac{\hat p(1-\hat p)}{n-1}. \end{equation*}
Plotting both against \(n\) for the same run:
| \(n\) | exact \(.01\) | sample \(.01\) | exact \(.4\) | sample \(.4\) | exact \(.99\) | sample \(.99\) |
|---|---|---|---|---|---|---|
| 100 | 2.485e-3 | 2.354e-3 | 2.118e-3 | 1.991e-3 | 6.328e-4 | 7.434e-4 |
| 500 | 4.969e-4 | 4.900e-4 | 4.235e-4 | 4.176e-4 | 1.266e-4 | 1.201e-4 |
| 1000 | 2.485e-4 | 2.486e-4 | 2.118e-4 | 2.106e-4 | 6.328e-5 | 5.203e-5 |
| 2500 | 9.939e-5 | 9.954e-5 | 8.470e-5 | 8.632e-5 | 2.531e-5 | 2.494e-5 |
| 5000 | 4.969e-5 | 4.973e-5 | 4.235e-5 | 4.247e-5 | 1.266e-5 | 1.278e-5 |
| 10000 | 2.485e-5 | 2.487e-5 | 2.118e-5 | 2.121e-5 | 6.328e-6 | 6.450e-6 |
| 15000 | 1.656e-5 | 1.657e-5 | 1.412e-5 | 1.421e-5 | 4.218e-6 | 4.287e-6 |
Column “exact \(t\)” is \(\Pr(\alpha)\Pr(\neg\alpha)/n\) at \(\theta_{\bar a} = t\); column “sample \(t\)” is \(S^2_n(\breve\alpha)/n\) from the run of part (b). Both decay like \(1/n\) and are indistinguishable beyond \(n \approx 2000\).
Show that the sample variance of function \(f(X)\) and sample \(x_1, \dots, x_n\) can be computed as follows:
\begin{equation*} S^2_n(f) \;=\; \frac{1}{n-1}\,T, \end{equation*}
where
\begin{equation*} T \;=\; \sum_{i=1}^{n}\bigl(f(x_i) - \mathrm{Av}_n(f)\bigr)^2 \;=\; \sum_{i=1}^{n} f(x_i)^2 \;-\; \frac{1}{n}\left(\sum_{i=1}^{n} f(x_i)\right)^{\!2}. \end{equation*}
Note that the first form of \(T\) given in this chapter suggests computation by a two-pass algorithm: compute the mean in one pass and compute the differences squared in another pass. The second form of \(T\) suggests computation by a one-pass algorithm that simply accumulates the sums of \(f(x_i)^2\) and \(f(x_i)\).
Expand the square. Equation 15.6 already defines \(S^2_n(f)\) as \(1/(n-1)\) times the first expression for \(T\), so only the identity between the two forms of \(T\) is at issue. Put \(f_i = f(x_i)\), \(S = \sum_i f_i\), \(Q = \sum_i f_i^2\), and \(m = \mathrm{Av}_n(f) = S/n\) (Equation 15.5), a constant in \(i\). Then
\begin{equation*} \begin{aligned} T &= \sum_{i=1}^n (f_i - m)^2 = \sum_{i=1}^n f_i^2 - 2m\sum_{i=1}^n f_i + \sum_{i=1}^n m^2\\ &= Q - 2mS + nm^2 = Q - \frac{2S^2}{n} + \frac{S^2}{n} = Q - \frac{S^2}{n}, \end{aligned} \end{equation*}
the third sum having \(n\) identical terms \(m^2\); and \(Q - S^2/n\) is the claimed second form. It needs only the running totals \(S\) and \(Q\), so one pass with \(O(1)\) memory reports \(\mathrm{Av}_n(f) = S/n\) and \(S^2_n(f) = (Q - S^2/n)/(n-1)\).
Exercises 15.8–15.14
Suppose we want to simulate a Bayesian network \(N\) that has been conditioned on evidence \(e\). Suppose further that we are given cluster marginals \(Pr(C_i|e)\) and separator marginals \(Pr(S_{ij}|e)\) computed by running the jointree algorithm on network \(N\) and evidence \(e\) (here \((T,\mathbf{C})\) is a jointree for \(N\) with clusters \(C_i\), and \(S_{ij} = C_i \cap C_j\) is the separator of edge \(i\!-\!j\) of \(T\)). Give an efficient algorithm for simulating the network \(N\) conditioned on \(e\) given these cluster and separator marginals. That is, show how we can efficiently generate a sequence of independent network instantiations \(\mathbf{x}^1,\dots,\mathbf{x}^n\) where the probability of generating instantiation \(\mathbf{x}^i\) is \(Pr(\mathbf{x}^i|e)\).
Walk the jointree outward from a root cluster, sampling one whole cluster at a time from a conditional built out of the given marginals — the jointree analogue of Algorithm 44, SIMULATE BN.
Root \(T\) at \(C_r\) and list the clusters in a prefix order \(C_{i_1}=C_r, C_{i_2},\dots,C_{i_m}\) (any BFS or DFS from \(C_r\)), writing \(S_k = C_{i_k}\cap C_{\pi(k)}\) for the separator to the tree-parent and \(V_k = C_{i_1}\cup\dots\cup C_{i_k}\), so \(V_m=\mathbf{X}\) as the clusters cover all network variables. Once, store \(Pr(C_r|e)\) and for \(k=2,\dots,m\) the entrywise quotient
\begin{equation*} Q_k(C_{i_k}\setminus S_k \mid S_k)\;=\;\frac{Pr(c_{i_k}|e)}{Pr(s_k|e)}, \end{equation*}
the division the jointree algorithm already performs. Then each sample is:
- Sample \(c_{i_1}\) from \(Pr(C_r|e)\).
- For \(k=2,\dots,m\): read off the value \(s_k\) the already-sampled variables give \(S_k\) — they all lie in \(C_{\pi(k)}\), instantiated earlier — and sample \(t_k\) of \(C_{i_k}\setminus S_k\) from \(Q_k(\,\cdot\mid s_k)\).
- Return the instantiation \(\mathbf{x}\) assembled from \(c_{i_1},t_2,\dots,t_m\).
Correctness: deleting the tree edge above \(C_{i_k}\) splits the clusters into a root side \(\mathbf{A}\supseteq V_{k-1}\) and a far side \(\mathbf{B}\supseteq C_{i_k}\) with \(\mathbf{A}\cap\mathbf{B}=S_k\) (running intersection), and \(Pr(\mathbf{x}|e)= \prod_i\psi_i(c_i)\) factorizes over the clusters (chain rule (4.2) times evidence indicators over \(Pr(e)\), every family and evidence variable sitting in some cluster), so grouping by side gives \(Pr(\mathbf{x}|e)=f(\mathbf{a})g(\mathbf{b})\) and hence \(V_{k-1}\setminus S_k \perp C_{i_k}\setminus S_k \mid S_k\) in \(Pr(\cdot|e)\); also \(C_{i_k}\cap V_{k-1}=S_k\), so no variable is re-sampled. Inducting on \(k\), with \(s_k\) part of \(v_{k-1}\),
\begin{equation*} Pr(v_{k-1}|e)\cdot\frac{Pr(s_k t_k|e)}{Pr(s_k|e)} = Pr(v_{k-1}|e)\,Pr(t_k\mid v_{k-1},e) = Pr(v_k|e), \end{equation*}
no division by zero occurring since \(Pr(s_k|e)\ge Pr(v_{k-1}|e)>0\) for any instantiation actually produced; at \(k=m\) this is \(Pr(\mathbf{x}|e)\), fresh random numbers make the \(\mathbf{x}^i\) independent, and every sample is consistent with \(e\) since \(Pr(c_i|e)=0\) at cluster instantiations contradicting \(e\).
Preprocessing costs \(O(\sum_i \exp(|C_i|))\), the order of the jointree itself; with each conditional turned into cumulative sums or an alias table the \(m\) draws are \(O(1)\) apiece, so \(n\) samples cost \(O(\sum_i \exp(|C_i|) + nm)\) with nothing discarded.
Recall Algorithm 44, SIMULATE BN: given a Bayesian network \(N\) over variables \(\mathbf{X}\) inducing distribution \(Pr(\mathbf{X})\), it fixes a total order \(\pi = X_1,\dots,X_n\) of the network variables in which parents appear before their children, starts with the trivial instantiation, and then for \(i=1,\dots,n\) lets \(\mathbf{u}_i\) be the value of \(X_i\)’s parents in the instantiation built so far, samples a value \(x_i\) for \(X_i\) from \(Pr(X_i|\mathbf{u}_i)\), and appends it. It returns the complete instantiation \(\mathbf{x}=x_1,\dots,x_n\).
Show the following for an instantiation \(\mathbf{x}\) returned by Algorithm 44, SIMULATE BN:
- (a) The partial instantiation \(x_1,\dots,x_k\) of \(\mathbf{x}\) is generated with probability \(Pr(x_1,\dots,x_k)\), where \(X_i\) is the variable at position \(i\) in the used order \(\pi\).
- (b) The value \(x\) assigned to variable \(X\) by instantiation \(\mathbf{x}\) is generated with probability \(Pr(x)\).
- (c) The instantiation \(\mathbf{c}\) assigned to variables \(\mathbf{C}\subseteq\mathbf{X}\) by \(\mathbf{x}\) is generated with probability \(Pr(\mathbf{c})\).
Hint: You can use (a) to prove (b), and use (b) to prove (c).
(a) Both sides equal \(\prod_{i=1}^{k}\theta_{x_i|\mathbf{u}_i}\), where \(\mathbf{u}_i\) is the instantiation that \(x_1,\dots,x_{i-1}\) gives the parents \(\mathbf{U}_i\) of \(X_i\). Since \(\pi\) places parents before children, at iteration \(i\) the partial instantiation already fixes \(\mathbf{U}_i\) and step 7 draws \(x_i\) with probability \(\theta_{x_i|\mathbf{u}_i}\); successive draws being independent given the history,
\begin{equation*} P_{\text{alg}}(x_1,\dots,x_k)\;=\;\prod_{i=1}^{k}\theta_{x_i|\mathbf{u}_i}. \end{equation*}
For the distribution, \(k=n\) is the chain rule (4.2); smaller \(k\) follows by summing out trailing variables, \(X_n\) having no children (a child would follow it in \(\pi\)) and so occurring in no \(\mathbf{u}_i\) with \(i<n\):
\begin{equation*} \begin{aligned} Pr(x_1,\dots,x_{n-1}) &=\sum_{x_n} \prod_{i=1}^{n}\theta_{x_i|\mathbf{u}_i}\\ &=\left(\prod_{i=1}^{n-1}\theta_{x_i|\mathbf{u}_i}\right) \sum_{x_n}\theta_{x_n|\mathbf{u}_n} \;=\;\prod_{i=1}^{n-1}\theta_{x_i|\mathbf{u}_i}, \end{aligned} \end{equation*}
every CPT column summing to \(1\); repeat down to position \(k+1\).
(b) Let \(X=X_k\). The returned instantiation assigns \(x\) to \(X_k\) exactly when the first \(k\) iterations produce one of the sequences \(x_1,\dots,x_{k-1},x\); these are mutually exclusive and no later iteration changes the value of \(X_k\). So by (a) and marginalization over \(X_1,\dots,X_{k-1}\),
\begin{equation*} P_{\text{alg}}(X_k = x) =\sum_{x_1,\dots,x_{k-1}} Pr(x_1,\dots,x_{k-1},x) \;=\;Pr(x). \end{equation*}
(c) The same argument with \(k\) the largest position in \(\pi\) occupied by a variable of \(\mathbf{C}\), so that \(\mathbf{C}\subseteq\{X_1,\dots,X_k\}\). Writing \(x_1,\dots,x_k\sim\mathbf{c}\) for compatibility, those events are mutually exclusive, undisturbed by later iterations, and their disjunction is \(\mathbf{c}\), so by (a)
\begin{equation*} P_{\text{alg}}(\mathbf{c}) =\sum_{x_1,\dots,x_k\,\sim\,\mathbf{c}} Pr(x_1,\dots,x_k) \;=\;Pr(\mathbf{c}). \end{equation*}
Prove Theorem 15.9.
Recall the setting. We have a distribution \(Pr(\mathbf{X},\mathbf{Y})\) over disjoint sets of variables \(\mathbf{X}\) and \(\mathbf{Y}\) and an event \(\alpha\). By Definition 15.2, the Rao-Blackwell function for event \(\alpha\) and distribution \(Pr(\mathbf{X},\mathbf{Y})\), denoted \(\ddot{\alpha}(\mathbf{Y})\), maps each instantiation \(\mathbf{y}\) into \([0,1]\) as follows:
\begin{equation*} \ddot{\alpha}(\mathbf{y}) \;\stackrel{\text{def}}{=}\; Pr(\alpha|\mathbf{y}). \end{equation*}
Theorem 15.9 states that the expectation and variance of the Rao-Blackwell function \(\ddot{\alpha}(\mathbf{Y})\) with respect to the distribution \(Pr(\mathbf{Y})\) are
\begin{equation*} Ex(\ddot{\alpha}) \;=\; Pr(\alpha), \end{equation*}
\begin{equation*} Va(\ddot{\alpha}) \;=\; \sum_{\mathbf{y}} Pr(\alpha|\mathbf{y})^2\,Pr(\mathbf{y}) \;-\; Pr(\alpha)^2 . \end{equation*}
Both halves are the definitions plus one case analysis (setting \(\ddot{\alpha}(\mathbf{y})=0\) where \(Pr(\mathbf{y})=0\), such terms carrying weight \(0\) in every sum). For the expectation, Equation 15.1 and then the definition of conditional probability give
\begin{equation*} \begin{aligned} Ex(\ddot{\alpha}) &=\sum_{\mathbf{y}} \ddot{\alpha}(\mathbf{y})\,Pr(\mathbf{y}) =\sum_{\mathbf{y}} Pr(\alpha|\mathbf{y})\,Pr(\mathbf{y})\\ &=\sum_{\mathbf{y}} Pr(\alpha \wedge \mathbf{y}) \;=\; Pr(\alpha), \end{aligned} \end{equation*}
the last step being case analysis on \(\mathbf{Y}\), whose events \(\alpha\wedge\mathbf{y}\) are mutually exclusive with disjunction \(\alpha\). Then \(Va(f)=Ex(f^2)-Ex(f)^2\) (Exercise 15.2) with \(f=\ddot{\alpha}\) gives
\begin{equation*} \begin{aligned} Va(\ddot{\alpha}) &=Ex(\ddot{\alpha}^2)-Ex(\ddot{\alpha})^2\\ &=\sum_{\mathbf{y}} Pr(\alpha|\mathbf{y})^2\,Pr(\mathbf{y})-Pr(\alpha)^2 . \end{aligned} \end{equation*}
Given a Bayesian network over variables \(\mathbf{X}\) and \(\mathbf{Y}\) where \(\mathbf{X}\cap\mathbf{Y}=\emptyset\) and \(\mathbf{Y}\) is a loop-cutset, show how \(Pr(\mathbf{z}|\mathbf{y})\) can be computed in time polynomial in the network size where \(\mathbf{Z}\subseteq\mathbf{X}\).
Here \(\mathbf{y}\) is an instantiation of all the cutset variables \(\mathbf{Y}\), \(\mathbf{z}\) is an instantiation of \(\mathbf{Z}\), and, by Definition 8.1, a set of nodes \(\mathbf{C}\) is a loop-cutset for a Bayesian network \(N\) if removing the edges outgoing from the nodes \(\mathbf{C}\) renders the network a polytree.
Hard-code \(\mathbf{y}\) into the CPTs to get a polytree \(N_{\mathbf{y}}\), then answer two probability-of-evidence queries on it and divide:
\begin{equation*} Pr(\mathbf{z}|\mathbf{y}) =\frac{Pr(\mathbf{z},\mathbf{y})}{Pr(\mathbf{y})} =\frac{Pr_{\mathbf{y}}(\mathbf{z},\mathbf{y})}{Pr_{\mathbf{y}}(\mathbf{y})} \qquad (Pr(\mathbf{y})>0). \end{equation*}
Delete from \(G\) every edge outgoing from a node of \(\mathbf{Y}\); the result \(G_{\mathbf{y}}\) is a polytree by Definition 8.1, and the nodes of \(\mathbf{Y}\), keeping their incoming edges, become leaves. Splitting the parents \(\mathbf{U}\) of a node \(V\) as \(\mathbf{U}_X\cup\mathbf{U}_Y\) into those outside and inside \(\mathbf{Y}\), the parents of \(V\) in \(G_{\mathbf{y}}\) are \(\mathbf{U}_X\), so give \(V\) the CPT
\begin{equation*} \theta^{\mathbf{y}}_{v|\mathbf{u}_{X}} \;\stackrel{\text{def}}{=}\; \theta_{v \mid \mathbf{u}_{X},\, \mathbf{u}_{Y}}, \end{equation*}
with \(\mathbf{u}_Y\) the value \(\mathbf{y}\) assigns \(\mathbf{U}_Y\) — legitimate, since for fixed \(\mathbf{u}_X\) these numbers sum to \(1\) over \(v\) — at one scan per CPT, so building \(N_{\mathbf{y}}\) is linear in the size of \(N\). For every instantiation \(\mathbf{x}\) of \(\mathbf{X}\), the chain rule (4.2) in \(N_{\mathbf{y}}\) and then in \(N\) gives
\begin{equation*} Pr_{\mathbf{y}}(\mathbf{x},\mathbf{y}) =\prod_{V}\theta^{\mathbf{y}}_{v|\mathbf{u}_{X}} =\prod_{V}\theta_{v|\mathbf{u}} = Pr(\mathbf{x},\mathbf{y}), \end{equation*}
the middle step legitimate precisely because the instantiation assigns \(\mathbf{Y}\) the values \(\mathbf{y}\) hard-coded into the CPTs. Summing over the \(\mathbf{x}\) compatible with \(\mathbf{z}\), and then over all \(\mathbf{x}\), yields the two numerators above as evidence queries with evidence \(\mathbf{z},\mathbf{y}\) and \(\mathbf{y}\).
The polytree algorithm of Section 7.5.4 — Algorithm 12, FE, with the elimination tree mirroring the polytree — returns the marginals \(Pr(C_i,e)\) in \(O(n\exp(k))\) time and space, \(k\) the maximum number of parents, and summing any one of them over its variables gives \(Pr(e)\). A node with \(k\) parents already occupies \(\Theta(\exp(k))\) entries of the specification, so \(O(n\exp(k))\) is linear in the network size, and two runs plus a division leave it there.
Given a Bayesian network over variables \(\mathbf{X}\) and containing evidence \(e\) on variables \(\mathbf{E}\), show how we can construct a Gibbs sampler for the distribution \(Pr(\mathbf{Y}|e)\), \(\mathbf{Y}\subseteq\mathbf{X}\setminus \mathbf{E}\), assuming that we can compute \(Pr(\mathbf{y},e)\) for each instantiation \(\mathbf{y}\) of variables \(\mathbf{Y}\). That is, we want a Gibbs sampler that allows us to compute expectations with respect to the distribution \(Pr(\mathbf{Y}|e)\).
For reference, Definition 15.6 says that, given a distribution \(Pr(\mathbf{V})\) over \(m\) variables, the corresponding Gibbs transition matrix is
\begin{equation*} P(\mathbf{V}_i = \mathbf{v}^{\prime} \mid \mathbf{V}_{i-1} = \mathbf{v}) = \begin{cases} 0, & \text{(i)}\\[4pt] \dfrac{1}{m}\,Pr(s^{\prime}|\mathbf{v}-S), & \text{(ii)}\\[6pt] \dfrac{1}{m}\displaystyle\sum_{S\in\mathbf{V}} Pr(s_{\mathbf{v}}|\mathbf{v}-S), & \text{(iii)} \end{cases} \end{equation*}
where case (i) applies when \(\mathbf{v}\) and \(\mathbf{v}^{\prime}\) disagree on more than one variable; case (ii) when they disagree on a single variable \(S\), which has value \(s^{\prime}\) in \(\mathbf{v}^{\prime}\); and case (iii) when \(\mathbf{v}=\mathbf{v}^{\prime}\), with \(s_{\mathbf{v}}\) the value of \(S\) in \(\mathbf{v}\).
Feeding \(Pr(\mathbf{Y}|e)\) — a distribution over the \(m=|\mathbf{Y}|\) variables \(\mathbf{Y}\) — to Definition 15.6, the only quantities the transition matrix needs are the full conditionals \(Pr(S\mid\mathbf{y}-S,e)\) for \(S\in\mathbf{Y}\), and each is one normalization away from the oracle: \(\mathbf{y}-S,s\) is a complete instantiation of \(\mathbf{Y}\) for every state \(s\) of \(S\), so \(Pr(\mathbf{y}-S,s,e)\) is available and case analysis on \(S\) gives
\begin{equation*} Pr(s \mid \mathbf{y}-S, e) = \frac{Pr(\mathbf{y}-S,\,s,\,e)} {\sum_{s^{\prime}} Pr(\mathbf{y}-S,\,s^{\prime},\,e)} \;=\;\eta\; Pr(\mathbf{y}-S,\,s,\,e). \end{equation*}
One full conditional thus costs \(|S|\) oracle calls and no other inference; both \(Pr(e)\) and \(Pr(\mathbf{y}-S,e)\) cancel, so unnormalized values suffice. The sampler is then Algorithm 48, GIBBS NEXT STATE, with the chain-rule computation of Theorem 15.17 replaced by oracle calls. Given a current state \(\mathbf{y}\):
- \(S\leftarrow\) a variable chosen uniformly at random from \(\mathbf{Y}\).
- For each state \(s\) of \(S\): \(P(s)\leftarrow Pr(\mathbf{y}-S,\,s,\,e)\).
- \(\eta\leftarrow\sum_{s}P(s)\); set \(P(s)\leftarrow P(s)/\eta\) for each \(s\).
- \(s\leftarrow\) a value of \(S\) sampled from the distribution \(P(S)\).
- Return the instantiation \(\mathbf{y}-S,\,s\).
Start from any \(\mathbf{y}^1\) with \(Pr(\mathbf{y}^1,e)>0\) and iterate. Step 1 chooses \(S\) with probability \(1/m\) and step 4 draws \(s\) with probability \(Pr(s|\mathbf{y}-S,e)\), so the next state \(\mathbf{y}^{\prime}\) arises with probability
- (i) \(0\) when \(\mathbf{y}^{\prime}\) and \(\mathbf{y}\) differ on more than one variable, only the chosen \(S\) being allowed to change;
- (ii) \(\frac{1}{m}Pr(s^{\prime}|\mathbf{y}-S,e)\) when they differ only on \(S\), that being the only choice at step 1 that produces the transition;
- (iii) \(\frac{1}{m}\sum_{S\in\mathbf{Y}}Pr(s_{\mathbf{y}}|\mathbf{y}-S,e)\) when \(\mathbf{y}^{\prime}=\mathbf{y}\), since any \(S\) can leave the state unchanged.
This is the Gibbs transition matrix of Definition 15.6 for \(Pr(\mathbf{Y}|e)\). By Theorem 15.16 the chain satisfies detailed balance with respect to \(Pr(\mathbf{Y}|e)\), which is therefore stationary — and, if \(Pr(\mathbf{y}|e)>0\) for every \(\mathbf{y}\) so that the chain is irreducible, uniquely so. Under that condition Theorem 15.15 gives, for any \(f(\mathbf{Y})\),
\begin{equation*} \lim_{n\to\infty} Av_n(f) =\sum_{\mathbf{y}} f(\mathbf{y})\,Pr(\mathbf{y}|e), \end{equation*}
the expectation with respect to \(Pr(\mathbf{Y}|e)\) as required.
Show that the variance of Theorem 15.9 ranges between zero and \(Pr(\alpha)Pr(\neg\alpha)\). State a condition under which the variance reduces to zero and a condition under which it reduces to \(Pr(\alpha)Pr(\neg\alpha)\).
Recall that the variance in question is that of the Rao-Blackwell function \(\ddot{\alpha}(\mathbf{Y})\) of Definition 15.2, namely \(\ddot{\alpha}(\mathbf{y})=Pr(\alpha|\mathbf{y})\), with respect to the distribution \(Pr(\mathbf{Y})\); by Theorem 15.9 it equals
\begin{equation*} Va(\ddot{\alpha}) \;=\; \sum_{\mathbf{y}} Pr(\alpha|\mathbf{y})^2\,Pr(\mathbf{y}) \;-\; Pr(\alpha)^2 . \end{equation*}
The variance is \(0\) exactly when \(\alpha\) is independent of \(\mathbf{Y}\) and \(Pr(\alpha)Pr(\neg\alpha)\) exactly when \(\mathbf{Y}\) determines the truth of \(\alpha\). Write \(f(\mathbf{y})=\ddot{\alpha}(\mathbf{y})=Pr(\alpha|\mathbf{y})\), so that \(Ex(f)=Pr(\alpha)\) by Theorem 15.9 and \(0\le f\le1\), \(f\) being a probability; “every \(\mathbf{y}\)” below means every \(\mathbf{y}\) with \(Pr(\mathbf{y})>0\).
(i) Lower end. \(Va(f)=\sum_{\mathbf{y}}(f(\mathbf{y})-Ex(f))^2 Pr(\mathbf{y})\ge 0\), a weighted sum of squares, with equality if and only if every summand vanishes:
\begin{equation*} Pr(\alpha|\mathbf{y}) \;=\; Ex(f) \;=\; Pr(\alpha) \quad\text{for every } \mathbf{y}, \end{equation*}
that is, the event \(\alpha\) is independent of the sampled variables \(\mathbf{Y}\).
(ii) Upper end. From \(0\le f\le 1\) we get \(f(\mathbf{y})^2\le f(\mathbf{y})\), hence \(Ex(f^2)\le Ex(f)=Pr(\alpha)\), and \(Va(f)=Ex(f^2)-Ex(f)^2\) (Exercise 15.2) gives
\begin{equation*} Va(\ddot{\alpha}) \;\le\; Pr(\alpha)-Pr(\alpha)^2 \;=\; Pr(\alpha)Pr(\neg\alpha), \end{equation*}
the direct sampling variance of Theorem 15.4. Equality requires \(Ex(f^2)=Ex(f)\), i.e. \(\sum_{\mathbf{y}} f(\mathbf{y})(1-f(\mathbf{y}))Pr(\mathbf{y})=0\); each summand being nonnegative, this holds if and only if
\begin{equation*} Pr(\alpha|\mathbf{y})\in\{0,1\} \quad\text{for every } \mathbf{y}, \end{equation*}
that is, \(\mathbf{y}\) already settles whether \(\alpha\) holds — as it does whenever \(\alpha\) mentions only variables in \(\mathbf{Y}\), \(\ddot{\alpha}\) then coinciding with the direct sampling function \(\breve{\alpha}\).
Let \(Pr(\mathbf{X})\) be a distribution that is hard to sample from. Let \(Pr^{\prime}(\mathbf{X})\) be another distribution that is easy to sample from, where \(Pr(\mathbf{x}) \le c \cdot Pr^{\prime}(\mathbf{x})\) for all instantiations \(\mathbf{x}\) and some constant \(c>0\). The method of rejection sampling performs the following steps to generate a sample of size \(n\) from distribution \(Pr(\mathbf{X})\):
Repeat \(n\) times:
- Sample an instantiation \(\mathbf{x}\) from distribution \(Pr^{\prime}(\mathbf{X})\).
- Accept \(\mathbf{x}\) with probability \(Pr(\mathbf{x})\,/\,\bigl(c\cdot Pr^{\prime}(\mathbf{x})\bigr)\).
- If \(\mathbf{x}\) is not accepted (i.e., rejected), go to Step 1.
We can show that the accepted instantiations represent a random sample from distribution \(Pr(\mathbf{X})\). Consider now the algorithm given in Section 15.5 for computing a conditional probability \(Pr(\alpha|\beta)\): generate a sample \(\mathbf{x}^1,\dots,\mathbf{x}^n\) of size \(n\) from the network distribution, let \(c_1\) be the number of instantiations in the sample at which \(\gamma=\alpha\wedge\beta\) is true and \(c_2\) the number at which \(\beta\) is true, and return \(Av_n(\breve{\gamma})/Av_n(\breve{\beta}) = c_1/c_2\). Show how this algorithm can be formulated as an instance of rejection sampling by specifying the corresponding distribution \(Pr^{\prime}\) and constant \(c\).
Take \(Pr^{\prime}(\mathbf{X}) = Pr(\mathbf{X})\), the network’s own distribution, which Algorithm 44 samples in time linear in the network size (Theorem 15.1), and \(c = 1/Pr(\beta)\). The schema’s hard target, written \(\widehat{Pr}\) to keep the names apart from the book’s \(Pr\), is \(\widehat{Pr}(\mathbf{X}) = Pr(\mathbf{X}|\beta)\).
A complete instantiation \(\mathbf{x}\) entails \(\beta\) or entails \(\neg\beta\), so with \(\breve{\beta}(\mathbf{x})\in\{0,1\}\) the direct sampling function of Definition 15.1,
\begin{equation*} \widehat{Pr}(\mathbf{x}) =\frac{Pr(\mathbf{x}\wedge\beta)}{Pr(\beta)} =\frac{\breve{\beta}(\mathbf{x})\,Pr(\mathbf{x})}{Pr(\beta)} \;\le\;\frac{Pr(\mathbf{x})}{Pr(\beta)} \;=\;c\cdot Pr^{\prime}(\mathbf{x}), \end{equation*}
which is the domination the schema requires. Substituting into step 2, for \(Pr^{\prime}(\mathbf{x})>0\),
\begin{equation*} \frac{\widehat{Pr}(\mathbf{x})}{c\cdot Pr^{\prime}(\mathbf{x})} =\frac{\breve{\beta}(\mathbf{x})\,Pr(\mathbf{x})\,/\,Pr(\beta)} {\bigl(1/Pr(\beta)\bigr)\,Pr(\mathbf{x})} =\breve{\beta}(\mathbf{x}), \end{equation*}
so both unknowns — \(Pr(\beta)\) and the normalization of \(\widehat{Pr}\) — cancel and the test is deterministic: accept \(\mathbf{x}\) iff \(\beta\) is true at \(\mathbf{x}\). The accepted instantiations are thus an independent sample from \(Pr(\mathbf{X}|\beta)\), and \(Pr(\alpha|\beta)=Ex(\breve{\alpha})\) with respect to \(Pr(\cdot|\beta)\) (Theorem 15.4 applied to that distribution), so it is estimated by the sample mean of \(\breve{\alpha}\) over them; an accepted instantiation satisfies \(\beta\), so those also satisfying \(\alpha\) are exactly those satisfying \(\gamma=\alpha\wedge\beta\):
\begin{equation*} \frac{\#\{\text{accepted } \mathbf{x}^i \text{ at which } \alpha \text{ holds}\}} {\#\{\text{accepted } \mathbf{x}^i\}} \;=\;\frac{c_1}{c_2} \;=\;\frac{Av_n(\breve{\gamma})}{Av_n(\breve{\beta})}, \end{equation*}
the estimate of Section 15.5.
Exercises 15.15–15.21
Consider the bounds on the absolute and relative errors of direct sampling that we provided in Sections 15.4.1 and 15.4.2 (based on Chebyshev’s inequality). Derive similar bounds based on this inequality for the absolute and relative errors of (idealized) importance sampling (Theorem 15.12). Can we use Hoeffding’s inequality for this purpose? Why?
Recall that Theorem 15.12 treats the idealized case in which the original distribution \(\mathrm{Pr}\) and the importance distribution \(\widetilde{\mathrm{Pr}}\) are proportional at the event \(\alpha\) (Definition 15.4), that is, \(\mathrm{Pr}(x)/\widetilde{\mathrm{Pr}}(x) = c\) for some constant \(c > 0\) and all instantiations \(x\) consistent with \(\alpha\). Under that condition the importance sampling function \(\tilde{\alpha}\) of Definition 15.3 has variance
\begin{equation*} \mathrm{Va}(\tilde{\alpha}) = \frac{\mathrm{Pr}(\alpha)}{\widetilde{\mathrm{Pr}}(\alpha)}\,\mathrm{Pr}(\alpha) - \mathrm{Pr}(\alpha)^2 . \end{equation*}
Corollaries 5 and 7 hold verbatim with \(\mathrm{Pr}\) replaced by \(\widetilde{\mathrm{Pr}}\) in the bound; Hoeffding does not apply in general, since \(\tilde{\alpha}\) is not \(\{0,1\}\)-valued and has no a priori range.
Absolute error. By Theorem 15.11 \(\tilde{\alpha}\) has expectation \(\mathrm{Pr}(\alpha)\) under \(\widetilde{\mathrm{Pr}}\), and in the idealized case of Theorem 15.12 its variance is \(\sigma^2 = \mathrm{Pr}(\alpha)^2/ \widetilde{\mathrm{Pr}}(\alpha) - \mathrm{Pr}(\alpha)^2 = \mathrm{Pr}(\alpha)^2 \widetilde{\mathrm{Pr}}(\neg\alpha)/\widetilde{\mathrm{Pr}}(\alpha)\). So by Theorem 15.5 the estimate (15.8) over a sample drawn from \(\widetilde{\mathrm{Pr}}\) has expectation \(\mathrm{Pr}(\alpha)\) and variance \(\sigma^2/n\), and Chebyshev’s inequality (Theorem 15.2) applied to it gives for every \(\epsilon > 0\)
\begin{equation*} P\bigl(|\mathrm{Av}_n(\tilde{\alpha}) - \mathrm{Pr}(\alpha)| < \epsilon\bigr) \;\ge\; 1 - \frac{\mathrm{Pr}(\alpha)^2\, \widetilde{\mathrm{Pr}}(\neg\alpha)} {n\,\epsilon^2\,\widetilde{\mathrm{Pr}}(\alpha)} . \end{equation*}
This is the analogue of Corollary 5, whose bound is \(1 - \mathrm{Pr}(\alpha)\mathrm{Pr}(\neg\alpha)/n\epsilon^2\).
Relative error. The relative error is \(< \epsilon\) exactly when the absolute error is \(< \epsilon\,\mathrm{Pr}(\alpha)\), so substituting \(\epsilon\,\mathrm{Pr}(\alpha)\) for \(\epsilon\) above, where the factors \(\mathrm{Pr}(\alpha)^2\) cancel,
\begin{equation*} P\!\left(\frac{|\mathrm{Av}_n(\tilde{\alpha}) - \mathrm{Pr}(\alpha)|} {\mathrm{Pr}(\alpha)} < \epsilon\right) \;\ge\; 1 - \frac{\widetilde{\mathrm{Pr}}(\neg\alpha)} {n\,\epsilon^2\,\widetilde{\mathrm{Pr}}(\alpha)} . \end{equation*}
This is Corollary 7 with \(\mathrm{Pr}\) replaced by \(\widetilde{\mathrm{Pr}}\) throughout, hence independent of the probability of the event being estimated.
Hoeffding. Not in the form of Theorem 15.8, which requires a \(\{0,1\}\)-valued function: by Definition 15.3 an importance sampling function takes the value \(\mathrm{Pr}(x)/\widetilde{\mathrm{Pr}}(x)\) on instantiations consistent with \(\alpha\), unbounded as \(\widetilde{\mathrm{Pr}}(x) \to 0\), while the general form of the inequality needs a known interval \([a,b]\). Under the proportionality of Theorem 15.12 the obstacle disappears: \(\tilde{\alpha}(x) = c\) for \(x\) consistent with \(\alpha\) and \(0\) otherwise, so \(\tilde{\alpha} = c\,\breve{\alpha}\) with \(c = \mathrm{Pr}(\alpha)/\widetilde{\mathrm{Pr}}(\alpha)\), summing \(\mathrm{Pr}(x) = c\,\widetilde{\mathrm{Pr}}(x)\) over \(x \models \alpha\). Theorem 15.8 does apply to the \(\{0,1\}\)-valued \(\breve{\alpha}\), whose expectation under \(\widetilde{\mathrm{Pr}}\) is \(\widetilde{\mathrm{Pr}}(\alpha)\); putting \(\epsilon = c\,\delta\), and then \(\epsilon\,\mathrm{Pr}(\alpha)\) for \(\epsilon\),
\begin{equation*} P\!\left(\frac{|\mathrm{Av}_n(\tilde{\alpha}) - \mathrm{Pr}(\alpha)|} {\mathrm{Pr}(\alpha)} \le \epsilon\right) \;\ge\; 1 - 2e^{-2n\epsilon^2\widetilde{\mathrm{Pr}}(\alpha)^2} , \end{equation*}
which is Corollary 8 with \(\mathrm{Pr}(\alpha)\) replaced by \(\widetilde{\mathrm{Pr}}(\alpha)\).
Consider a simple Bayesian network of the form \(A \rightarrow B\), where \(A\) and \(B\) are binary variables. Provide a closed form for the variance of likelihood weighting when estimating \(\mathrm{Pr}(a)\). Give a similar form for the estimate of \(\mathrm{Pr}(b)\). Your forms must be expressed in terms of network parameters and the probabilities of \(a\) and \(b\).
The network has a single edge from \(A\) to \(B\); its parameters are \(\theta_a\) and \(\theta_{\bar a} = 1 - \theta_a\) for the root \(A\), and \(\theta_{b|a}, \theta_{\bar b|a} = 1 - \theta_{b|a}, \theta_{b|\bar a}, \theta_{\bar b|\bar a} = 1 - \theta_{b|\bar a}\) for \(B\).
\(\mathrm{Va}(\tilde{a}) = 0\), and \(\mathrm{Va}(\tilde{b}) = \mathrm{Pr}(a)\mathrm{Pr}(\neg a)(\theta_{b|a} - \theta_{b|\bar a})^2\). In each case build the likelihood-weighting network \(\widetilde{N}\) of Definition 15.5, read off the importance sampling function, and apply Theorem 15.11:
\begin{equation*} \mathrm{Va}(\tilde{\alpha}) = \left(\sum_{x \models \alpha} \frac{\mathrm{Pr}(x)^2}{\widetilde{\mathrm{Pr}}(x)}\right) - \mathrm{Pr}(\alpha)^2 . \end{equation*}
(i) Estimating \(\mathrm{Pr}(a)\). Here \(\mathbf{E} = \{A\}\); \(A\) is a root, so no edge is deleted and Definition 15.5 merely replaces its CPT by \(\tilde{\theta}_a = 1\), \(\tilde{\theta}_{\bar a} = 0\), leaving the CPT of \(B\) untouched, whence \(\widetilde{\mathrm{Pr}}(a,b) = \theta_{b|a}\), \(\widetilde{\mathrm{Pr}}(a,\bar b) = \theta_{\bar b|a}\), \(\widetilde{\mathrm{Pr}}(\bar a,\cdot) = 0\). By Theorem 15.14 the weight at either instantiation consistent with \(a\) is the single evidence parameter \(\theta_a\), so \(\tilde{a} \equiv \theta_a = \mathrm{Pr}(a)\) on everything \(\widetilde{\mathrm{Pr}}\) can generate and
\begin{equation*} \mathrm{Va}(\tilde{a}) = \theta_a^2\bigl(\theta_{b|a} + \theta_{\bar b|a}\bigr) - \theta_a^2 = \theta_a^2 - \theta_a^2 = 0 . \end{equation*}
(ii) Estimating \(\mathrm{Pr}(b)\). Now \(\mathbf{E} = \{B\}\), so Definition 15.5 deletes the edge \(A \rightarrow B\) and sets \(\tilde{\theta}_b = 1\), \(\tilde{\theta}_{\bar b} = 0\), leaving the CPT of \(A\) unchanged, so \(\widetilde{\mathrm{Pr}}(a,b) = \theta_a\), \(\widetilde{\mathrm{Pr}}(\bar a,b) = 1 - \theta_a\), and \(\widetilde{\mathrm{Pr}}(\cdot,\bar b) = 0\). On the two instantiations consistent with \(b\), again by Theorem 15.14, \(\tilde{b}(a,b) = \theta_a\theta_{b|a}/\theta_a = \theta_{b|a}\) and \(\tilde{b}(\bar a,b) = \theta_{\bar a}\theta_{b|\bar a}/\theta_{\bar a} = \theta_{b|\bar a}\). Theorem 15.11 then gives
\begin{equation*} \begin{aligned} \mathrm{Va}(\tilde{b}) &= \frac{(\theta_a\theta_{b|a})^2}{\theta_a} + \frac{(\theta_{\bar a}\theta_{b|\bar a})^2}{\theta_{\bar a}} - \mathrm{Pr}(b)^2 \\ &= \theta_a\,\theta_{b|a}^2 + (1-\theta_a)\,\theta_{b|\bar a}^2 - \mathrm{Pr}(b)^2 . \end{aligned} \end{equation*}
with \(\mathrm{Pr}(a) = \theta_a\) and \(\mathrm{Pr}(b) = \theta_a\theta_{b|a} + (1-\theta_a)\theta_{b|\bar a}\); completing the square gives the equivalent
\begin{equation*} \mathrm{Va}(\tilde{b}) = \mathrm{Pr}(a)\,\mathrm{Pr}(\neg a)\, \bigl(\theta_{b|a} - \theta_{b|\bar a}\bigr)^2 . \end{equation*}
Prove Theorem 15.14.
Theorem 15.14. Let \(N\) be a Bayesian network, \(\mathbf{e}\) be some evidence, and let \(\widetilde{N}\) be the corresponding likelihood-weighting network. Suppose that networks \(N\) and \(\widetilde{N}\) induce distributions \(\mathrm{Pr}(\mathbf{X})\) and \(\widetilde{\mathrm{Pr}}(\mathbf{X})\), respectively, and that \(x\) is consistent with evidence \(\mathbf{e}\). If \(\theta_{e|u}\) ranges over the parameters of variables \(E \in \mathbf{E}\) in network \(N\), where \(eu\) is consistent with instantiation \(x\), then
\begin{equation*} \mathrm{Pr}(x)/\widetilde{\mathrm{Pr}}(x) = \prod_{\theta_{e|u}} \theta_{e|u} \;\le\; 1 . \end{equation*}
Recall Definition 15.5: the likelihood-weighting network \(\widetilde{N}\) is obtained from \(N\) by deleting the edges going into the nodes \(\mathbf{E}\) while setting the CPTs of these nodes as follows. If variable \(E \in \mathbf{E}\) is instantiated to \(e\) in evidence \(\mathbf{e}\), then \(\tilde{\theta}_e = 1\); otherwise \(\tilde{\theta}_e = 0\). All other CPTs of \(\widetilde{N}\) are equal to those in \(N\).
Factor both distributions by the chain rule (4.2) and cancel; it applies to \(\widetilde{N}\) since deleting edges creates no cycle and each \(E \in \mathbf{E}\) becomes a root whose new CPT is a legitimate distribution over \(E\). Write \(x_X\) for the value \(x\) assigns \(X\) and \(u_X\) for what it assigns the parents of \(X\) in \(N\). Every \(X \notin \mathbf{E}\) keeps its parents and CPT in \(\widetilde{N}\), and for each \(E \in \mathbf{E}\) the value \(x_E\) is the value \(e\) that \(\mathbf{e}\) assigns \(E\) (\(x\) being consistent with \(\mathbf{e}\)), so \(\tilde{\theta}_{x_E} = \tilde{\theta}_e = 1\) by Definition 15.5 and
\begin{equation*} \widetilde{\mathrm{Pr}}(x) = \prod_{X \notin \mathbf{E}} \theta_{x_X | u_X} . \end{equation*}
Splitting the chain rule for \(\mathrm{Pr}(x)\) along the same partition of \(\mathbf{X}\) gives
\begin{equation*} \mathrm{Pr}(x) = \left(\prod_{X \notin \mathbf{E}} \theta_{x_X | u_X}\right) \cdot \prod_{E \in \mathbf{E}} \theta_{x_E | u_E} = \widetilde{\mathrm{Pr}}(x)\cdot \prod_{E \in \mathbf{E}} \theta_{x_E | u_E} . \end{equation*}
Each \(\theta_{x_E|u_E}\) in the second product is a parameter of an evidence variable of \(N\) whose family instantiation \(x_E u_E\) is consistent with \(x\) — exactly the \(\theta_{e|u}\) of the statement. Dividing wherever \(\widetilde{\mathrm{Pr}}(x) \ne 0\),
\begin{equation*} \frac{\mathrm{Pr}(x)}{\widetilde{\mathrm{Pr}}(x)} = \prod_{\theta_{e|u}} \theta_{e|u} \;\le\; 1 , \end{equation*}
the bound because a finite product of parameters \(0 \le \theta_{e|u} \le 1\) lies in \([0,1]\). The undivided form holds for every \(x\) consistent with \(\mathbf{e}\), so \(\widetilde{\mathrm{Pr}}(x) = 0\) forces \(\mathrm{Pr}(x) = 0\).
Consider a Bayesian network in which all leaf nodes are deterministic (their CPTs contain only 0 and 1 entries) and let \(\mathbf{e}\) be an instantiation of the leaf nodes. What is the variance of likelihood weighting when estimating \(\mathrm{Pr}(\mathbf{e})\)?
Likelihood weighting buys nothing here: its variance is
\begin{equation*} \mathrm{Va}(\tilde{\mathbf{e}}) = \mathrm{Pr}(\mathbf{e})\,\mathrm{Pr}(\neg \mathbf{e}) = \mathrm{Pr}(\mathbf{e}) - \mathrm{Pr}(\mathbf{e})^2 , \end{equation*}
exactly the direct sampling variance of Theorem 15.4, the worst case allowed by Exercise 15.19.
The weights are \(0/1\)-valued. With \(\mathbf{E}\) the leaf nodes and \(\widetilde{N}\) the likelihood-weighting network of Definition 15.5 inducing \(\widetilde{\mathrm{Pr}}\), Theorem 15.14 gives for \(x\) consistent with \(\mathbf{e}\)
\begin{equation*} w(x) \;\stackrel{\text{def}}{=}\; \frac{\mathrm{Pr}(x)}{\widetilde{\mathrm{Pr}}(x)} = \prod_{E \in \mathbf{E}} \theta_{x_E | u_E} , \end{equation*}
one parameter per leaf, the one whose family instantiation is consistent with \(x\). Every CPT entry of a leaf is \(0\) or \(1\) by hypothesis, so \(w(x) \in \{0,1\}\) for every \(x \models \mathbf{e}\). By Theorem 15.11 the importance sampling function \(\tilde{\mathbf{e}}\) has variance
\begin{equation*} \mathrm{Va}(\tilde{\mathbf{e}}) = \left(\sum_{x \models \mathbf{e}} \frac{\mathrm{Pr}(x)^2}{\widetilde{\mathrm{Pr}}(x)}\right) - \mathrm{Pr}(\mathbf{e})^2 . \end{equation*}
For \(x \models \mathbf{e}\) with \(\widetilde{\mathrm{Pr}}(x) > 0\) we have \(\mathrm{Pr}(x) = w(x)\widetilde{\mathrm{Pr}}(x)\) and \(w(x)^2 = w(x)\), so the summand is \(w(x)^2\widetilde{\mathrm{Pr}}(x) = w(x)\widetilde{\mathrm{Pr}}(x) = \mathrm{Pr}(x)\); if instead \(\widetilde{\mathrm{Pr}}(x) = 0\) then \(\mathrm{Pr}(x) = 0\) (Exercise 15.17) and the term again contributes \(\mathrm{Pr}(x)\). Hence the sum is \(\sum_{x \models \mathbf{e}} \mathrm{Pr}(x) = \mathrm{Pr}(\mathbf{e})\), giving \(\mathrm{Va}(\tilde{\mathbf{e}}) = \mathrm{Pr}(\mathbf{e}) - \mathrm{Pr}(\mathbf{e})^2\).
Consider the functions \(\breve{\alpha}\) and \(\tilde{\alpha}\) given in Definitions 15.1 and 15.3, respectively. Show that \(\mathrm{Va}(\tilde{\alpha}) \le \mathrm{Va}(\breve{\alpha})\) if \(\widetilde{\mathrm{Pr}}(x) \ge \mathrm{Pr}(x)\) for all instantiations \(x\) consistent with \(\alpha\).
Here \(\breve{\alpha}(x) = 1\) if \(\alpha\) is true at \(x\) and \(0\) otherwise (Definition 15.1), while \(\tilde{\alpha}(x) = \mathrm{Pr}(x)/\widetilde{\mathrm{Pr}}(x)\) if \(\alpha\) is true at \(x\) and \(0\) otherwise (Definition 15.3), where the importance distribution \(\widetilde{\mathrm{Pr}}\) is required to satisfy \(\widetilde{\mathrm{Pr}}(x) = 0\) only if \(\mathrm{Pr}(x) = 0\), for all \(x\) at which \(\alpha\) is true. The variance \(\mathrm{Va}(\breve{\alpha})\) is taken with respect to \(\mathrm{Pr}\) and \(\mathrm{Va}(\tilde{\alpha})\) with respect to \(\widetilde{\mathrm{Pr}}\).
The two variances share the term \(-\mathrm{Pr}(\alpha)^2\): by Theorem 15.4 \(\mathrm{Va}(\breve{\alpha}) = \mathrm{Pr}(\alpha) - \mathrm{Pr}(\alpha)^2\), while by Theorem 15.11
\begin{equation*} \mathrm{Va}(\tilde{\alpha}) = \left(\sum_{x \models \alpha} \frac{\mathrm{Pr}(x)^2}{\widetilde{\mathrm{Pr}}(x)}\right) - \mathrm{Pr}(\alpha)^2 , \end{equation*}
so it suffices to bound each term of that sum by \(\mathrm{Pr}(x)\). Fix \(x \models \alpha\). (i) If \(\widetilde{\mathrm{Pr}}(x) = 0\), then the requirement in Definition 15.3 forces \(\mathrm{Pr}(x) = 0\), \(\tilde{\alpha}(x)\) is taken to be \(0\), and the term is \(0 = \mathrm{Pr}(x)\). (ii) If \(\widetilde{\mathrm{Pr}}(x) > 0\) and \(\mathrm{Pr}(x) = 0\), the term is again \(0 = \mathrm{Pr}(x)\); and if \(\mathrm{Pr}(x) > 0\), the hypothesis \(\widetilde{\mathrm{Pr}}(x) \ge \mathrm{Pr}(x)\) enlarges the positive denominator, so
\begin{equation*} \frac{\mathrm{Pr}(x)^2}{\widetilde{\mathrm{Pr}}(x)} \;\le\; \frac{\mathrm{Pr}(x)^2}{\mathrm{Pr}(x)} \;=\; \mathrm{Pr}(x) . \end{equation*}
Summing over \(x \models \alpha\) gives \(\sum_{x\models\alpha}\mathrm{Pr}(x)^2/ \widetilde{\mathrm{Pr}}(x) \le \mathrm{Pr}(\alpha)\), and subtracting \(\mathrm{Pr}(\alpha)^2\),
\begin{equation*} \mathrm{Va}(\tilde{\alpha}) \;\le\; \mathrm{Pr}(\alpha) - \mathrm{Pr}(\alpha)^2 \;=\; \mathrm{Va}(\breve{\alpha}) . \end{equation*}
Show the following: If \(\mathrm{Pr}(.|\alpha)\) can be used as an importance distribution, then \(\mathrm{Pr}(\alpha)\) can be computed exactly after generating a sample of size 1.
The importance sampling function is then constant at \(\mathrm{Pr}(\alpha)\), so a single draw returns it exactly. Assume \(\mathrm{Pr}(\alpha) > 0\), as otherwise \(\mathrm{Pr}(.|\alpha)\) is undefined, and put
\begin{equation*} \widetilde{\mathrm{Pr}}(x) \;=\; \mathrm{Pr}(x \mid \alpha) \;=\; \begin{cases} \dfrac{\mathrm{Pr}(x)}{\mathrm{Pr}(\alpha)}, & \text{if } \alpha \text{ is true at } x \\[6pt] 0, & \text{otherwise.} \end{cases} \end{equation*}
This is legal: at an \(x\) satisfying \(\alpha\), \(\widetilde{\mathrm{Pr}}(x) = \mathrm{Pr}(x)/\mathrm{Pr}(\alpha)\) vanishes iff \(\mathrm{Pr}(x)\) does, as Definition 15.3 demands. Any \(x\) with \(\widetilde{\mathrm{Pr}}(x) > 0\) satisfies \(\alpha\), so by Definition 15.3
\begin{equation*} \tilde{\alpha}(x) \;=\; \frac{\mathrm{Pr}(x)}{\widetilde{\mathrm{Pr}}(x)} \;=\; \frac{\mathrm{Pr}(x)} {\mathrm{Pr}(x)/\mathrm{Pr}(\alpha)} \;=\; \mathrm{Pr}(\alpha) \end{equation*}
on the whole support of \(\widetilde{\mathrm{Pr}}\). Sampling produces only instantiations of positive probability, so \(\mathrm{Av}_1(\tilde{\alpha}) = \tilde{\alpha}(x^1) = \mathrm{Pr}(\alpha)\) for every possible outcome \(x^1\).
Consider a Bayesian network \(X_1 \rightarrow \ldots \rightarrow X_n\) (a chain in which each \(X_i\) for \(i > 1\) has the single parent \(X_{i-1}\), and \(X_1\) is a root) and suppose that we want to estimate \(\mathrm{Pr}(x_n)\) using likelihood weighting. Find a closed form for the variance of this method in terms of the CPT for node \(X_n\) and the marginal distribution of node \(X_{n-1}\). Identify conditions on the network that lead to a zero variance.
\(\mathrm{Va}(\tilde{\alpha}) = \sum_{x_{n-1}} \mathrm{Pr}(x_{n-1}) (\theta_{x_n|x_{n-1}} - \mathrm{Pr}(x_n))^2\), zero exactly when the CPT column of \(X_n\) at \(x_n\) is constant over the support of \(\mathrm{Pr}(X_{n-1})\). The evidence is \(\mathbf{e} = x_n\) on \(\mathbf{E} = \{X_n\}\), so Definition 15.5 deletes the edge \(X_{n-1} \rightarrow X_n\) and makes the CPT of \(X_n\) degenerate at \(x_n\), leaving the structure \(X_1 \rightarrow \ldots \rightarrow X_{n-1}\) and its parameters verbatim. Hence
\begin{equation*} \widetilde{\mathrm{Pr}}(x_1,\ldots,x_{n-1}, x_n) = \mathrm{Pr}(x_1,\ldots,x_{n-1}), \end{equation*}
zero at any other value of \(X_n\); in particular \(X_{n-1}\) keeps its true marginal \(\mathrm{Pr}(X_{n-1})\). With \(X_n\) the sole evidence variable, whose parent takes value \(x_{n-1}\) in \(x\), Theorem 15.14 gives
\begin{equation*} \tilde{\alpha}(x) = \frac{\mathrm{Pr}(x)}{\widetilde{\mathrm{Pr}}(x)} = \theta_{x_n \mid x_{n-1}} , \end{equation*}
read straight off the CPT of \(X_n\). So Theorem 15.11, with \(\mathrm{Pr}(x) = \mathrm{Pr}(x_1,\ldots,x_{n-1})\theta_{x_n|x_{n-1}}\), gives \(\mathrm{Va}(\tilde{\alpha}) = \sum_{x_1,\ldots,x_{n-1}} \mathrm{Pr}(x_1,\ldots,x_{n-1})\theta_{x_n|x_{n-1}}^2 - \mathrm{Pr}(x_n)^2\), whose summand depends on \(x_1,\ldots,x_{n-2}\) only through the leading factor; summing those out gives the required closed form
\begin{equation*} \boxed{\; \mathrm{Va}(\tilde{\alpha}) = \left(\sum_{x_{n-1}} \mathrm{Pr}(x_{n-1})\, \theta_{x_n \mid x_{n-1}}^2\right) - \mathrm{Pr}(x_n)^2 \;} \end{equation*}
with \(\mathrm{Pr}(x_n) = \sum_{x_{n-1}} \mathrm{Pr}(x_{n-1})\theta_{x_n|x_{n-1}}\): only the CPT column of \(X_n\) at \(x_n\) and the marginal \(\mathrm{Pr}(X_{n-1})\) enter, as promised. Completing the square gives the equivalent form
\begin{equation*} \mathrm{Va}(\tilde{\alpha}) = \sum_{x_{n-1}} \mathrm{Pr}(x_{n-1}) \bigl(\theta_{x_n \mid x_{n-1}} - \mathrm{Pr}(x_n)\bigr)^2 . \end{equation*}
A weighted sum of squares vanishes only if each term does, so \(\mathrm{Va}(\tilde{\alpha}) = 0\) iff \(\theta_{x_n|x_{n-1}} = \mathrm{Pr}(x_n)\) for every \(x_{n-1}\) with \(\mathrm{Pr}(x_{n-1}) > 0\). Two conditions on the network realise this:
- (i) The CPT rows of \(X_n\) are identical, \(\theta_{x_n|x_{n-1}} = \theta_{x_n}\) for all \(x_{n-1}\); then by the chain rule \(\mathrm{Pr}(x_n \mid x_1,\ldots,x_{n-1}) = \theta_{x_n}\) at every prefix of positive probability, so every sample returns the weight \(\theta_{x_n} = \mathrm{Pr}(x_n)\). (A parameter property, not a structural one: \(X_{n-1}\) is a parent of \(X_n\), so d-separation certifies nothing here.)
- (ii) \(\mathrm{Pr}(X_{n-1})\) is degenerate, \(\mathrm{Pr}(x^{*}_{n-1}) = 1\), so the condition need hold at one value only — as when \(\theta_{x_1} = 1\) for one value of \(X_1\) and every CPT \(\theta_{X_i|X_{i-1}}\), \(2 \le i \le n-1\), is \(0/1\)-valued.
Exercises 15.22–15.28
Consider the HMM in Figure 15.14 and suppose that our goal is to estimate the probability \(\Pr(S_t \mid o_1, \ldots, o_t)\) for each time \(t\) given evidence \(o_1, \ldots, o_t\). Suppose that we use likelihood weighting for this purpose and let \(\widehat{\Pr}(.)\) be the importance distribution. Show that for every instantiation \(s_1, \ldots, s_t, o_1, \ldots, o_t\) that satisfies the given evidence, we have
\begin{equation*} \frac{\Pr(s_1, \ldots, s_t, o_1, \ldots, o_t)} {\widehat{\Pr}(s_1, \ldots, s_t, o_1, \ldots, o_t)} = \Pr(o_1, \ldots, o_t \mid s_1, \ldots, s_t). \end{equation*}
Describe an implementation of this algorithm whose space complexity is independent of time \(t\).
Figure 15.14 shows, in part (a), an HMM for three time steps: a state chain \(S_1 \to S_2 \to S_3\) together with a sensor edge \(S_i \to O_i\) for each \(i = 1,2,3\). Part (b) shows the corresponding likelihood-weighting HMM given evidence on nodes \(O_1, O_2, O_3\): it has the same nodes and the same state edges \(S_1 \to S_2 \to S_3\), but every sensor edge \(S_i \to O_i\) has been deleted, so each \(O_i\) is a root whose CPT assigns probability \(1\) to its observed value \(o_i\) and \(0\) to all other values (Definition 15.5). The general \(t\)-step HMM and its likelihood-weighting network are obtained in the same way: the HMM is specified by an initial distribution \(\Pr(S_1)\), a transition distribution \(\Pr(S_t \mid S_{t-1})\), and a sensor distribution \(\Pr(O_t \mid S_t)\).
Both sides equal \(\prod_{i=1}^{t}\Pr(o_i \mid s_i)\). The chain rule (4.2) in the HMM \(\mathsf{N}\) gives
\begin{equation*} \Pr(s_1,\ldots,s_t,o_1,\ldots,o_t) = \Pr(s_1) \prod_{i=2}^{t} \Pr(s_i \mid s_{i-1}) \cdot \prod_{i=1}^{t} \Pr(o_i \mid s_i), \end{equation*}
while in the likelihood-weighting network \(\widehat{\mathsf{N}}\) of Definition 15.5 the edges \(S_i \to O_i\) are deleted and each \(O_i\) carries \(\widehat{\theta}_{o_i} = 1\) on the observed value, the state CPTs being untouched, so at an instantiation satisfying the evidence the chain rule gives
\begin{equation*} \widehat{\Pr}(s_1,\ldots,s_t,o_1,\ldots,o_t) = \Pr(s_1) \prod_{i=2}^{t} \Pr(s_i \mid s_{i-1}) , \end{equation*}
the prior over the state trajectory — positive whenever the trajectory itself is, so Definition 15.3 is satisfied. Dividing gives the ratio \(\prod_{i=1}^{t}\Pr(o_i \mid s_i)\), which is Theorem 15.14 for this network (the evidence parameters consistent with the instantiation are the \(\theta_{o_i|s_i}\)). Summing the \(O_i\), which are leaves, out of the first display leaves \(\Pr(s_1,\ldots,s_t) = \Pr(s_1)\prod_{i=2}^t \Pr(s_i \mid s_{i-1})\), and dividing the joint by this marginal identifies that same product with \(\Pr(o_1,\ldots,o_t \mid s_1,\ldots,s_t)\), as required.
For the implementation write \(w(s_1,\ldots,s_t) = \prod_{i=1}^{t} \Pr(o_i \mid s_i)\). By Definition 15.3 and Theorem 15.11 likelihood weighting estimates an event’s probability by the sample mean of its importance sampling function over \(n\) draws from \(\widehat{\Pr}\); taking \(\beta = o_1,\ldots,o_t\) and \(\gamma = s_t \wedge \beta\), and noting every sample satisfies \(\beta\), the two sample means are \(\frac{1}{n}\sum_i w^i\) and \(\frac{1}{n}\sum_{i : s_t^i = s_t} w^i\) with \(w^i = w(s_1^i,\ldots,s_t^i)\), so
\begin{equation*} \Pr(s_t \mid o_1,\ldots,o_t) \approx \frac{\sum_{i \,:\, s_t^i = s_t} w^i}{\sum_{i=1}^{n} w^i}. \end{equation*}
Both the sampling and the weight are recursive in \(t\): sampling from \(\widehat{\Pr}\) visits nodes in topological order (Algorithm 44), so \(s_t^i\) is drawn from \(\Pr(S_t \mid s_{t-1}^i)\) and depends on the past only through \(s_{t-1}^i\), while \(w^i_t = w^i_{t-1}\Pr(o_t \mid s_t^i)\) with \(w^i_0 = 1\). So no trajectory need be stored — only the pair \((s_t^i, w_t^i)\) per sample, observations processed one at a time:
- Initialize: for \(i = 1,\ldots,n\), sample \(s_1^i\) from \(\Pr(S_1)\) and set \(w_1^i \leftarrow \Pr(o_1 \mid s_1^i)\).
- For each \(t > 1\) and each \(i\): sample \(s_t^i\) from \(\Pr(S_t \mid s_{t-1}^i)\), overwriting \(s_{t-1}^i\); then set \(w_t^i \leftarrow w_{t-1}^i \Pr(o_t \mid s_t^i)\), overwriting \(w_{t-1}^i\).
- To report the estimate at time \(t\), accumulate \(P \leftarrow \sum_i w_t^i\) and \(P[s] \leftarrow \sum_{i : s_t^i = s} w_t^i\), and return \(P[s]/P\) for each state \(s\).
Storage is \(n\) states plus \(n\) weights plus a table of size \(|S|\) (or an \(O(n)\) hash table keyed by the states actually sampled), i.e. \(O(n + |S|)\), independent of \(t\); the work per time step is \(O(n)\). Keep the \(w_t^i\) in log-space or rescale them by their sum each step, since the common factor cancels in the ratio above.
Show that Equations 15.11 and 15.12 are implied by Equation 15.10.
Context. Particle filtering on the HMM of Figure 15.8 (a state chain \(S_1 \to S_2 \to \cdots \to S_n\) with a sensor edge \(S_t \to O_t\) at each time) replaces the full HMM by a sequence of three-node network fragments. For each time \(t > 1\) the fragment of Figure 15.9 induces a distribution \(\Pr^{\prime}(S_{t-1}, S_t, O_t)\) and is specified by three CPTs: a CPT \(\Pr^{\star}(S_{t-1})\) for the root \(S_{t-1}\), the transition CPT \(\Pr(S_t \mid S_{t-1})\) taken from the HMM, and the sensor CPT \(\Pr(O_t \mid S_t)\) taken from the HMM. Its edges are \(S_{t-1} \to S_t\) and \(S_t \to O_t\), so
\begin{equation*} \Pr^{\prime}(S_{t-1},S_t,O_t) = \Pr^{\star}(S_{t-1}) \Pr(S_t \mid S_{t-1}) \Pr(O_t \mid S_t). \end{equation*}
Equation 15.10 is the choice
\begin{equation*} \Pr^{\star}(S_{t-1}) = \Pr(S_{t-1} \mid O_1, \ldots, O_{t-1}), \end{equation*}
where \(O_1, \ldots, O_{t-1}\) are fixed at their observed values. Equations 15.11 and 15.12 are
\begin{equation*} \Pr^{\prime}(S_{t-1},S_t,O_t) = \Pr(S_{t-1},S_t,O_t \mid O_1, \ldots, O_{t-1}), \end{equation*}
\begin{equation*} \Pr^{\prime}(S_t \mid O_t) = \Pr(S_t \mid O_1, \ldots, O_t). \end{equation*}
Equation 15.11 is the chain rule under \(\Pr(\cdot \mid \mathbf{o}_{<t})\) with the two Markov properties of the HMM substituted, and Equation 15.12 follows from it by summing out. Write \(\mathbf{o}_{<t}\) for \(O_1 = o_1, \ldots, O_{t-1} = o_{t-1}\), assumed of positive probability. In the order \(S_{t-1}, S_t, O_t\),
\begin{equation*} \begin{aligned} &\Pr(s_{t-1}, s_t, o_t \mid \mathbf{o}_{<t}) \\ &\quad = \Pr(s_{t-1} \mid \mathbf{o}_{<t}) \cdot \Pr(s_t \mid s_{t-1}, \mathbf{o}_{<t}) \cdot \Pr(o_t \mid s_t, s_{t-1}, \mathbf{o}_{<t}). \end{aligned} \end{equation*}
The last two factors simplify by d-separation (Definition 4.1, Theorem 4.1). Any path from \(S_t\) to an \(O_i\), \(i<t\), must leave \(S_t\) backwards through \(S_{t-1}\), a sequential valve that is instantiated (forward it reaches only the leaf \(O_t\) or nodes with index \(>t\)), so \(S_t\) is d-separated from \(O_1,\ldots,O_{t-1}\) by \(S_{t-1}\); and \(O_t\)’s only incident edge is \(S_t \to O_t\), so every path out of it passes through the instantiated sequential valve \(S_t\) and \(O_t\) is d-separated from \(S_{t-1},O_1,\ldots,O_{t-1}\) by \(S_t\). Hence \(\Pr(s_t \mid s_{t-1}, \mathbf{o}_{<t}) = \Pr(s_t \mid s_{t-1})\) and \(\Pr(o_t \mid s_t, s_{t-1}, \mathbf{o}_{<t}) = \Pr(o_t \mid s_t)\); substituting these and then Equation 15.10,
\begin{equation*} \begin{aligned} \Pr(s_{t-1}, s_t, o_t \mid \mathbf{o}_{<t}) &= \Pr(s_{t-1} \mid \mathbf{o}_{<t}) \Pr(s_t \mid s_{t-1}) \Pr(o_t \mid s_t) \\ &= \Pr^{\star}(s_{t-1}) \Pr(s_t \mid s_{t-1}) \Pr(o_t \mid s_t) \\ &= \Pr^{\prime}(s_{t-1}, s_t, o_t), \end{aligned} \end{equation*}
the last step being the chain rule for the fragment of Figure 15.9. Holding for every \(s_{t-1}, s_t, o_t\), this is Equation 15.11. Summing it over \(S_{t-1}\) gives \(\Pr^{\prime}(s_t, o_t) = \Pr(s_t, o_t \mid \mathbf{o}_{<t})\), and summing further over \(S_t\) gives \(\Pr^{\prime}(o_t) = \Pr(o_t \mid \mathbf{o}_{<t})\), assumed positive (equivalently \(\Pr(o_1,\ldots,o_t) > 0\)). Then
\begin{equation*} \begin{aligned} \Pr^{\prime}(s_t \mid o_t) &= \frac{\Pr^{\prime}(s_t, o_t)}{\Pr^{\prime}(o_t)} = \frac{\Pr(s_t, o_t \mid \mathbf{o}_{<t})}{\Pr(o_t \mid \mathbf{o}_{<t})} \\ &= \frac{\Pr(s_t, o_t, \mathbf{o}_{<t}) / \Pr(\mathbf{o}_{<t})} {\Pr(o_t, \mathbf{o}_{<t}) / \Pr(\mathbf{o}_{<t})} = \frac{\Pr(s_t, o_1, \ldots, o_t)}{\Pr(o_1, \ldots, o_t)} \\ &= \Pr(s_t \mid o_1, \ldots, o_t), \end{aligned} \end{equation*}
which is Equation 15.12.
Prove Equations 15.13 and 15.14. That is, show that these are the estimates computed by likelihood weighting when applied to the network fragment at time \(t > 1\).
Context. At time \(t > 1\) particle filtering works with the three-node fragment of Figure 15.9, with edges \(S_{t-1} \to S_t\) and \(S_t \to O_t\), whose CPTs are \(\Pr^{\star}(S_{t-1})\), \(\Pr(S_t \mid S_{t-1})\), and \(\Pr(O_t \mid S_t)\); it induces
\begin{equation*} \Pr^{\prime}(S_{t-1},S_t,O_t) = \Pr^{\star}(S_{t-1}) \Pr(S_t \mid S_{t-1}) \Pr(O_t \mid S_t). \end{equation*}
The corresponding likelihood-weighting network, Figure 15.10(b), is obtained by Definition 15.5: the edge \(S_t \to O_t\) is deleted and the CPT of the root \(O_t\) is set to \(\widehat{\theta}_{o_t} = 1\) on the observed value \(o_t\) and \(0\) elsewhere. Its distribution is written \(\widehat{\Pr}\). Likelihood weighting generates from this network the sample
\begin{equation*} s_{t-1}^1, s_t^1, o_t; \quad s_{t-1}^2, s_t^2, o_t; \quad \ldots; \quad s_{t-1}^n, s_t^n, o_t , \end{equation*}
and estimates \(\Pr^{\prime}(s_t \mid o_t)\) as the ratio of estimates of \(\Pr^{\prime}(s_t, o_t)\) and \(\Pr^{\prime}(o_t)\). Show that the estimate of \(\Pr^{\prime}(o_t)\) is given by Equation 15.13, namely
\begin{equation*} \frac{1}{n} \sum_{i=1}^{n} \Pr(o_t \mid s_t^i) \end{equation*}
and that the estimate of \(\Pr^{\prime}(s_t, o_t)\) is given by Equation 15.14, namely
\begin{equation*} \frac{1}{n} \sum_{\substack{i \\ s_t^i = s_t}} \Pr(o_t \mid s_t^i), \end{equation*}
so that the estimate of \(\Pr^{\prime}(s_t \mid o_t)\) is given by Equation 15.15, namely
\begin{equation*} \frac{\sum_{i \,:\, s_t^i = s_t} \Pr(o_t \mid s_t^i)} {\sum_{i} \Pr(o_t \mid s_t^i)} . \end{equation*}
Every sample carries the weight \(\Pr(o_t \mid s_t)\), and Equations 15.13–15.15 are the sample means that follow. The likelihood-weighting network of Figure 15.10(b) has the single edge \(S_{t-1} \to S_t\) and \(O_t\) a root, so its chain rule gives
\begin{equation*} \widehat{\Pr}(s_{t-1}, s_t, o) = \Pr^{\star}(s_{t-1}) \Pr(s_t \mid s_{t-1}) \widehat{\theta}_{o}, \end{equation*}
with \(\widehat{\theta}_{o} = 1\) iff \(o = o_t\). Hence all the mass sits on instantiations satisfying \(O_t = o_t\), where \(\widehat{\Pr}(s_{t-1}, s_t, o_t) = \Pr^{\star}(s_{t-1})\Pr(s_t \mid s_{t-1})\): sampling by Algorithm 44 draws \(s_{t-1}^i\) from \(\Pr^{\star}(S_{t-1})\), then \(s_t^i\) from \(\Pr(S_t \mid s_{t-1}^i)\), and sets \(O_t = o_t\), which is the sample displayed in the statement. And for every \(\mathbf{x} = s_{t-1}, s_t, o_t\) consistent with the evidence,
\begin{equation*} \frac{\Pr^{\prime}(\mathbf{x})}{\widehat{\Pr}(\mathbf{x})} = \frac{\Pr^{\star}(s_{t-1}) \Pr(s_t \mid s_{t-1}) \Pr(o_t \mid s_t)} {\Pr^{\star}(s_{t-1}) \Pr(s_t \mid s_{t-1})} = \Pr(o_t \mid s_t). \end{equation*}
This is Theorem 15.14 here, \(O_t\) being the sole evidence variable and contributing the single parameter \(\theta_{o_t \mid s_t} = \Pr(o_t \mid s_t)\).
For Equation 15.13 take \(\beta = (O_t = o_t)\), with importance sampling function \(\widetilde{\beta} = \Pr^{\prime}/\widehat{\Pr}\) on \(\mathbf{x} \models \beta\) and \(0\) elsewhere (Definition 15.3, admissible here since \(\widehat{\Pr}(\mathbf{x}) = 0\) at an \(\mathbf{x} \models \beta\) forces \(\Pr^{\star}(s_{t-1})\Pr(s_t \mid s_{t-1}) = 0\) and hence \(\Pr^{\prime}(\mathbf{x}) = 0\)). By Theorem 15.11 \(\mathrm{Ex}(\widetilde{\beta}) = \Pr^{\prime}(o_t)\), and every sampled \(\mathbf{x}^i\) satisfies \(\beta\), so by the ratio above \(\widetilde{\beta}(\mathbf{x}^i) = \Pr(o_t \mid s_t^i)\) and \(\mathrm{Av}_n(\widetilde{\beta}) = \frac{1}{n}\sum_i \Pr(o_t \mid s_t^i)\), Equation 15.13, accumulated on line 5 of Algorithm 47.
For Equation 15.14 fix \(s_t\) and take \(\gamma = (S_t = s_t) \wedge (O_t = o_t)\), whose importance sampling function is \(\Pr(o_t \mid s_t)\) on \(\mathbf{x} \models \gamma\) and \(0\) elsewhere, again by that ratio, with \(\mathrm{Ex}(\widetilde{\gamma}) = \Pr^{\prime}(s_t, o_t)\) (Theorem 15.11). Since each sample satisfies \(O_t = o_t\) automatically, \(\mathbf{x}^i \models \gamma\) exactly when \(s_t^i = s_t\), so
\begin{equation*} \mathrm{Av}_n(\widetilde{\gamma}) = \frac{1}{n} \sum_{\substack{i \\ s_t^i = s_t}} \Pr(o_t \mid s_t^i), \end{equation*}
which is Equation 15.14, line 6 of Algorithm 47. Following Section 15.5, the conditional probability is the ratio of the two estimates, the factors \(1/n\) cancelling:
\begin{equation*} \Pr^{\prime}(s_t \mid o_t) \approx \frac{\mathrm{Av}_n(\widetilde{\gamma})}{\mathrm{Av}_n(\widetilde{\beta})} = \frac{\sum_{i \,:\, s_t^i = s_t} \Pr(o_t \mid s_t^i)} {\sum_{i} \Pr(o_t \mid s_t^i)}, \end{equation*}
which is Equation 15.15 and the value returned on line 8 of Algorithm 47. Nothing above used any particular form of \(\Pr^{\star}(S_{t-1})\), which in the algorithm is the empirical distribution carried by the \(n\) particles from time \(t-1\), so drawing \(s_{t-1}^i\) from it is just taking the \(i\)-th incoming particle — why Algorithm 47 has no explicit sampling step for \(S_{t-1}\).
Write the pseudocode for applying particle filtering to the class of DBNs discussed in Section 15.6.2 and Figure 15.12.
Context. The class of DBNs in question (Figure 15.11) satisfies two conditions: every edge either connects two nodes at the same time \(t\) or goes from a node at time \(t-1\) to a node at time \(t\); and the nodes at time \(t\) split into two sets \(\mathbf{S}_t\) and \(\mathbf{O}_t\), where the nodes \(\mathbf{O}_t\) are leaves whose parents lie in \(\mathbf{S}_t\) and which are guaranteed to be observed at time \(t\). Such a network is a factored HMM: the hidden state is the set \(\mathbf{S}_t\) and the observation is the set \(\mathbf{O}_t\).
The concrete DBN of Figure 15.11 has, in each time slice, hidden variables \(S^1, S^2, S^3, S^4\) and observed variables \(O^1, O^2\), with intra-slice edges
\begin{equation*} S^1_t \to S^3_t, \quad S^2_t \to S^3_t, \quad S^2_t \to S^4_t, \quad S^3_t \to O^1_t, \quad S^4_t \to O^1_t, \quad S^4_t \to O^2_t, \end{equation*}
and inter-slice edges \(S^2_{t-1} \to S^2_t\) and \(S^3_{t-1} \to S^3_t\).
Figure 15.12 shows the two fragments used by particle filtering on this network. Fragment (a) represents \(\Pr(\mathbf{S}_t \mid \mathbf{S}_{t-1})\): it consists of the slice at time \(t\) restricted to \(\mathbf{S}_t\), that is, the nodes \(S^1_t, S^2_t, S^3_t, S^4_t\) with the edges \(S^1_t \to S^3_t\), \(S^2_t \to S^3_t\), \(S^2_t \to S^4_t\) among them, together with the two instantiated parents \(s^2_{t-1}\) and \(s^3_{t-1}\) from time \(t-1\) and their edges into \(S^2_t\) and \(S^3_t\) respectively. It therefore induces \(\Pr(S^1_t, S^2_t, S^3_t, S^4_t \mid s^2_{t-1}, s^3_{t-1})\). Fragment (b) represents \(\Pr(\mathbf{O}_t \mid \mathbf{S}_t)\): it keeps only the nodes in \(\mathbf{O}_t\) and their parents in \(\mathbf{S}_t\), here the instantiated nodes \(s^3_t, s^4_t\) with the edges \(s^3_t \to O^1_t\), \(s^4_t \to O^1_t\) and \(s^4_t \to O^2_t\), so that \(\Pr(O^1_t, O^2_t \mid s^3_t, s^4_t) = \Pr(O^1_t \mid s^3_t, s^4_t) \Pr(O^2_t \mid s^4_t)\) is a product of network parameters.
A particle is an instantiation of the interface \(\mathbf{I}_{t-1} \subseteq \mathbf{S}_{t-1}\), the hidden variables at time \(t-1\) having a child at time \(t\) (\(\{S^2,S^3\}\) in Figure 15.12(a)); this is all that crosses a time boundary, since no other time-\((t-1)\) node has a child at time \(t\), so given \(\mathbf{i}_{t-1}\) the slice at time \(t\) is independent of the rest of the past. Two fragments are used, both ordinary Bayesian networks over one slice:
- \(\mathsf{N}^{\mathrm{tr}}\), the fragment of Figure 15.12(a). Its roots are the instantiated interface nodes from time \(t-1\); the remaining nodes are \(\mathbf{S}_t\) with the intra-slice edges. With the roots clamped to a particle \(\mathbf{i}_{t-1}\) it induces \(\Pr(\mathbf{S}_t \mid \mathbf{i}_{t-1})\).
- \(\mathsf{N}^{\mathrm{sn}}\), the fragment of Figure 15.12(b), used only to read off parameters: for a full state \(\mathbf{s}_t\) and the observation \(\mathbf{o}_t\),
\begin{equation*} \Pr(\mathbf{o}_t \mid \mathbf{s}_t) = \prod_{O \in \mathbf{O}_t} \theta_{o \mid u}, \end{equation*}
where \(o\) is the value of \(O\) in \(\mathbf{o}_t\) and \(u\) the instantiation of \(O\)’s parents in \(\mathbf{s}_t\) — a product of network parameters precisely because the nodes \(\mathbf{O}_t\) are leaves with all parents in \(\mathbf{S}_t\), so \(O(\lvert \mathbf{O}_t \rvert)\) table lookups and no inference.
One iteration of the filter:
DBN PARTICLE FILTER(\(\{\mathbf{i}^1_{t-1}, \ldots, \mathbf{i}^n_{t-1}\}\), \(\mathbf{o}_t\), \(\mathsf{N}^{\mathrm{tr}}\), \(\mathsf{N}^{\mathrm{sn}}\))
input: \(n\) particles \(\mathbf{i}^k_{t-1}\) over \(\mathbf{I}_{t-1}\), the evidence \(\mathbf{o}_t\), and the two fragments. output: a weighted estimate of \(\Pr^{\prime}(\mathbf{S}_t \mid \mathbf{o}_t)\) and \(n\) particles for time \(t+1\).
| line | statement |
|---|---|
| 1 | \(P \leftarrow 0\) (estimate of \(\Pr^{\prime}(\mathbf{o}_t)\)) |
| 2 | \(L \leftarrow\) empty hash table mapping states to weights |
| 3 | for \(k = 1\) to \(n\) do |
| 4 | \(\quad\) clamp the roots of \(\mathsf{N}^{\mathrm{tr}}\) to \(\mathbf{i}^k_{t-1}\) |
| 5 | \(\quad \mathbf{s}^k_t \leftarrow\) SIMULATE BN(\(\mathsf{N}^{\mathrm{tr}}\)) |
| 6 | \(\quad w_k \leftarrow \prod_{O \in \mathbf{O}_t} \theta_{o \mid u}\) |
| 7 | \(\quad P \leftarrow P + w_k\) |
| 8 | \(\quad L[\mathbf{s}^k_t] \leftarrow L[\mathbf{s}^k_t] + w_k\) |
| 9 | end for |
| 10 | if \(P = 0\) then report filter failure and stop |
| 11 | \(L[\mathbf{s}] \leftarrow L[\mathbf{s}] / P\) for each key \(\mathbf{s}\) of \(L\) |
| 12 | draw \(\mathbf{s}^1, \ldots, \mathbf{s}^n\) independently from \(L\) |
| 13 | return \(L\) and the \(n\) particles \(\mathbf{i}^k_t\) |
Here line 5 is Algorithm 44 on the clamped fragment, line 6 reads its parameters from \(\mathsf{N}^{\mathrm{sn}}\) at \(u\) the value of \(O\)’s parents in \(\mathbf{s}^k_t\), line 8 inserts an absent key with weight \(0\), and \(\mathbf{i}^k_t\) on line 13 is the value \(\mathbf{I}_t\) takes in \(\mathbf{s}^k\). At \(t = 1\) omit line 4 and let line 5 be SIMULATE BN on the initial slice restricted to \(\mathbf{S}_1\), which induces \(\Pr(\mathbf{S}_1)\).
Correctness: lines 4 and 5 sample \(\mathbf{s}^k_t\) from \(\Pr(\mathbf{S}_t \mid \mathbf{i}^k_{t-1})\), the vector analogue of line 4 of Algorithm 47, and line 6 computes \(\Pr(\mathbf{o}_t \mid \mathbf{s}^k_t)\), which by Exercise 15.24 — whose argument goes through verbatim with \(S_{t-1}, S_t, O_t\) replaced by the sets \(\mathbf{S}_{t-1}, \mathbf{S}_t, \mathbf{O}_t\) — is the ratio \(\Pr^{\prime}(\mathbf{x})/\widehat{\Pr}(\mathbf{x})\) for the likelihood-weighting network of the time-\(t\) fragment. Lines 7, 8, and 11 therefore compute
\begin{equation*} L[\mathbf{s}_t] = \frac{\sum_{k \,:\, \mathbf{s}^k_t = \mathbf{s}_t} \Pr(\mathbf{o}_t \mid \mathbf{s}^k_t)} {\sum_{k} \Pr(\mathbf{o}_t \mid \mathbf{s}^k_t)}, \end{equation*}
which is Equation 15.15 for the factored case, an estimate of \(\Pr^{\prime}(\mathbf{s}_t \mid \mathbf{o}_t) = \Pr(\mathbf{s}_t \mid \mathbf{o}_1, \ldots, \mathbf{o}_t)\) by Equation 15.12; line 12 draws the next step’s particles from it.
\(L\) must not be indexed by all instantiations of \(\mathbf{S}_t\), whose number \(m\) is exponential in \(\lvert \mathbf{S}_t \rvert\); keyed by a hash table on the states actually sampled it holds at most \(n\) keys, so one iteration runs in \(O(nc)\) time and space with \(c = \lvert \mathbf{S}_t \rvert + \lvert \mathbf{O}_t \rvert\) the slice size (line 5 costs \(O(\lvert \mathbf{S}_t \rvert)\) samplings, line 6 \(O(\lvert \mathbf{O}_t \rvert)\) lookups) — the \(O(n)\) rather than \(O(m)\) behaviour of footnote 6, independent of \(t\).
Show that if a Markov chain satisfies the detailed balance property given in Equation 15.16, then \(\Pr(\mathbf{X})\) must be a stationary distribution for the chain.
Context. A Markov chain for variables \(\mathbf{X}\) is a dynamic Bayesian network \(\mathbf{X}_1 \to \mathbf{X}_2 \to \cdots \to \mathbf{X}_n\) whose instantiations \(\mathbf{x}\) are called states; the CPT for \(\mathbf{X}_1\) is the initial distribution and the CPTs for \(\mathbf{X}_2, \ldots, \mathbf{X}_n\) are the transition matrices, all equal since the chain is homogeneous. \(\mathbb{P}\) denotes the distribution induced by the chain. The distribution \(\Pr(\mathbf{X})\) is a stationary distribution for the chain if setting \(\mathbb{P}(\mathbf{X}_1) = \Pr(\mathbf{X})\) yields \(\mathbb{P}(\mathbf{X}_t) = \Pr(\mathbf{X})\) for all \(t > 1\). Equation 15.16, the detailed balance property, is
\begin{equation*} \Pr(\mathbf{x}) \mathbb{P}(\mathbf{X}_i = \mathbf{x}^{\prime} \mid \mathbf{X}_{i-1} = \mathbf{x}) = \Pr(\mathbf{x}^{\prime}) \mathbb{P}(\mathbf{X}_i = \mathbf{x} \mid \mathbf{X}_{i-1} = \mathbf{x}^{\prime}), \end{equation*}
required to hold for all states \(\mathbf{x}, \mathbf{x}^{\prime}\).
Summing Equation 15.16 over \(\mathbf{x}\) gives stationarity. Write \(K(\mathbf{x},\mathbf{x}^{\prime}) = \mathbb{P}(\mathbf{X}_i = \mathbf{x}^{\prime} \mid \mathbf{X}_{i-1} = \mathbf{x})\) for the common transition matrix (the chain is homogeneous) and set \(\mathbb{P}(\mathbf{X}_1) = \Pr(\mathbf{X})\). If \(\mathbb{P}(\mathbf{X}_t = \mathbf{x}) = \Pr(\mathbf{x})\) for all \(\mathbf{x}\), then marginalizing \(\mathbf{X}_t\) out of the joint of \(\mathbf{X}_t, \mathbf{X}_{t+1}\),
\begin{equation*} \begin{aligned} \mathbb{P}(\mathbf{X}_{t+1} = \mathbf{x}^{\prime}) &= \sum_{\mathbf{x}} \mathbb{P}(\mathbf{X}_t = \mathbf{x})\, K(\mathbf{x},\mathbf{x}^{\prime}) = \sum_{\mathbf{x}} \Pr(\mathbf{x}) K(\mathbf{x},\mathbf{x}^{\prime}) \\ &= \sum_{\mathbf{x}} \Pr(\mathbf{x}^{\prime}) K(\mathbf{x}^{\prime},\mathbf{x}) \qquad \text{(Equation 15.16)} \\ &= \Pr(\mathbf{x}^{\prime}) \sum_{\mathbf{x}} K(\mathbf{x}^{\prime},\mathbf{x}) = \Pr(\mathbf{x}^{\prime}), \end{aligned} \end{equation*}
the final row sum being \(1\) as a normalized CPT column for \(\mathbf{X}_{t+1}\). Induction from the base case \(t = 1\) gives \(\mathbb{P}(\mathbf{X}_t) = \Pr(\mathbf{X})\) for every \(t\).
Provide a Markov chain over three states that has a stationary distribution yet does not satisfy the detailed balance property given in Equation 15.16.
Take the states \(\{1, 2, 3\}\) with the homogeneous transition matrix \(K(\mathbf{x},\mathbf{x}^{\prime}) = \mathbb{P}(\mathbf{X}_i = \mathbf{x}^{\prime} \mid \mathbf{X}_{i-1} = \mathbf{x})\) given by the biased rotation
| from \ to | 1 | 2 | 3 |
|---|---|---|---|
| 1 | 0 | 2/3 | 1/3 |
| 2 | 1/3 | 0 | 2/3 |
| 3 | 2/3 | 1/3 | 0 |
one step clockwise (\(1 \to 2 \to 3 \to 1\)) with probability \(2/3\), one step counterclockwise with probability \(1/3\); each row sums to \(1\) (Check!).
The uniform \(\Pr(1) = \Pr(2) = \Pr(3) = 1/3\) is stationary, since each \(\mathbf{x}^{\prime}\) receives mass from exactly two states, of weights \(2/3\) and \(1/3\):
\begin{equation*} \sum_{\mathbf{x}} \Pr(\mathbf{x}) K(\mathbf{x},\mathbf{x}^{\prime}) = \tfrac{1}{3}\cdot\tfrac{2}{3} + \tfrac{1}{3}\cdot\tfrac{1}{3} = \tfrac{1}{3} = \Pr(\mathbf{x}^{\prime}), \end{equation*}
one-step invariance propagating to all \(t\) by the induction of Exercise 15.26. Detailed balance fails already at \(\mathbf{x} = 1\), \(\mathbf{x}^{\prime} = 2\):
\begin{equation*} \Pr(1) K(1,2) = \tfrac{1}{3}\cdot\tfrac{2}{3} = \tfrac{2}{9} \;\neq\; \tfrac{1}{9} = \tfrac{1}{3}\cdot\tfrac{1}{3} = \Pr(2) K(2,1). \end{equation*}
The Gibbs sampler can be implemented in two ways. In one case, the variable \(S\) whose state will be sampled is chosen at random. In another case, a particular sequence for variables \(S\) is predetermined and sampling is always performed according to that sequence. The second method is known to result in an irreducible Markov chain that does not satisfy the detailed balance property. Compare the performance of these methods empirically.
(The first method is the transition matrix of Definition 15.6, the random-scan Gibbs sampler implemented by Algorithm 48, whose line 1 chooses \(S\) uniformly at random from \(\mathbf{X}\). The second, systematic-scan or sweep, sampler replaces that line by “let \(S\) be the next variable in a fixed cyclic order”.)
The systematic scan wins: at equal work its standard error is about \(1.35\) times smaller, hence its variance about \(1.83\) times smaller. The test network is Figure 15.1, with \(A\) (winter), \(B\) (sprinkler), \(C\) (rain), \(D\) (wet grass), \(E\) (slippery road), edges \(A \to B\), \(A \to C\), \(B \to D\), \(C \to D\), \(C \to E\), and CPTs
| \(A\) | \(\theta_A\) |
|---|---|
| true | .6 |
| false | .4 |
| \(A\) | \(B\) | \(\theta_{B \mid A}\) |
|---|---|---|
| true | true | .2 |
| true | false | .8 |
| false | true | .75 |
| false | false | .25 |
| \(A\) | \(C\) | \(\theta_{C \mid A}\) |
|---|---|---|
| true | true | .8 |
| true | false | .2 |
| false | true | .1 |
| false | false | .9 |
| \(B\) | \(C\) | \(D\) | \(\theta_{D \mid BC}\) |
|---|---|---|---|
| true | true | true | .95 |
| true | true | false | .05 |
| true | false | true | .9 |
| true | false | false | .1 |
| false | true | true | .8 |
| false | true | false | .2 |
| false | false | true | 0 |
| false | false | false | 1 |
| \(C\) | \(E\) | \(\theta_{E \mid C}\) |
|---|---|---|
| true | true | .7 |
| true | false | .3 |
| false | true | 0 |
| false | false | 1 |
Take evidence \(\mathbf{e} = d\) and sample \(\mathbf{X} = \{A, B, C, E\}\) from \(\Pr(S \mid \mathbf{x} - S, d)\) per Theorem 15.17. Exact enumeration gives \(\Pr(d) = .6995\) and
\begin{equation*} \begin{aligned} \Pr(a \mid d) &= .600429, &\qquad \Pr(b \mid d) &= .549392, \\ \Pr(c \mid d) &= .621730, &\qquad \Pr(e \mid d) &= .435211 . \end{aligned} \end{equation*}
Here \(\theta_{e \mid \bar{c}} = 0\) and \(\theta_{d \mid \bar{b}\bar{c}} = 0\) kill six states, but both chains are irreducible on the remaining \(10\), so Theorem 15.15 applies to each. Protocol: one unit of work is one single-variable resampling (the systematic sampler cycling \(A, B, C, E, \ldots\)); each run starts uniformly on the \(10\) support states, burns in \(400\) updates, records the next \(N\), and is repeated \(R = 2000\) times. Root-mean-square error for \(\Pr(a \mid d)\) against \(N\):
| \(N\) | random scan | systematic scan | ratio |
|---|---|---|---|
| 250 | .2649 | .2061 | 1.285 |
| 1000 | .1457 | .1111 | 1.312 |
| 4000 | .0762 | .0561 | 1.358 |
and for all four queries at \(N = 4000\):
| query | random scan | systematic scan | ratio |
|---|---|---|---|
| \(\Pr(a \mid d)\) | .0762 | .0561 | 1.358 |
| \(\Pr(b \mid d)\) | .0679 | .0500 | 1.358 |
| \(\Pr(c \mid d)\) | .0829 | .0615 | 1.348 |
| \(\Pr(e \mid d)\) | .0639 | .0470 | 1.360 |
Both samplers are unbiased to within \(.0017\) at these lengths and both errors decay like \(N^{-1/2}\) per Theorem 15.15, so the whole difference is the constant: reaching a given accuracy costs the random scan roughly \(83\%\) more updates. Two facts account for it.
- (i) Stationary but not reversible
- taking one sweep as the transition, \(K^{\mathrm{sw}} = K_A K_B K_C K_E\), each \(K_X\) preserves \(\Pr(\mathbf{X} \mid d)\) by Theorem 15.16 and hence so does the product, but the reversal is the opposite sweep \(K_E K_C K_B K_A \neq K^{\mathrm{sw}}\). Measured, \(\max \lvert \Pr(\mathbf{x}) K(\mathbf{x},\mathbf{x}^{\prime}) - \Pr(\mathbf{x}^{\prime}) K(\mathbf{x}^{\prime},\mathbf{x}) \rvert\) is \(3.5 \times 10^{-18}\) for the random-scan kernel but \(.014883\) for \(K^{\mathrm{sw}}\); each kernel has \(1\) as a simple eigenvalue with \(\Pr K - \Pr\) below \(6 \times 10^{-17}\), confirming the shared unique stationary distribution. This is Exercise 15.27 concretely.
- (ii) Larger spectral gap
- the second eigenvalue modulus per update is \(.98333\) for the random scan against \(.88112^{1/4} = .96886\) for the sweep, predicting
\begin{equation*} \frac{(1+\lambda_{\mathrm{ran}})/(1-\lambda_{\mathrm{ran}})} {(1+\lambda_{\mathrm{sys}})/(1-\lambda_{\mathrm{sys}})} = \frac{119.0}{63.2} \approx 1.88 , \end{equation*}
close to the measured \(1.83\); over \(4\) updates the random scan leaves a given variable untouched with probability \((3/4)^4 \approx .32\), the sweep never.
Exercises 15.29–15.31
A Markov chain is said to be aperiodic if and only if there exists a specific time \(t > 1\) such that for every pair of states \(x\) and \(x^{\prime}\) we have \(P(X_t = x^{\prime} \mid X_1 = x) > 0\). (The literature on Markov chains contains multiple definitions of the notion of aperiodicity; this is the one used here.) If a Markov chain is aperiodic, it will also be irreducible and hence have a unique stationary distribution, say \(\mathit{Pr}(X)\). (Note the subtle difference between aperiodicity and irreducibility, where the latter states that for every pair of states \(x\) and \(x^{\prime}\) there exists a specific time \(t > 1\), possibly depending on the pair, such that \(P(X_t = x^{\prime} \mid X_1 = x) > 0\). As defined here, aperiodicity implies irreducibility but the converse is not true.) Moreover, if the chain is aperiodic it will converge to its stationary distribution, that is,
\begin{equation*} \lim_{t \to \infty} P(X_t = x^{\prime} \mid X_1 = x) \;=\; \mathit{Pr}(x^{\prime}) \end{equation*}
for all states \(x\) and \(x^{\prime}\). Hence, when simulating the Markov chain, the simulated instantiations are eventually sampled from the stationary distribution \(\mathit{Pr}(X)\) and become independent of the initial state at time \(1\).
Consider now the Markov chain for a binary variable \(X\) with the transition matrix \(P(x \mid \bar{x}) = 1\) and \(P(\bar{x} \mid x) = 1\); hence \(P(\bar{x} \mid \bar{x}) = 0\) and \(P(x \mid x) = 0\). Is this chain aperiodic? Is it irreducible? If it is, identify its unique stationary distribution. Will the chain converge to any distribution?
Not aperiodic, but irreducible, with the uniform distribution as its unique stationary distribution, and it converges to nothing. The transition matrix, rows indexed by the state at time \(i-1\) and columns by the state at time \(i\), is
| \(P(X_i \mid X_{i-1})\) | \(X_i = x\) | \(X_i = \bar{x}\) |
|---|---|---|
| \(X_{i-1} = x\) | 0 | 1 |
| \(X_{i-1} = \bar{x}\) | 1 | 0 |
The chain flips \(X\) deterministically at every step, so by induction on \(t\) (if \(X_t = y\) with probability \(1\) then \(X_{t+1} = \bar{y}\) with probability \(1\)),
\begin{equation*} P(X_t = x \mid X_1 = x) = \mathbf{1}[t \text{ odd}], \qquad P(X_t = \bar{x} \mid X_1 = x) = \mathbf{1}[t \text{ even}]. \end{equation*}
- (i) Aperiodicity fails
- it demands a single \(t > 1\) good for all pairs, yet at each fixed \(t\) exactly one of the two displayed probabilities is \(0\).
- (ii) Irreducibility holds
- the time may depend on the pair, and \(t = 2\) gives \(P(X_2 = \bar{x} \mid X_1 = x) = 1\) while \(t = 3\) gives \(P(X_3 = x \mid X_1 = x) = 1\), for either choice of \(x\).
- (iii) Unique stationary distribution
- writing \(\mathit{Pr}(x) = p\), one step gives \(P(X_i = x) = p\cdot 0 + (1-p)\cdot 1 = 1-p\), so stationarity forces \(p = 1/2\) and \(\mathit{Pr}(x) = \mathit{Pr}(\bar{x}) = 1/2\).
- (iv) Convergence fails
- \(P(X_t = x \mid X_1 = x)\) is \(1, 0, 1, 0, \ldots\), which has no limit, so \(X_t\) never becomes independent of \(X_1\).
Show that the Gibbs transition matrix given in Definition 15.6 satisfies the following condition:
\begin{equation*} \sum_{x^{\prime}} P(X_i = x^{\prime} \mid X_{i-1} = x) \;=\; 1 . \end{equation*}
Recall Definition 15.6: given a distribution \(\mathit{Pr}(X)\) over \(m\) variables \(X\), the corresponding Gibbs transition matrix is
\begin{equation*} P(X_i = x^{\prime} \mid X_{i-1} = x) = \begin{cases} 0, & \text{if } x \text{ and } x^{\prime} \text{ disagree on more than one variable}\\[4pt] \dfrac{1}{m}\, \mathit{Pr}(s^{\prime} \mid x - S), & \text{if } x \text{ and } x^{\prime} \text{ disagree on a single variable } S,\\ & \text{which has value } s^{\prime} \text{ in } x^{\prime}\\[4pt] \dfrac{1}{m} \displaystyle\sum_{S \in X} \mathit{Pr}(s_x \mid x - S), & \text{if } x = x^{\prime} \text{ and } s_x \text{ is the value of } S \text{ in } x. \end{cases} \end{equation*}
The row splits into \(m\) full distributions \(\mathit{Pr}(S \mid x - S)\), each summing to \(1\). Fix the row \(x\), write \(X = \{S_1, \ldots, S_m\}\), let \(s_x^{S}\) be the value of \(S\) in \(x\), and partition the states \(x^{\prime}\) by how many variables they disagree with \(x\) on. Two or more contributes \(0\) by the first case of Definition 15.6, and \((S, s^{\prime}) \mapsto (x - S, s^{\prime})\) over \(S \in X\), \(s^{\prime} \ne s_x^{S}\), is a bijection onto the states disagreeing on exactly one (Check!), so with the remaining two cases, writing \(P(x^{\prime} \mid x) = P(X_i = x^{\prime} \mid X_{i-1} = x)\),
\begin{equation*} \begin{aligned} \sum_{x^{\prime}} P(x^{\prime} \mid x) &= 0 + \frac{1}{m} \sum_{S \in X} \Bigl[ \sum_{s^{\prime} \ne s_x^{S}} \mathit{Pr}(s^{\prime} \mid x - S)
- \mathit{Pr}(s_x^{S} \mid x - S) \Bigr]\\ &= \frac{1}{m} \sum_{S \in X} \sum_{s^{\prime}} \mathit{Pr}(s^{\prime} \mid x - S) = \frac{1}{m} \sum_{S \in X} 1 \;=\; 1, \end{aligned} \end{equation*}
the inner sums merging as they range over \(s^{\prime} \ne s_x^{S}\) and \(s^{\prime} = s_x^{S}\), and each \(\mathit{Pr}(S \mid x - S)\) summing to \(1\) over the values of \(S\) (defined, since Definition 15.6 requires \(\mathit{Pr}(x - S) > 0\)).
Consider the Gibbs transition matrix \(P(X_i \mid X_{i-1})\) given in Definition 15.6 and let \(x\) be a state of variables \(X\). Consider now the state \(x^{\prime}\) generated as follows:
- Let \(S\) be a variable chosen randomly from \(X\).
- Let \(s\) be a state of variable \(S\) sampled from \(\mathit{Pr}(S \mid X - S)\), that is, from \(\mathit{Pr}(S \mid x - S)\), where the variables \(X - S\) are fixed to the values they take in the state \(x\).
- Set state \(x^{\prime}\) to \(x - S, s\).
Show that the state \(x^{\prime}\) is generated with probability \(P(X_i = x^{\prime} \mid X_{i-1} = x)\).
Recall Definition 15.6: given a distribution \(\mathit{Pr}(X)\) over \(m\) variables \(X\), the corresponding Gibbs transition matrix is
\begin{equation*} P(X_i = x^{\prime} \mid X_{i-1} = x) = \begin{cases} 0, & \text{if } x \text{ and } x^{\prime} \text{ disagree on more than one variable}\\[4pt] \dfrac{1}{m}\, \mathit{Pr}(s^{\prime} \mid x - S), & \text{if } x \text{ and } x^{\prime} \text{ disagree on a single variable } S,\\ & \text{which has value } s^{\prime} \text{ in } x^{\prime}\\[4pt] \dfrac{1}{m} \displaystyle\sum_{S \in X} \mathit{Pr}(s_x \mid x - S), & \text{if } x = x^{\prime} \text{ and } s_x \text{ is the value of } S \text{ in } x. \end{cases} \end{equation*}
Here chosen randomly means chosen uniformly at random from the \(m\) variables in \(X\).
The two-stage draw picks the pair \((S,s)\) with probability \(Q(S,s) = \tfrac{1}{m}\mathit{Pr}(s \mid x - S)\) by the chain rule and outputs the deterministic function \(g(S,s) = (x - S, s)\), so by total probability over the disjoint outcomes, writing \(s_x^{S}\) for the value of \(S\) in \(x\) and \(X = \{S_1, \ldots, S_m\}\),
\begin{equation*} Q(x^{\prime}) \;=\; \sum_{S \in X} \; \sum_{s} \frac{1}{m}\, \mathit{Pr}(s \mid x - S) \cdot \mathbf{1}\!\left[ (x - S, s) = x^{\prime} \right]. \end{equation*}
Since \(g(S,s)\) agrees with \(x\) off \(S\), it disagrees with \(x\) on at most one variable, and on \(S\) exactly when \(s \ne s_x^{S}\), splitting \(Q\) into the three cases of Definition 15.6:
- (i) \(x^{\prime}\) disagrees with \(x\) on more than one variable
- no outcome maps to \(x^{\prime}\), so \(Q(x^{\prime}) = 0\).
- (ii) \(x^{\prime}\) disagrees exactly on \(S_0\), with value \(s^{\prime}\) there
- any \(S \ne S_0\) leaves \(S_0\) at its value in \(x\), so only \(S = S_0\) can match, and then only for \(s = s^{\prime}\); hence \(Q(x^{\prime}) = \tfrac{1}{m}\mathit{Pr}(s^{\prime} \mid x - S_0)\), the conditioning instantiation being the one named in the definition because \(x - S_0 = x^{\prime} - S_0\).
- (iii) \(x^{\prime} = x\)
- \(g(S,s) = x\) iff \(s = s_x^{S}\), one value of \(s\) for each of the \(m\) choices of \(S\), so \(Q(x) = \tfrac{1}{m}\sum_{S \in X}\mathit{Pr}(s_x^{S} \mid x - S)\).
The cases being exhaustive, \(Q(x^{\prime}) = P(X_i = x^{\prime} \mid X_{i-1} = x)\) throughout (assuming, as in Exercise 15.30, \(\mathit{Pr}(x - S) > 0\) for every \(S\)).
Sensitivity Analysis
Exercises 16.1–16.7
Let us say that two probability distributions \(\mathrm{Pr}^0(\mathbf{X})\) and \(\mathrm{Pr}(\mathbf{X})\) have the same support if for every instantiation \(\mathbf{x}\), \(\mathrm{Pr}^0(\mathbf{x}) = 0\) iff \(\mathrm{Pr}(\mathbf{x}) = 0\). Show that the CD distance satisfies the following property: \(D(\mathrm{Pr}^0, \mathrm{Pr}) = \infty\) iff the distributions \(\mathrm{Pr}^0\) and \(\mathrm{Pr}\) do not have the same support.
Recall Definition 16.1: for two distributions over the same set of variables \(\mathbf{X}\),
\begin{equation*} D(\mathrm{Pr}^0, \mathrm{Pr}) \;=\; \ln \max_{\mathbf{x}} \frac{\mathrm{Pr}(\mathbf{x})}{\mathrm{Pr}^0(\mathbf{x})} \;-\; \ln \min_{\mathbf{x}} \frac{\mathrm{Pr}(\mathbf{x})}{\mathrm{Pr}^0(\mathbf{x})}, \end{equation*}
where \(0/0 \stackrel{\text{def}}{=} 1\) and \(\infty/\infty \stackrel{\text{def}}{=} 1\).
\(D = \infty\) exactly when the ratio \(r(\mathbf{x}) = \mathrm{Pr}(\mathbf{x})/\mathrm{Pr}^0(\mathbf{x})\) of Definition 16.1 hits \(\infty\) or \(0\), and under the convention \(0/0 = 1\) those are precisely the support disagreements:
| \(\mathrm{Pr}^0(\mathbf{x})\) | \(\mathrm{Pr}(\mathbf{x})\) | \(r(\mathbf{x})\) |
|---|---|---|
| \(= 0\) | \(= 0\) | \(1\) |
| \(> 0\) | \(> 0\) | finite and positive |
| \(= 0\) | \(> 0\) | \(\infty\) |
| \(> 0\) | \(= 0\) | \(0\) |
No \(\infty - \infty\) can arise, since \(\min_{\mathbf{x}} r = \infty\) would force \(\mathrm{Pr}^0 \equiv 0\) and \(\max_{\mathbf{x}} r = 0\) would force \(\mathrm{Pr} \equiv 0\), each against normalization; so \(\max r \in (0,\infty]\), \(\min r \in [0,\infty)\) and \(D \in (-\infty,+\infty]\).
- (i) Different support
- some \(\mathbf{x}\) falls in row three, giving \(\max r = \infty\), or in row four, giving \(\min r = 0\); either way \(D(\mathrm{Pr}^0,\mathrm{Pr}) = \infty\).
- (ii) Same support
- rows three and four are empty, so \(r = 1\) off the common support and \(r \in (0,\infty)\) on it; over finitely many instantiations \(0 < \min_{\mathbf{x}} r \le \max_{\mathbf{x}} r < \infty\), whence \(D(\mathrm{Pr}^0,\mathrm{Pr}) < \infty\).
Show that the CD distance satisfies the properties of positiveness, symmetry, and triangle inequality. That is, if \(\mathrm{Pr}^0\), \(\mathrm{Pr}\), and \(\mathrm{Pr}^{\prime}\) are three probability distributions over the same set of variables \(\mathbf{X}\), then
- Positiveness
- \(D(\mathrm{Pr}^0,\mathrm{Pr}) \ge 0\), and \(D(\mathrm{Pr}^0,\mathrm{Pr}) = 0\) iff \(\mathrm{Pr}^0 = \mathrm{Pr}\).
- Symmetry
- \(D(\mathrm{Pr}^0,\mathrm{Pr}) = D(\mathrm{Pr},\mathrm{Pr}^0)\).
- Triangle inequality
- \(D(\mathrm{Pr}^0,\mathrm{Pr}) + D(\mathrm{Pr},\mathrm{Pr}^{\prime}) \ge D(\mathrm{Pr}^0,\mathrm{Pr}^{\prime})\).
Here \(D\) is the CD distance of Definition 16.1,
\begin{equation*} D(\mathrm{Pr}^0, \mathrm{Pr}) \;=\; \ln \max_{\mathbf{x}} \frac{\mathrm{Pr}(\mathbf{x})}{\mathrm{Pr}^0(\mathbf{x})} \;-\; \ln \min_{\mathbf{x}} \frac{\mathrm{Pr}(\mathbf{x})}{\mathrm{Pr}^0(\mathbf{x})}, \end{equation*}
with \(0/0 = 1\) and \(\infty/\infty = 1\).
All three rest on the sandwich \(\min_{\mathbf{x}} r \le 1 \le \max_{\mathbf{x}} r\), where \(r(\mathbf{x}) = \mathrm{Pr}(\mathbf{x})/\mathrm{Pr}^0(\mathbf{x})\) as in Exercise 16.1.
- (i) Positiveness
- if \(r(\mathbf{x}) > 1\) for every \(\mathbf{x}\), the case table of Exercise 16.1 excludes its first and fourth rows, so \(\mathrm{Pr}(\mathbf{x}) > \mathrm{Pr}^0(\mathbf{x})\) throughout and summing gives \(1 > 1\); symmetrically \(r(\mathbf{x}) < 1\) throughout excludes the first and third rows and gives \(1 < 1\). This is the sandwich, whence
\begin{equation*} D(\mathrm{Pr}^0,\mathrm{Pr}) = \ln \max_{\mathbf{x}} r - \ln \min_{\mathbf{x}} r \;\ge\; \ln 1 - \ln 1 \;=\; 0 . \end{equation*}
And \(D = 0\) forces \(\max r = \min r\), hence \(r \equiv 1\) by the sandwich, hence \(\mathrm{Pr} = \mathrm{Pr}^0\) by rows one and two of the table; conversely \(\mathrm{Pr} = \mathrm{Pr}^0\) gives \(r \equiv 1\) and \(D = 0\).
- (ii) Symmetry
- the conventions are reciprocal-consistent, so the ratio \(\tilde r = \mathrm{Pr}^0/\mathrm{Pr}\) used for \(D(\mathrm{Pr},\mathrm{Pr}^0)\) equals \(1/r\) in the extended reals on each of the four rows (Check!), and \(t \mapsto 1/t\) is order-reversing on \([0,\infty]\), so \(\max \tilde r = 1/\min r\) and \(\min \tilde r = 1/\max r\) and
\begin{equation*} D(\mathrm{Pr},\mathrm{Pr}^0) = -\ln \min_{\mathbf{x}} r + \ln \max_{\mathbf{x}} r = D(\mathrm{Pr}^0,\mathrm{Pr}), \end{equation*}
the rearrangement legitimate because at most one of the two logarithms is infinite.
- (iii) Triangle inequality
- trivial if either left distance is \(\infty\), both being nonnegative by (i), so assume both finite; then all three distributions share one support \(S\) by Exercise 16.1. Put \(a = \mathrm{Pr}/\mathrm{Pr}^0\), \(b = \mathrm{Pr}^{\prime}/\mathrm{Pr}\), \(c = \mathrm{Pr}^{\prime}/\mathrm{Pr}^0\). Cancelling \(\mathrm{Pr}(\mathbf{x})\) gives \(c = ab\) on \(S\), where all six probabilities are positive, and off \(S\) the convention \(0/0 = 1\) makes it read \(1 = 1\cdot 1\). So \(c(\mathbf{x}) = a(\mathbf{x})b(\mathbf{x}) \in (0,\infty)\) throughout, no indeterminate product, giving \(\max c \le (\max a)(\max b)\) and \(\min c \ge (\min a)(\min b)\) between positive reals, so logarithms preserve these and
\begin{equation*} \begin{aligned} D(\mathrm{Pr}^0,\mathrm{Pr}^{\prime}) &= \ln \max_{\mathbf{x}} c - \ln \min_{\mathbf{x}} c \\ &\le \bigl(\ln \max a - \ln \min a\bigr) + \bigl(\ln \max b - \ln \min b\bigr) \\ &= D(\mathrm{Pr}^0,\mathrm{Pr}) + D(\mathrm{Pr},\mathrm{Pr}^{\prime}). \end{aligned} \end{equation*}
Consider a distribution \(\mathrm{Pr}(\mathbf{X})\), event \(\alpha\), and show that
\begin{equation*} \frac{\mathrm{Pr}(\alpha)}{\mathrm{Pr}^0(\alpha)} \;\le\; \max_{\mathbf{x} \models \alpha} \frac{\mathrm{Pr}(\mathbf{x})}{\mathrm{Pr}^0(\mathbf{x})} \end{equation*}
and
\begin{equation*} \frac{\mathrm{Pr}(\alpha)}{\mathrm{Pr}^0(\alpha)} \;\ge\; \min_{\mathbf{x} \models \alpha} \frac{\mathrm{Pr}(\mathbf{x})}{\mathrm{Pr}^0(\mathbf{x})} . \end{equation*}
Here \(\mathrm{Pr}^0(\mathbf{X})\) is a second distribution over the same variables, \(\mathbf{x}\) ranges over the instantiations of \(\mathbf{X}\) that satisfy \(\alpha\), and the conventions of Definition 16.1 apply (\(0/0 = 1\)).
Both bounds are the mediant inequality, that a ratio of sums lies between the extreme ratios of its terms. Let \(\alpha\) be satisfiable, \(A = \{\mathbf{x} : \mathbf{x} \models \alpha\}\), and, with \(r = \mathrm{Pr}/\mathrm{Pr}^0 \in [0,\infty]\) by the case table of Exercise 16.1,
\begin{equation*} M = \max_{\mathbf{x} \in A} r(\mathbf{x}), \qquad m = \min_{\mathbf{x} \in A} r(\mathbf{x}) . \end{equation*}
Since \(A\) need not carry all the mass, the normalization argument of Exercise 16.1 does not exclude \(M = 0\) or \(m = \infty\), so those are handled explicitly.
- (i) Upper bound
- trivial if \(M = \infty\), so let \(M < \infty\). Then \(\mathrm{Pr}(\mathbf{x}) \le M\,\mathrm{Pr}^0(\mathbf{x})\) on \(A\): where \(\mathrm{Pr}^0(\mathbf{x}) > 0\) this is the definition of \(M\), and where \(\mathrm{Pr}^0(\mathbf{x}) = 0\) finiteness of \(M\) forces \(\mathrm{Pr}(\mathbf{x}) = 0\), leaving \(0 \le 0\). Summing over \(A\) gives \(\mathrm{Pr}(\alpha) \le M\,\mathrm{Pr}^0(\alpha)\), and dividing by \(\mathrm{Pr}^0(\alpha) > 0\) gives the claim. If instead \(\mathrm{Pr}^0(\alpha) = 0\), then \(\mathrm{Pr}(\alpha) = 0\) too, so the left-hand side is \(0/0 = 1\) while every ratio on \(A\) is \(0/0 = 1\) and \(M = 1\): equality.
- (ii) Lower bound
- trivial if \(m = 0\). If \(m = \infty\) then \(\mathrm{Pr}^0(\mathbf{x}) = 0 < \mathrm{Pr}(\mathbf{x})\) throughout \(A\), so \(\mathrm{Pr}^0(\alpha) = 0 < \mathrm{Pr}(\alpha)\) and the claim reads \(\infty \ge \infty\). For \(0 < m < \infty\) we get \(\mathrm{Pr}(\mathbf{x}) \ge m\,\mathrm{Pr}^0(\mathbf{x})\) on \(A\), the case \(\mathrm{Pr}^0(\mathbf{x}) = 0\) reading \(\mathrm{Pr}(\mathbf{x}) \ge m\cdot 0 = 0\), a legitimate product since \(m\) is finite; summing and dividing by \(\mathrm{Pr}^0(\alpha) > 0\) gives the claim. If \(\mathrm{Pr}^0(\alpha) = 0\) the left-hand side is \(\infty\) when \(\mathrm{Pr}(\alpha) > 0\), and otherwise every ratio on \(A\) is \(1\), so \(m = 1\) and the claim again holds.
Show that the bounds given by Theorem 16.1 are tight in the sense that for every pair of distributions \(\mathrm{Pr}^0\) and \(\mathrm{Pr}\), there are events \(\alpha\) and \(\beta\) such that
\begin{equation*} \frac{O(\alpha \mid \beta)}{O^0(\alpha \mid \beta)} \;=\; e^{D(\mathrm{Pr}^0,\mathrm{Pr})} \end{equation*}
\begin{equation*} \frac{O(\neg\alpha \mid \beta)}{O^0(\neg\alpha \mid \beta)} \;=\; e^{-D(\mathrm{Pr}^0,\mathrm{Pr})} . \end{equation*}
Recall that Theorem 16.1 states \(e^{-D(\mathrm{Pr}^0,\mathrm{Pr})} \le O(\alpha|\beta)/O^0(\alpha|\beta) \le e^{D(\mathrm{Pr}^0,\mathrm{Pr})}\) for arbitrary events \(\alpha\) and \(\beta\), where \(O(\alpha|\beta) = \mathrm{Pr}(\alpha|\beta)/\mathrm{Pr}(\neg\alpha|\beta)\).
Take \(\alpha = \mathbf{x}^\star\) and \(\beta = \mathbf{x}^\star \vee \mathbf{x}_\star\), where \(r(\mathbf{x}^\star) = \max_{\mathbf{x}} r\) and \(r(\mathbf{x}_\star) = \min_{\mathbf{x}} r\) for \(r = \mathrm{Pr}/\mathrm{Pr}^0\). Distinct instantiations being mutually exclusive, \(\alpha \wedge \beta = \mathbf{x}^\star\) and \(\neg\alpha \wedge \beta = \mathbf{x}_\star\), and the odds conditioned on \(\beta\) are ratios of joint probabilities.
- (i) \(0 < D < \infty\)
- by Exercise 16.1 the supports coincide, and \(r = 1\) off the common support \(S\). If \(\max r = 1\) then \(\mathrm{Pr} \le \mathrm{Pr}^0\) on \(S\), strictly somewhere since \(\min r < 1\) by Exercise 16.2 and \(D > 0\), so summing over \(S\) gives \(1 < 1\); hence \(\max r > 1\) and it is attained inside \(S\), and symmetrically \(\min r < 1\) inside \(S\). So all four of \(\mathrm{Pr}(\mathbf{x}^\star), \mathrm{Pr}^0(\mathbf{x}^\star), \mathrm{Pr}(\mathbf{x}_\star), \mathrm{Pr}^0(\mathbf{x}_\star)\) are positive and \(\mathbf{x}^\star \ne \mathbf{x}_\star\), so every odds below is finite and positive, and
\begin{equation*} \begin{aligned} \frac{O(\alpha|\beta)}{O^0(\alpha|\beta)} &= \frac{\mathrm{Pr}(\mathbf{x}^\star)}{\mathrm{Pr}(\mathbf{x}_\star)} \cdot \frac{\mathrm{Pr}^0(\mathbf{x}_\star)}{\mathrm{Pr}^0(\mathbf{x}^\star)} = \frac{r(\mathbf{x}^\star)}{r(\mathbf{x}_\star)} = e^{D(\mathrm{Pr}^0,\mathrm{Pr})} , \end{aligned} \end{equation*}
whence \(O(\neg\alpha|\beta)/O^0(\neg\alpha|\beta)\), the reciprocal, is \(e^{-D}\).
- (ii) \(D = 0\)
- then \(\mathrm{Pr} = \mathrm{Pr}^0\) by Exercise 16.2 and both identities read \(1 = e^0\); it remains to name a pair whose odds ratio is unambiguously \(1\). If two instantiations \(\mathbf{x}_1 \ne \mathbf{x}_2\) have positive probability, \(\alpha = \mathbf{x}_1\), \(\beta = \mathbf{x}_1 \vee \mathbf{x}_2\) makes both odds the positive real \(\mathrm{Pr}(\mathbf{x}_1)/\mathrm{Pr}(\mathbf{x}_2)\). Otherwise \(\mathrm{Pr}\) is a point mass at \(\mathbf{x}_1\), and for a second instantiation \(\mathbf{x}_2\) take \(\alpha = \mathbf{x}_2\), \(\beta = \mathbf{x}_1 \vee \mathbf{x}_2\): both odds are \(0\) with ratio \(0/0 = 1\), and both \(\neg\alpha\) odds are \(\infty\) with ratio \(\infty/\infty = 1\). With only one instantiation the claim is vacuous.
- (iii) \(D = \infty\)
- the supports differ by Exercise 16.1. If \(\mathrm{Pr}^0(\mathbf{x}^\star) = 0 < \mathrm{Pr}(\mathbf{x}^\star)\) for some \(\mathbf{x}^\star\), pick \(\mathbf{x}_\star \ne \mathbf{x}^\star\) with \(\mathrm{Pr}^0(\mathbf{x}_\star) > 0\) (one exists as \(\mathrm{Pr}^0\) sums to one); then \(O^0(\alpha|\beta) = 0\) while \(O(\alpha|\beta) > 0\), so the ratio is \(\infty = e^D\) and its reciprocal \(0 = e^{-D}\). If instead \(\mathrm{Pr}(\mathbf{x}_\star) = 0 < \mathrm{Pr}^0(\mathbf{x}_\star)\), pick \(\mathbf{x}^\star \ne \mathbf{x}_\star\) with \(\mathrm{Pr}(\mathbf{x}^\star) > 0\); then \(O(\alpha|\beta) = \infty\) while \(O^0(\alpha|\beta)\) is finite, and the same conclusion follows.
Show that Inequality 16.2 is implied by Theorem 16.1. That is, derive
\begin{equation*} \frac{e^{-d}\, p}{\bigl(e^{-d} - 1\bigr) p + 1} \;\le\; \mathrm{Pr}(\alpha|\beta) \;\le\; \frac{e^{d}\, p}{\bigl(e^{d} - 1\bigr) p + 1}, \end{equation*}
where \(p = \mathrm{Pr}^0(\alpha|\beta)\) and \(d = D(\mathrm{Pr}^0,\mathrm{Pr})\), from the odds bound of Theorem 16.1,
\begin{equation*} e^{-d} \;\le\; \frac{O(\alpha|\beta)}{O^0(\alpha|\beta)} \;\le\; e^{d}, \end{equation*}
in which \(O(\alpha|\beta) = \mathrm{Pr}(\alpha|\beta)/\mathrm{Pr}(\neg\alpha|\beta)\) and \(O^0(\alpha|\beta) = \mathrm{Pr}^0(\alpha|\beta)/\mathrm{Pr}^0(\neg\alpha|\beta)\).
Apply the strictly increasing map \(f(t) = t/(1+t)\) on \([0,\infty]\), inverse to the odds map \(q \mapsto q/(1-q)\) with \(f(\infty) = 1\) (Check!), to each half of Theorem 16.1. Write \(p = \mathrm{Pr}^0(\alpha|\beta)\), \(q = \mathrm{Pr}(\alpha|\beta)\), so that \(O^0(\alpha|\beta) = p/(1-p)\) and \(O(\alpha|\beta) = q/(1-q)\), and assume \(\mathrm{Pr}^0(\beta), \mathrm{Pr}(\beta) > 0\) and \(d < \infty\) (at \(d = \infty\) Theorem 16.1 constrains the odds not at all, and Inequality 16.2, whose \(e^{\pm d}p\) is then indeterminate at \(p = 0\), is read as the vacuous \(0 \le \mathrm{Pr}(\alpha|\beta) \le 1\)).
- (i) Upper bound
- Theorem 16.1 gives \(q/(1-q) \le e^{d}p/(1-p) =: K\). If \(K = \infty\), that is \(p = 1\), the claimed bound is \(e^d/e^d = 1 \ge q\). Otherwise \(K\) is a nonnegative real, multiplying by \(1-q \ge 0\) gives \(q(1+K) \le K\), so \(q \le f(K)\) (here \(q = 1\) is impossible, as it would make the odds infinite against finite \(K\)), and
\begin{equation*} f(K) = \frac{e^{d}p/(1-p)}{1 + e^{d}p/(1-p)} = \frac{e^{d}p}{(1-p) + e^{d}p} = \frac{e^{d}p}{\bigl(e^{d}-1\bigr)p + 1}. \end{equation*}
- (ii) Lower bound
- symmetrically \(q/(1-q) \ge e^{-d}p/(1-p) =: k\). If \(k = \infty\) then \(p = q = 1\) and the claimed bound is \(1 = q\); otherwise applying \(f\) to both sides gives
\begin{equation*} q \;\ge\; f(k) = \frac{e^{-d}p}{(1-p) + e^{-d}p} = \frac{e^{-d}p}{\bigl(e^{-d}-1\bigr)p + 1}. \end{equation*}
Both denominators \((1-p) + e^{\pm d}p\) are positive on \([0,1]\) (\(p\) and \(1-p\) are not both zero), so the two displays are Inequality 16.2.
Consider two Bayesian networks \(\mathcal{N}^0\) and \(\mathcal{N}\), where network \(\mathcal{N}\) is obtained from \(\mathcal{N}^0\) by changing a single parameter value \(\theta^0_x\) in the CPT of root node \(X\) (co-varying parameters being changed according to the proportional scheme of Definition 16.2). Show the following for any evidence \(\mathbf{e}\),
\begin{equation*} \frac{O(x|\mathbf{e})}{O^0(x|\mathbf{e})} \;=\; \frac{O(x)}{O^0(x)} . \end{equation*}
Here \(O(x|\mathbf{e}) = \mathrm{Pr}(x|\mathbf{e})/\mathrm{Pr}(\neg x|\mathbf{e})\) and \(O(x) = \mathrm{Pr}(x)/\mathrm{Pr}(\neg x)\) are the posterior and prior odds of \(x\) in \(\mathcal{N}\), and similarly for \(\mathcal{N}^0\).
The evidence cancels because the proportional scheme scales every co-varying parameter by one common factor \(c = (1-\theta_x)/(1-\theta^0_x)\). Let \(\mathbf{Y}\) be the other network variables, with \(\mathbf{e}\) an instantiation of variables among them (if \(\mathbf{e}\) fixed \(X\), both posterior odds would degenerate simultaneously). Only \(\Theta_X\) changes, so writing \(f(x^\star,\mathbf{y})\) for the product of the CPT entries of all variables other than \(X\) and \(g(x^\star) = \sum_{\mathbf{y} \models \mathbf{e}} f(x^\star, \mathbf{y})\), which is therefore the same in both networks,
\begin{equation*} \mathrm{Pr}(x^\star, \mathbf{e}) = \theta_{x^\star}\, g(x^\star), \qquad \mathrm{Pr}^0(x^\star, \mathbf{e}) = \theta^0_{x^\star}\, g(x^\star). \end{equation*}
Definition 16.2, with \(\theta^0_x \ne 1\) (else \(\mathrm{Pr}^0(\neg x,\mathbf{e}) = 0\) and the initial odds are infinite), gives \(\theta_{x^\star} = c\,\theta^0_{x^\star}\) for every \(x^\star \ne x\), hence
\begin{equation*} \mathrm{Pr}(\neg x, \mathbf{e}) = \sum_{x^\star \ne x} \theta_{x^\star}\, g(x^\star) = c \cdot \mathrm{Pr}^0(\neg x, \mathbf{e}). \end{equation*}
Posterior odds are ratios of joint probabilities, \(\mathrm{Pr}(\mathbf{e})\) cancelling, so assuming \(g(x) > 0\), \(\mathrm{Pr}^0(\neg x,\mathbf{e}) > 0\) and \(\theta_x < 1\) (if \(\theta_x = 1\) then \(c = 0\) and both \(O(x|\mathbf{e})\) and \(O(x)\) are infinite, so the identity reads \(\infty = \infty\)),
\begin{equation*} \begin{aligned} \frac{O(x|\mathbf{e})}{O^0(x|\mathbf{e})} &= \frac{\theta_x\, g(x)}{c\,\mathrm{Pr}^0(\neg x,\mathbf{e})} \cdot \frac{\mathrm{Pr}^0(\neg x,\mathbf{e})}{\theta^0_x\, g(x)} = \frac{1}{c}\cdot\frac{\theta_x}{\theta^0_x} \\ &= \frac{\theta_x/(1-\theta_x)}{\theta^0_x/(1-\theta^0_x)} = \frac{O(x)}{O^0(x)}, \end{aligned} \end{equation*}
the last step because \(X\) is a root, so its prior is its CPT: \(\mathrm{Pr}(x) = \theta_x\) and \(\mathrm{Pr}(\neg x) = 1-\theta_x\).
Show that \(D(\Theta^0_{X|\mathbf{U}}, \Theta_{X|\mathbf{U}}) \ge \max_{\mathbf{u}} D(\Theta^0_{X|\mathbf{u}}, \Theta_{X|\mathbf{u}})\).
Here \(\Theta^0_{X|\mathbf{U}}\) and \(\Theta_{X|\mathbf{U}}\) are an initial and a modified CPT for variable \(X\) with parents \(\mathbf{U}\), \(\Theta^0_{X|\mathbf{u}}\) and \(\Theta_{X|\mathbf{u}}\) are the rows of these CPTs corresponding to the parent instantiation \(\mathbf{u}\), and the CD distance of Definition 16.1 is applied to tables by taking the extreme entry-wise ratios over the entries of the tables in question:
\begin{equation*} D(\Theta^0_{X|\mathbf{U}}, \Theta_{X|\mathbf{U}}) = \ln \max_{x,\mathbf{u}} \frac{\theta_{x|\mathbf{u}}}{\theta^0_{x|\mathbf{u}}} - \ln \min_{x,\mathbf{u}} \frac{\theta_{x|\mathbf{u}}}{\theta^0_{x|\mathbf{u}}}, \end{equation*}
\begin{equation*} D(\Theta^0_{X|\mathbf{u}}, \Theta_{X|\mathbf{u}}) = \ln \max_{x} \frac{\theta_{x|\mathbf{u}}}{\theta^0_{x|\mathbf{u}}} - \ln \min_{x} \frac{\theta_{x|\mathbf{u}}}{\theta^0_{x|\mathbf{u}}}, \end{equation*}
with the conventions \(0/0 = 1\) and \(\infty/\infty = 1\).
The entries of one row form a subset of the CPT’s entries, so its extrema are dominated. Write \(r(x,\mathbf{u}) = \theta_{x|\mathbf{u}}/\theta^0_{x|\mathbf{u}} \in [0,\infty]\) and fix \(\mathbf{u}\). Maximizing over a superset can only increase, minimizing over a superset can only decrease, and \(\ln\) is increasing on \([0,\infty]\), so
\begin{equation*} \ln \max_{x,\mathbf{u}^\star} r \;\ge\; \ln \max_{x} r(x,\mathbf{u}), \qquad \ln \min_{x,\mathbf{u}^\star} r \;\le\; \ln \min_{x} r(x,\mathbf{u}). \end{equation*}
No \(\infty - \infty\) arises on subtracting: every row of both CPTs sums to one, so Exercise 16.1’s argument applies inside a fixed row and gives \(\min_{x} r(x,\mathbf{u}) \le 1 \le \max_{x} r(x,\mathbf{u})\), a sandwich only widened by extrema over the whole CPT, so every \(\ln\max \ge 0\) and every \(\ln\min \le 0\). Subtracting,
\begin{equation*} \begin{aligned} D(\Theta^0_{X|\mathbf{U}}, \Theta_{X|\mathbf{U}}) &= \ln \max_{x,\mathbf{u}^\star} r - \ln \min_{x,\mathbf{u}^\star} r \\ &\ge \ln \max_{x} r(x,\mathbf{u}) - \ln \min_{x} r(x,\mathbf{u}) = D(\Theta^0_{X|\mathbf{u}}, \Theta_{X|\mathbf{u}}), \end{aligned} \end{equation*}
and \(\mathbf{u}\) was arbitrary, so the left-hand side dominates the maximum over \(\mathbf{u}\). Equality would need one row realizing both global extrema, which in general fails; for binary \(X\) with binary parent \(U\),
| \(U\) | \(X\) | \(θ^0_{x | u}\) | \(θ_{x | u}\) | ratio |
|---|---|---|---|---|---|---|
| \(u\) | \(x\) | \(.10\) | \(.50\) | \(5.0\) | ||
| \(u\) | \(\bar x\) | \(.90\) | \(.50\) | \(5/9 \approx 0.556\) | ||
| \(\bar u\) | \(x\) | \(.50\) | \(.10\) | \(0.2\) | ||
| \(\bar u\) | \(\bar x\) | \(.50\) | \(.90\) | \(1.8\) |
has row distances \(\ln 5 - \ln \tfrac{5}{9} = \ln 9\) and \(\ln 1.8 - \ln 0.2 = \ln 9\), whereas the maximum ratio \(5\) sits in row \(u\) and the minimum \(0.2\) in row \(\bar u\):
\begin{equation*} D(\Theta^0_{X|U},\Theta_{X|U}) = \ln 5 - \ln 0.2 = \ln 25 \;>\; \ln 9 . \end{equation*}
Exercises 16.8–16.14
Prove Inequalities 16.14, 16.15, and 16.16.
Recall the setting. Let \(\mathcal{N}^0\) and \(\mathcal{N}\) be two Bayesian networks over the same structure, where \(\mathcal{N}\) is obtained from \(\mathcal{N}^0\) by changing a single parameter value \(\theta^0_{x|u}\) to a new value \(\theta_{x|u}\) (co-varying parameters being adjusted by the proportional scheme of Definition 16.2), and let \(\mathrm{Pr}^0\) and \(\mathrm{Pr}\) be the distributions they induce. Write \(\delta_{x|u} = \theta_{x|u} - \theta^0_{x|u}\). Here \(e\) is an instantiation of variables \(\mathbf{E}\), and \(y\) and \(z\) are values of variables \(Y, Z \notin \mathbf{E}\). By Theorem 16.4 the probability of any event \(\alpha\) is a linear function of the new parameter value,
\begin{equation*} \mathrm{Pr}(\alpha) \;=\; \mu^{\alpha}_{x|u}\cdot\theta_{x|u} + \nu^{\alpha}_{x|u}, \end{equation*}
with \(\mu^{\alpha}_{x|u}\) and \(\nu^{\alpha}_{x|u}\) given by (16.5) and (16.6); equivalently \(\mathrm{Pr}(\alpha) = \mathrm{Pr}^0(\alpha) + \mu^{\alpha}_{x|u}\cdot\delta_{x|u}\). The three inequalities to be proven are:
- (16.14)
- To satisfy \(\mathrm{Pr}(y|e) \le \kappa\) we need a parameter change \(\delta_{x|u}\) such that
\begin{equation*} \mathrm{Pr}^0(y,e) - \kappa\cdot\mathrm{Pr}^0(e) \;\le\; \delta_{x|u}\left(-\mu^{y,e}_{x|u} + \kappa\cdot\mu^{e}_{x|u}\right). \end{equation*}
- (16.15)
- To satisfy \(\mathrm{Pr}(y|e) - \mathrm{Pr}(z|e) \ge \kappa\) we need a change \(\delta_{x|u}\) such that
\begin{equation*} \begin{aligned} &\mathrm{Pr}^0(y,e) - \mathrm{Pr}^0(z,e) - \kappa\cdot\mathrm{Pr}^0(e) \\ &\qquad \ge\; \delta_{x|u}\left(-\mu^{y,e}_{x|u} + \mu^{z,e}_{x|u} + \kappa\cdot\mu^{e}_{x|u}\right). \end{aligned} \end{equation*}
- (16.16)
- To satisfy \(\mathrm{Pr}(y|e)/\mathrm{Pr}(z|e) \ge \kappa\) we need a change \(\delta_{x|u}\) such that
\begin{equation*} \mathrm{Pr}^0(y,e) - \kappa\cdot\mathrm{Pr}^0(z,e) \;\ge\; \delta_{x|u}\left(-\mu^{y,e}_{x|u} + \kappa\cdot\mu^{z,e}_{x|u}\right). \end{equation*}
Clear the denominator, substitute Theorem 16.4, and collect the \(\delta_{x|u}\) terms. Assume \(\mathrm{Pr}(e) > 0\). Linearity of \(\mathrm{Pr}(\alpha) = \mu^{\alpha}_{x|u}\theta_{x|u} + \nu^{\alpha}_{x|u}\) in \(\theta_{x|u}\) kills \(\nu^{\alpha}_{x|u}\) on evaluating at \(\theta^0_{x|u}\) and subtracting, leaving for each \(\alpha \in \{y\wedge e, z\wedge e, e\}\),
\begin{equation*} \mathrm{Pr}(\alpha) = \mathrm{Pr}^0(\alpha)
- \mu^{\alpha}_{x|u}\cdot\delta_{x|u}. \end{equation*}
- (16.14)
- multiplying by \(\mathrm{Pr}(e) > 0\) preserves direction, so \(\mathrm{Pr}(y|e) \le \kappa\) iff \(\mathrm{Pr}(y,e) \le \kappa\,\mathrm{Pr}(e)\), that is
\begin{equation*} \mathrm{Pr}^0(y,e) + \mu^{y,e}_{x|u}\delta_{x|u} \;\le\; \kappa\left(\mathrm{Pr}^0(e) + \mu^{e}_{x|u}\delta_{x|u}\right); \end{equation*}
moving \(\kappa\,\mathrm{Pr}^0(e)\) left and \(\mu^{y,e}_{x|u}\delta_{x|u}\) right, then factoring \(\delta_{x|u}\), gives 16.14 (every step an equivalence, so the condition is necessary too).
- (16.15)
- likewise \(\mathrm{Pr}(y|e) - \mathrm{Pr}(z|e) \ge \kappa\) iff \(\mathrm{Pr}(y,e) - \mathrm{Pr}(z,e) \ge \kappa\,\mathrm{Pr}(e)\); substituting all three expansions and separating the \(\mathrm{Pr}^0\) terms from the \(\delta_{x|u}\) terms gives 16.15.
- (16.16)
- here \(\mathrm{Pr}(e)\) cancels on its own, so with \(\mathrm{Pr}(z,e) > 0\) the constraint \(\mathrm{Pr}(y|e)/\mathrm{Pr}(z|e) \ge \kappa\) is \(\mathrm{Pr}(y,e) \ge \kappa\,\mathrm{Pr}(z,e)\); substituting the two expansions and rearranging gives 16.16.
Consider the solution space characterized by Inequality 16.17. Call a solution optimal if it minimizes the CD distance between the original and new networks. Show that optimal solutions must satisfy the equality constraint corresponding to Inequality 16.17.
For reference, Inequality 16.17 is the multiple-parameter analogue of Corollary 9. Let \(\mathcal{N}^0\) and \(\mathcal{N}\) be two Bayesian networks, where \(\mathcal{N}\) is obtained from \(\mathcal{N}^0\) by changing one parameter value \(\theta^0_{x|u}\) for each parent instantiation \(u\) in the CPT of variable \(X\) (co-varying parameters being adjusted by the proportional scheme of Definition 16.2), and let \(\mathrm{Pr}^0\) and \(\mathrm{Pr}\) be the distributions they induce. To ensure that \(\mathrm{Pr}(y|e) \ge \kappa\) holds, the amounts of parameter change \(\delta_{x|u} = \theta_{x|u} - \theta^0_{x|u}\) must satisfy
\begin{equation*} \mathrm{Pr}^0(y,e) - \kappa\cdot\mathrm{Pr}^0(e) \;\ge\; \sum_{u}\delta_{x|u} \left(-\mu^{y,e}_{x|u} + \kappa\cdot\mu^{e}_{x|u}\right), \end{equation*}
where \(\mu^{y,e}_{x|u}\) and \(\mu^{e}_{x|u}\) are given by (16.5).
An optimal solution must be tight: scaling a slack solution toward the origin keeps it admissible while strictly decreasing its CD distance. Abbreviate \(K = \mathrm{Pr}^0(y,e) - \kappa\,\mathrm{Pr}^0(e)\), \(c_u = -\mu^{y,e}_{x|u} + \kappa\,\mu^{e}_{x|u}\) and \(g(\delta) = \sum_u c_u\,\delta_{x|u}\), so that Inequality 16.17 reads \(g(\delta) \le K\) and, by Corollary 10, cuts out exactly the changes enforcing \(\mathrm{Pr}(y|e) \ge \kappa\). Query control means \(K = \mathrm{Pr}^0(e)(\mathrm{Pr}^0(y|e) - \kappa) < 0\), else \(\delta = 0\) already solves it at distance \(0\).
Only the CPT of \(X\) differs, so the chain rule cancels every other family and \(\mathrm{Pr}(z)/\mathrm{Pr}^0(z) = \theta_{x_z|u_z}/\theta^0_{x_z|u_z}\), giving as in Theorem 16.2
\begin{equation*} D(\mathrm{Pr}^0,\mathrm{Pr}) \;=\; \ln\max_{x^{\prime},u}\frac{\theta_{x^{\prime}|u}}{\theta^0_{x^{\prime}|u}} \;-\; \ln\min_{x^{\prime},u}\frac{\theta_{x^{\prime}|u}}{\theta^0_{x^{\prime}|u}}, \end{equation*}
the extrema over parameters with \(\mathrm{Pr}^0(x^{\prime},u) > 0\); a \(\delta\) lifting a zero parameter at some \(u\) with \(\mathrm{Pr}^0(u) > 0\) has \(D = \infty\), so the candidate optimum has finite distance.
For \(t \in [0,1]\) put \(\delta(t) = t\delta\). Then \(\theta^0_{x|u} + t\delta_{x|u}\) is the convex combination \((1-t)\theta^0_{x|u} + t\theta_{x|u}\), and by Definition 16.2 so is each co-varying \(\theta^0_{x^{\star}|u}(1-\theta^0_{x|u}-t\delta_{x|u})/(1-\theta^0_{x|u})\) (in the exceptional case \(\theta^0_{x|u} = 1\), Definition 16.2 gives \(-t\delta_{x|u}/(|X|-1) \ge 0\) since \(\delta_{x|u} \le 0\) there), so \(\delta(t)\) is admissible. The ratios
\begin{equation*} \begin{aligned} \frac{\theta_{x|u}(t)}{\theta^0_{x|u}} &= 1 + t\,\frac{\delta_{x|u}}{\theta^0_{x|u}},\\ \frac{\theta_{x^{\star}|u}(t)}{\theta^0_{x^{\star}|u}} &= 1 - t\,\frac{\delta_{x|u}}{1-\theta^0_{x|u}} \end{aligned} \end{equation*}
are affine in \(t\) through \((0,1)\), so for \(t \ge 0\) the extremes are carried by the extreme slopes and \(D(t) = \ln(1+t\,s_{\max}) - \ln(1+t\,s_{\min})\) with \(s_{\max} \ge 0 \ge s_{\min}\), hence nondecreasing. It is strictly increasing when \(\delta \ne 0\) at finite \(D(\delta)\): at a \(u\) with \(\delta_{x|u} \ne 0\) and \(\mathrm{Pr}^0(u) > 0\), finiteness forces \(0 < \theta^0_{x|u} < 1\) (at \(1\) all co-varying parameters start at \(0\) and any decrease of \(\theta_{x|u}\) lifts one), while some co-varying \(\theta^0_{x^{\star}|u} > 0\) as they sum to \(1-\theta^0_{x|u} > 0\), so the two displayed slopes are nonzero of opposite sign and \(s_{\max} > 0 > s_{\min}\).
Now let \(\delta^{\star}\) satisfy \(g(\delta^{\star}) < K < 0\), so \(\delta^{\star} \ne 0\), and put \(t^{\star} = K/g(\delta^{\star}) \in (0,1)\) (both terms negative with \(|K| < |g(\delta^{\star})|\)). Linearity gives \(g(t^{\star}\delta^{\star}) = K\), so \(t^{\star}\delta^{\star}\) is admissible, realizes \(\mathrm{Pr}(y|e) = \kappa\), and has strictly smaller distance. Hence every optimal \(\delta\) satisfies \(g(\delta) = K\).
Suppose that \(\mathrm{Pr}\) is a distribution obtained from \(\mathrm{Pr}^0\) by incorporating soft evidence on events \((\beta_1,\ldots,\beta_n)\) using Jeffrey’s rule (see Chapter 3). Show that
\begin{equation*} D(\mathrm{Pr}^0,\mathrm{Pr}) \;=\; \ln\max_{i=1}^{n}\frac{\mathrm{Pr}(\beta_i)}{\mathrm{Pr}^0(\beta_i)} \;-\; \ln\min_{i=1}^{n}\frac{\mathrm{Pr}(\beta_i)}{\mathrm{Pr}^0(\beta_i)} . \end{equation*}
Here \(\beta_1,\ldots,\beta_n\) are mutually exclusive and exhaustive events and Jeffrey’s rule (3.22) defines the new state of belief by \(\mathrm{Pr}(\alpha) = \sum_{i=1}^{n} q_i\,\mathrm{Pr}^0(\alpha|\beta_i)\), where \(q_1,\ldots,q_n\) are the new beliefs in the events \(\beta_1,\ldots,\beta_n\).
The likelihood ratio is constant on each \(\beta_i\), with value \(k_i = \mathrm{Pr}(\beta_i)/\mathrm{Pr}^0(\beta_i)\), and these are the only ratios Definition 16.1 sees. Assume \(\mathrm{Pr}^0(\beta_i) > 0\), as (3.22) requires.
First \(q_i = \mathrm{Pr}(\beta_i)\): apply (3.22) with \(\alpha = \beta_i\) and use mutual exclusiveness, \(\mathrm{Pr}^0(\beta_i|\beta_j) = 0\) for \(j \ne i\) and \(\mathrm{Pr}^0(\beta_i|\beta_i) = 1\). Next, each world \(x\) satisfies exactly one \(\beta_i\), so in (3.22) with \(\alpha = x\) only the \(j = i\) term survives and
\begin{equation*} \mathrm{Pr}(x) \;=\; q_i\,\frac{\mathrm{Pr}^0(x)}{\mathrm{Pr}^0(\beta_i)} \;=\; \mathrm{Pr}^0(x)\cdot k_i . \end{equation*}
So the ratios of Definition 16.1 are exactly the \(k_i\), each realized since \(\mathrm{Pr}^0(\beta_i) > 0\) puts a world of positive prior probability inside \(\beta_i\), plus the value \(0/0 = 1\) from worlds with \(\mathrm{Pr}^0(x) = 0\) (hence \(\mathrm{Pr}(x) = 0\)). That stray \(1\) moves neither extremum, the partition giving
\begin{equation*} \sum_{i=1}^{n}\mathrm{Pr}^0(\beta_i)\,k_i \;=\; \sum_{i=1}^{n}\mathrm{Pr}(\beta_i) \;=\; 1 , \end{equation*}
exhibiting \(1\) as a convex combination of the \(k_i\), so \(\min_i k_i \le 1 \le \max_i k_i\). Hence \(\max_{x}\mathrm{Pr}(x)/\mathrm{Pr}^0(x) = \max_i k_i\) and \(\min_{x}\mathrm{Pr}(x)/\mathrm{Pr}^0(x) = \min_i k_i\), which is the claimed formula.
Consider a simplified version of the pregnancy network in Figure 16.1 where we can only administer the scanning test to detect pregnancy. That is, the network has two nodes, \(P\) (Pregnant?, with values yes and no) and \(S\) (Scanning Test, with values \(+ve\) and \(-ve\)), and the single edge \(P \to S\). Its CPTs, taken from Figure 16.1, are
| \(P\) | \(\theta_P\) |
|---|---|
| yes | .87 |
| no | .13 |
| \(P\) | \(S\) | \(\theta^0_{S \mid P}\) |
|---|---|---|
| yes | \(+ve\) | .90 |
| yes | \(-ve\) | .10 |
| no | \(+ve\) | .01 |
| no | \(-ve\) | .99 |
so the false-negative rate of the scanning test is \(\theta^0_{-ve|yes} = .10\) and its false-positive rate is \(\theta^0_{+ve|no} = .01\). The current probability of pregnancy given a positive scanning test is \(\mathrm{Pr}^0(yes\,|\,{+ve}) = .9983\) and the current probability of no pregnancy given a negative scanning test is \(\mathrm{Pr}^0(no\,|\,{-ve}) = .5967\). We wish to apply changes in both the false-positive and false-negative rates of the scanning test by amounts of \(\delta_1\) and \(\delta_2\), respectively, such that the corresponding probabilities are at least \(.999\) and \(.7\) (instead of \(.9983\) and \(.5967\), respectively). Plot the solution spaces of \(\delta_1\) and \(\delta_2\) such that they satisfy the two constraints, and find the unique solution such that the minimum confidence levels are exactly realized by the parameter changes.
The unique exact solution is \(\delta_1 = -1129/302900 = -.0037273\) and \(\delta_2 = -2457/67570 = -.0363623\), the vertex where the two constraint lines meet. Both changed parameters, \(\theta_{+ve|no} = .01 + \delta_1\) and \(\theta_{-ve|yes} = .10 + \delta_2\), sit in one CPT at different parent instantiations, so Theorem 16.5 and Corollary 10 apply, and \(S\) being binary forces the co-varying \(\theta_{-ve|no} = .99 - \delta_1\), \(\theta_{+ve|yes} = .90 - \delta_2\):
\begin{equation*} \begin{aligned} \mathrm{Pr}(yes,+ve) &= .783 - .87\,\delta_2, &\quad \mathrm{Pr}(no,+ve) &= .0013 + .13\,\delta_1,\\ \mathrm{Pr}(no,-ve) &= .1287 - .13\,\delta_1, &\quad \mathrm{Pr}(yes,-ve) &= .087 + .87\,\delta_2 , \end{aligned} \end{equation*}
which at \(\delta_1 = \delta_2 = 0\) return the quoted \(\mathrm{Pr}^0(yes|{+ve}) = .99834\) and \(\mathrm{Pr}^0(no|{-ve}) = .59666\) (Check!). Clearing the positive denominators turns \(\mathrm{Pr}(yes|{+ve}) \ge .999\) into \(.001\,\mathrm{Pr}(yes,+ve) \ge .999\,\mathrm{Pr}(no,+ve)\) and \(\mathrm{Pr}(no|{-ve}) \ge .7\) into \(.3\,\mathrm{Pr}(no,-ve) \ge .7\,\mathrm{Pr}(yes,-ve)\), that is
\begin{equation*} \begin{aligned} \text{(C1)}&\qquad .12987\,\delta_1 + .00087\,\delta_2 \;\le\; -.0005157,\\ \text{(C2)}&\qquad .039\,\delta_1 + .609\,\delta_2 \;\le\; -.02229 , \end{aligned} \end{equation*}
which are Inequality 16.17 of Corollary 10 with the sides exchanged. Plotting \(\delta_1\) horizontally, (C1) is the near-vertical line of slope \(-149.3\) through \((-.003971,0)\) and \((0,-.592759)\), admissible to its left, and (C2) the near-horizontal line of slope \(-.0640\) through \((-.571538,0)\) and \((0,-.036601)\), admissible below; keeping the rates in \([0,1]\) adds \(\delta_1 \ge -.01\) and \(\delta_2 \ge -.10\), so the solution space is the quadrilateral with corners
\begin{equation*} \begin{aligned} &(-.010000,\,-.100000), \quad (-.010000,\,-.035961),\\ &(-.003727,\,-.036362), \quad (-.003301,\,-.100000). \end{aligned} \end{equation*}
Its vertex \((-.0037273, -.0363623)\), where (C1) and (C2) hold with equality, is the point asked for; there \(\theta_{+ve|no} = 19/3029 = .0062727\) and \(\theta_{-ve|yes} = 430/6757 = .0636377\), so the false-positive rate falls from \(1\%\) to \(0.63\%\) and the false-negative rate from \(10\%\) to \(6.36\%\), and
\begin{equation*} \begin{aligned} \mathrm{Pr}(yes|{+ve}) &= \frac{.87 \times .9363623}{.87 \times .9363623 + .13 \times .0062727} = .999,\\[2pt] \mathrm{Pr}(no|{-ve}) &= \frac{.13 \times .9937273}{.13 \times .9937273 + .87 \times .0636377} = .700 . \end{aligned} \end{equation*}
Consider a simplified version of the fire network in Figure 16.3 where we are only interested in the variables Fire, Tampering, and Alarm. That is, the network consists of two root nodes \(F\) (Fire) and \(T\) (Tampering), both of which are parents of the node \(A\) (Alarm); all three variables are binary. Its CPTs, taken from Figure 16.3, are
| \(F\) | \(\theta_F\) |
|---|---|
| true | .01 |
| false | .99 |
| \(T\) | \(\theta_T\) |
|---|---|
| true | .02 |
| false | .98 |
| \(F\) | \(T\) | \(A\) | \(\theta^0_{A \mid F,T}\) |
|---|---|---|---|
| true | true | true | .50 |
| true | false | true | .99 |
| false | true | true | .85 |
| false | false | true | .0001 |
(redundant CPT rows, for \(A\) false, are omitted). Compute the sensitivity function for query \(\mathrm{Pr}(F|A)\) in terms of parameter \(\theta_{A|F,T}\), then again for the same query in terms of parameter \(\theta_{A|\neg F,\neg T}\), and plot the functions. From the plots, what would the effects on the query value be if we apply a small absolute change in each of the two parameters? Also, compute the sensitivity functions for the query \(\mathrm{Pr}(A|F)\) in terms of these two parameters. What is the difference between these two sensitivity functions and the previous two?
By Theorem 16.4 each of \(\mathrm{Pr}(F,A)\), \(\mathrm{Pr}(A)\), \(\mathrm{Pr}(A,F)\) and \(\mathrm{Pr}(F)\) is a linear function of the parameter being varied, so each sensitivity function is a ratio of two linear functions,
\begin{equation*} \mathrm{Pr}(\alpha|\beta) = \frac{\mu^{\alpha,\beta}_{x|u}\,\theta_{x|u} + \nu^{\alpha,\beta}_{x|u}} {\mu^{\beta}_{x|u}\,\theta_{x|u} + \nu^{\beta}_{x|u}} . \end{equation*}
The coefficients come out directly, the network being small enough to eliminate by hand. Because \(F\) and \(T\) are independent roots,
\begin{equation*} \mathrm{Pr}(f,t) = .0002,\quad \mathrm{Pr}(f,\bar t) = .0098,\quad \mathrm{Pr}(\bar f,t) = .0198,\quad \mathrm{Pr}(\bar f,\bar t) = .9702 . \end{equation*}
(1) Write \(\theta = \theta_{A|F,T}\), current value \(.50\). Summing out \(T\),
\begin{equation*} \begin{aligned} \mathrm{Pr}(F,A) &= .0002\,\theta + .0098 \times .99 = .0002\,\theta + .009702,\\ \mathrm{Pr}(\neg F, A) &= .0198 \times .85 + .9702 \times .0001 = .01683 + .00009702 = .01692702, \end{aligned} \end{equation*}
the second free of \(\theta\), so \(\mathrm{Pr}(A) = .0002\,\theta + .02662902\) and
\begin{equation*} \mathrm{Pr}(F|A) \;=\; \frac{.0002\,\theta + .009702} {.0002\,\theta + .02662902} . \end{equation*}
Some values of this function:
| \(\theta_{A \mid F,T}\) | \(\mathrm{Pr}(F \mid A)\) |
|---|---|
| .00 | .364339 |
| .25 | .365531 |
| .50 | .366718 |
| .75 | .367900 |
| 1.00 | .369078 |
Over \([0,1]\) the plot is a rise so gentle as to be indistinguishable from a horizontal line at height \(\approx .367\), total variation \(.369078 - .364339 = .004739\), with derivative at the current value
\begin{equation*} \left.\frac{d}{d\theta}\,\mathrm{Pr}(F|A)\right|_{\theta = .5} = \frac{.0002\,(.02662902 - .009702)}{(.5 \times .0002 + .02662902)^2} = .00474 . \end{equation*}
(2) Write \(\theta^{\prime} = \theta_{A|\neg F,\neg T}\), current value \(.0001\). Now
\begin{equation*} \begin{aligned} \mathrm{Pr}(F,A) &= .0002 \times .5 + .0098 \times .99 = .009802,\\ \mathrm{Pr}(\neg F, A) &= .0198 \times .85 + .9702\,\theta^{\prime} = .01683 + .9702\,\theta^{\prime}, \end{aligned} \end{equation*}
so \(\mathrm{Pr}(F,A)\) is constant in \(\theta^{\prime}\), \(\mathrm{Pr}(A) = .026632 + .9702\,\theta^{\prime}\) and
\begin{equation*} \mathrm{Pr}(F|A) \;=\; \frac{.009802}{.026632 + .9702\,\theta^{\prime}} . \end{equation*}
Some values:
| \(\theta_{A \mid \neg F,\neg T}\) | \(\mathrm{Pr}(F \mid A)\) |
|---|---|
| .0000 | .368053 |
| .0001 | .366718 |
| .0010 | .355117 |
| .0100 | .269775 |
| .1000 | .079271 |
| 1.0000 | .009833 |
Over \([0,1]\) this is a steeply decaying hyperbola, down a quarter of its height by \(\theta^{\prime} = .01\), to \(.0444\) at \(\theta^{\prime} = .2\), then flat near zero; over the narrow range \([0,.02]\), as in the two-panel style of Figure 16.4, it plunges convexly from \(.368\) through \(.270\) at \(\theta^{\prime} = .01\) to \(.213\). Its derivative at the current value is
\begin{equation*} \left.\frac{d}{d\theta^{\prime}}\,\mathrm{Pr}(F|A)\right|_{\theta^{\prime} = .0001} = \frac{-.009802 \times .9702}{(.026632 + .9702 \times .0001)^2} = -13.31 . \end{equation*}
Effect of a small absolute change. A change of \(+.01\) in \(\theta_{A|F,T}\) moves the query from \(.366718\) to \(.366765\), about \(5 \times 10^{-5}\), and no change at all to it, even to \(0\) or \(1\), can leave \([.3643,.3691]\); the same \(+.01\) in \(\theta_{A|\neg F,\neg T}\) moves the query from \(.366718\) to \(.269056\), a drop of \(.098\), some two thousand times larger. The coefficients say why: \(\theta_{A|F,T}\) is multiplied by the tiny prior mass \(\mathrm{Pr}(f,t) = .0002\), \(\theta_{A|\neg F,\neg T}\) by the dominant \(\mathrm{Pr}(\bar f,\bar t) = .9702\).
(3) and (4) For \(\mathrm{Pr}(A|F)\): since \(F\) and \(T\) are roots and \(A\) a leaf, \(\mathrm{Pr}(F) = .01\) regardless of the CPT of \(A\), and summing out \(T\),
\begin{equation*} \mathrm{Pr}(A|F) = .02\,\theta_{A|F,T} + .98 \times .99 = .02\,\theta_{A|F,T} + .9702, \end{equation*}
a line of slope \(.02\), value \(.9802\) at the current parameter and range \([.9702, .9902]\) over \(\theta_{A|F,T} \in [0,1]\). The other parameter \(\theta_{A|\neg F,\neg T}\) appears only in instantiations containing \(\neg F\), so in neither \(\mathrm{Pr}(A,F)\) nor \(\mathrm{Pr}(F)\), and
\begin{equation*} \mathrm{Pr}(A|F) = .9802, \end{equation*}
a constant, plotted as a horizontal line.
The difference: the first two functions are genuine ratios of linear functions, hence hyperbolas, because the parameter enters both the numerator \(\mathrm{Pr}(F,A)\) and the denominator \(\mathrm{Pr}(A)\), so \(\mu^{\beta}_{x|u} \ne 0\) with \(\beta = A\). The last two are linear, one constant, because for \(\mathrm{Pr}(A|F)\) the conditioning event is \(\beta = F\) and \(\mathrm{Pr}(F) = .01\) is free of every parameter in the CPT of \(A\), so \(\mu^{F}_{x|u} = 0\) and \((\mu^{\alpha,\beta}\theta + \nu^{\alpha,\beta})/(\mu^{\beta}\theta + \nu^{\beta})\) degenerates to a linear function: evidence on an ancestor of the changed family leaves the denominator alone, evidence on a descendant does not.
Assume that instead of using the proportional scheme of Definition 16.2, we distribute the parameter change equally among co-varying parameters. In this case, what is the new value of \(\theta_{x^{\star}|u}\)? What problem may this scheme face when distributing the parameter change?
Recall Definition 16.2. Let \(\Theta^0_{X|\mathbf{U}}\) be an initial CPT for variable \(X\) and suppose we want to change a single parameter value \(\theta^0_{x|u}\) to the new value \(\theta_{x|u}\). The proportional scheme changes the co-varying parameters, for all \(x^{\star} \ne x\), by
\begin{equation*} \theta_{x^{\star}|u} = \rho(x,x^{\star},u)\,(1 - \theta_{x|u}), \qquad \rho(x,x^{\star},u) = \begin{cases} \dfrac{\theta^0_{x^{\star}|u}}{1-\theta^0_{x|u}} & \text{if } \theta^0_{x|u} \ne 1,\\[6pt] \dfrac{1}{|X|-1} & \text{if } \theta^0_{x|u} = 1, \end{cases} \end{equation*}
where \(|X|\) is the number of values of \(X\).
The equal scheme sets, for every \(x^{\star} \ne x\) and \(\delta_{x|u} = \theta_{x|u} - \theta^0_{x|u}\),
\begin{equation*} \theta_{x^{\star}|u} \;=\; \theta^0_{x^{\star}|u} - \frac{\delta_{x|u}}{|X|-1} \;=\; \theta^0_{x^{\star}|u} - \frac{\theta_{x|u} - \theta^0_{x|u}}{|X|-1}, \end{equation*}
splitting the \(-\delta_{x|u}\) that normalization \(\sum_{x^{\prime}}\theta_{x^{\prime}|u} = 1\) forces onto the \(|X|-1\) co-varying parameters into equal shares; these sum to \(1 - \theta_{x|u}\) (Check!). It is a common additive shift where Definition 16.2 applies the common multiplicative rescaling \(\theta_{x^{\star}|u} = \theta^0_{x^{\star}|u}(1-\theta_{x|u})/(1-\theta^0_{x|u})\), so the two agree for binary \(X\) and differ only when \(|X| \ge 3\).
The problem is that the equal scheme can leave the probability simplex: the subtracted amount is the same for every co-varying parameter while the parameters themselves may differ wildly in size, so a small one can be driven negative. Precisely, an increase (\(\delta_{x|u} > 0\)) yields a legitimate CPT if and only if
\begin{equation*} \delta_{x|u} \;\le\; (|X|-1)\cdot\min_{x^{\star} \ne x}\theta^0_{x^{\star}|u}, \end{equation*}
so a co-varying parameter of initial value \(0\) blocks every increase. Decreases are safe, since \(\delta_{x|u} < 0\) gives \(|\delta_{x|u}| \le \theta^0_{x|u}\) and hence \(\theta_{x^{\star}|u} \le \theta^0_{x^{\star}|u} + \theta^0_{x|u} \le 1\). Concretely, for the CPT column used in the text,
| \(\theta^0_{x_1 \mid u}\) | \(\theta^0_{x_2 \mid u}\) | \(\theta^0_{x_3 \mid u}\) |
|---|---|---|
| .6 | .3 | .1 |
raising \(\theta_{x_1|u}\) from \(.6\) to \(.9\) makes each of the two co-varying parameters give up \(.15\), and the equal scheme yields
| \(\theta_{x_1 \mid u}\) | \(\theta_{x_2 \mid u}\) | \(\theta_{x_3 \mid u}\) |
|---|---|---|
| .9 | .15 | \(-.05\) |
not a probability distribution, whereas the proportional scheme multiplies each co-varying parameter by \((1-.9)/(1-.6) = .25\), giving the legitimate \(.075\) and \(.025\), and can never fail, multiplying nonnegative numbers by a nonnegative factor. Two lesser defects: the equal scheme destroys the ratios \(\theta_{x_3|u}/\theta_{x_2|u} = \theta^0_{x_3|u}/\theta^0_{x_2|u}\) that the proportional scheme preserves, and it lifts a zero co-varying parameter whenever \(\theta_{x|u}\) decreases, which at \(\mathrm{Pr}^0(u) > 0\) changes the support and so sends \(D(\mathrm{Pr}^0,\mathrm{Pr})\) to \(\infty\) by Exercise 16.1, voiding the bounds of Theorem 16.1.
Prove that the proportional scheme of Definition 16.2 is the optimal scheme of distributing parameter changes among co-varying parameters in the sense that it minimizes the CD distance \(D(\mathrm{Pr}^0,\mathrm{Pr})\) among all possible schemes.
Here a scheme is any rule that, given an initial CPT \(\Theta^0_{X|\mathbf{U}}\), a parent instantiation \(u\), and the new value \(\theta_{x|u}\) of a single changed parameter \(\theta^0_{x|u}\), assigns new values \(\theta_{x^{\star}|u} \ge 0\) to the co-varying parameters (\(x^{\star} \ne x\)) so that \(\sum_{x^{\star} \ne x}\theta_{x^{\star}|u} = 1 - \theta_{x|u}\). All other CPTs, and all other columns of the CPT of \(X\), are left unchanged.
Every scheme’s co-varying ratios must average to the scheme-independent value \(s = (1-\theta_{x|u})/(1-\theta^0_{x|u})\), so none can beat the proportional scheme, which puts every ratio at \(s\). Only the column \(\Theta_{X|u}\) is touched, so if \(\mathrm{Pr}^0(u) = 0\) then \(D(\mathrm{Pr}^0,\mathrm{Pr}) = 0\) for every scheme; and if \(\mathrm{Pr}^0(u) > 0\), Theorem 16.2 and (16.3) give
\begin{equation*} D(\mathrm{Pr}^0,\mathrm{Pr}) \;=\; \ln\max_{x^{\prime}}\frac{\theta_{x^{\prime}|u}}{\theta^0_{x^{\prime}|u}} \;-\; \ln\min_{x^{\prime}}\frac{\theta_{x^{\prime}|u}}{\theta^0_{x^{\prime}|u}}, \end{equation*}
the extrema over all values \(x^{\prime}\) of \(X\), with \(0/0 = 1\) and \(c/0 = \infty\) for \(c > 0\); the scheme enters only through these \(|X|\) ratios. The degenerate cases tie, the proportional scheme attaining the common minimum:
- (i) \(\theta^0_{x|u} = 0 < \theta_{x|u}\)
- the ratio at \(x\) is already \(\infty\), so \(D = \infty\) whatever the scheme does.
- (ii) \(\theta^0_{x|u} = \theta_{x|u} = 0\)
- nothing is asked of the co-varying parameters beyond their original sum, and Definition 16.2 leaves each alone, giving \(D = 0\).
- (iii) \(\theta_{x|u} = 1\)
- every scheme must zero all co-varying parameters, so there is only one scheme.
- (iv) \(\theta^0_{x|u} = 1 > \theta_{x|u}\)
- all co-varying parameters start at \(0\) and some must be raised, so \(D = \infty\) for every scheme.
So assume \(0 < \theta^0_{x|u} < 1\) and \(0 \le \theta_{x|u} < 1\), and put
\begin{equation*} r \;=\; \frac{\theta_{x|u}}{\theta^0_{x|u}}, \qquad s \;=\; \frac{1-\theta_{x|u}}{1-\theta^0_{x|u}} \;>\; 0 . \end{equation*}
Neither depends on the scheme, \(\theta_{x|u}\) being given and the co-varying parameters summing to \(1-\theta_{x|u}\) under any scheme, and \(\theta^0_{x|u} r + (1-\theta^0_{x|u}) s = \theta_{x|u} + (1-\theta_{x|u}) = 1\) exhibits \(1\) as a convex combination of \(r\) and \(s\), giving the sandwich \(\min(r,s) \le 1 \le \max(r,s)\).
Definition 16.2 sets \(\theta^{P}_{x^{\star}|u} = \theta^0_{x^{\star}|u}\cdot s\), so every co-varying parameter with \(\theta^0_{x^{\star}|u} > 0\) has ratio exactly \(s\), while one with \(\theta^0_{x^{\star}|u} = 0\) stays at \(0\) and contributes \(0/0 = 1\), which by the sandwich moves neither extremum. Hence
\begin{equation*} D^{P} \;=\; \ln\max(r,s) - \ln\min(r,s) \;=\; \left|\ln r - \ln s\right| . \end{equation*}
Let an arbitrary scheme produce values \(\theta_{x^{\star}|u}\). If it makes some \(x^{\star}\) with \(\theta^0_{x^{\star}|u} = 0\) positive then \(D = \infty \ge D^{P}\); so assume it does not, and on \(S = \{x^{\star} \ne x : \theta^0_{x^{\star}|u} > 0\}\), nonempty as \(\sum_{x^{\star} \ne x}\theta^0_{x^{\star}|u} = 1 - \theta^0_{x|u} > 0\), put \(\rho_{x^{\star}} = \theta_{x^{\star}|u}/\theta^0_{x^{\star}|u}\). Normalization reads \(\sum_{x^{\star} \in S}\theta^0_{x^{\star}|u}\rho_{x^{\star}} = 1 - \theta_{x|u}\), so dividing by \(1-\theta^0_{x|u} = \sum_{x^{\star} \in S}\theta^0_{x^{\star}|u} > 0\),
\begin{equation*} s \;=\; \sum_{x^{\star} \in S} \frac{\theta^0_{x^{\star}|u}}{1-\theta^0_{x|u}}\;\rho_{x^{\star}}, \end{equation*}
a weighted average with nonnegative weights summing to \(1\), whence \(\min_{S}\rho_{x^{\star}} \le s \le \max_{S}\rho_{x^{\star}}\): no scheme can pull all its co-varying ratios strictly closer to \(1\) than \(s\) is. With \(M\) and \(m\) the maximum and minimum ratio over the whole column,
\begin{equation*} \begin{aligned} M &\ge \max\left(r,\ \max_{x^{\star} \in S}\rho_{x^{\star}}\right) \ge \max(r,s),\\ m &\le \min\left(r,\ \min_{x^{\star} \in S}\rho_{x^{\star}}\right) \le \min(r,s), \end{aligned} \end{equation*}
so that, \(\ln\) being increasing,
\begin{equation*} D(\mathrm{Pr}^0,\mathrm{Pr}) = \ln M - \ln m \;\ge\; \ln\max(r,s) - \ln\min(r,s) \;=\; D^{P} . \end{equation*}
The proportional scheme is itself a scheme and attains \(D^{P}\), so \(D^{P} = \min_{\text{schemes}} D(\mathrm{Pr}^0,\mathrm{Pr})\).
Exercises 16.15–16.17
Consider the network in Figure 16.3, reproduced here. It has six binary variables — Fire (\(F\)), Tampering (\(T\)), Smoke (\(S\)), Alarm (\(A\)), Leaving (\(L\)) and Report (\(R\)) — and the edges
\begin{equation*} F \to S, \quad F \to A, \quad T \to A, \quad A \to L, \quad L \to R . \end{equation*}
Its CPTs are (redundant rows omitted, so each row below states the probability of the value shown):
| \(F\) | \(\theta_F\) |
|---|---|
| true | .01 |
| \(T\) | \(\theta_T\) |
|---|---|
| true | .02 |
| \(F\) | \(S\) | \(\theta_{S\mid F}\) |
|---|---|---|
| true | true | .9 |
| false | true | .01 |
| \(F\) | \(T\) | \(A\) | \(\theta_{A\mid F,T}\) |
|---|---|---|---|
| true | true | true | .5 |
| true | false | true | .99 |
| false | true | true | .85 |
| false | false | true | .0001 |
| \(A\) | \(L\) | \(\theta_{L\mid A}\) |
|---|---|---|
| true | true | .88 |
| false | true | .001 |
| \(L\) | \(R\) | \(\theta_{R\mid L}\) |
|---|---|---|
| true | true | .75 |
| false | true | .01 |
The probability of having a fire given that the alarm has triggered is \(\Pr(f \mid a) = .3667\). We now wish to install a smoke detector that responds only to whether smoke is present, such that when both the alarm and the smoke detector trigger, the probability of fire is at least \(.8\). How can we use sensitivity analysis to find the required reliability of the smoke detector? Specify the three elements of the sensitivity analysis process: the Bayesian network that models this scenario, the query constraint you wish to satisfy, and the parameters you are allowed to change. Hint: You may recall how sensors are modeled as soft evidence in Chapter 3.
- (1) The network
- a smoke detector is the noisy sensor of Section 3.6.4, a binary variable whose only parent is the event it senses, here \(S\). Take \(N^0\) to be Figure 16.3 augmented by a node \(D\) and the edge \(S \to D\), all six original CPTs unchanged, with \(\Theta_{D \mid S}\) the sensor’s error profile
\begin{equation*} f_p \;=\; \Pr(d \mid \neg s) \;=\; \theta_{d \mid \neg s}, \qquad f_n \;=\; \Pr(\neg d \mid s) \;=\; 1 - \theta_{d \mid s} . \end{equation*}
Start it vacuous, \(\theta_{d\mid s} = \theta_{d \mid \neg s} = 1\): a detector that always triggers has Bayes factor \(1\), so \(\Pr^0(f \mid a, d) = \Pr^0(f \mid a) = .3667\) as quoted, and only \(\theta_{d \mid \neg s}\) is left free, so Corollary 9 applies verbatim.
- (2) The query constraint
- with evidence \(e = a, d\) and event \(y = f\), the type-(16.9) constraint \(\Pr(f \mid a, d) \ge \kappa\), \(\kappa = .8\).
- (3) The changeable parameters
- only the sensor CPT, \(\theta_{d \mid s} = 1 - f_n\) and \(\theta_{d\mid \neg s} = f_p\) — one is buying a detector, not re-engineering fires. Two parameters in one CPT is the multiple-parameter setting of Section 16.3.2; pinning \(\theta_{d \mid s} = 1\) reduces it to Section 16.3.1.
Since \(D\) is binary, the only co-varying parameter is \(\theta_{\neg d\mid\neg s}\) and \(\rho = 1\) in (16.5); both query events \(\alpha = f, a, d\) and \(\alpha = a, d\) mention \(d\), so \(\partial \Pr(\alpha)/\partial \theta_{\neg d\mid\neg s} = 0\), and \(\partial \Pr(\alpha)/\partial\theta_{d\mid\neg s} = \Pr^0(\alpha, d, \neg s)/\theta_{d\mid\neg s}\) at \(\theta_{d\mid\neg s} = 1\) makes the constants of (16.5)
\begin{equation*} \mu^{f,a,d}_{d\mid\neg s} = \Pr\nolimits^0(f, a, \neg s), \qquad \mu^{a,d}_{d\mid\neg s} = \Pr\nolimits^0(a, \neg s). \end{equation*}
Inference in Figure 16.3 gives
\begin{equation*} \begin{aligned} \Pr\nolimits^0(a) &= .026729, &\qquad \Pr\nolimits^0(f,a) &= .009802,\\ \Pr\nolimits^0(a,\neg s) &= .017738, &\qquad \Pr\nolimits^0(f,a,\neg s) &= .00098020 . \end{aligned} \end{equation*}
In \(N^0\) the detector always fires, so \(\Pr^0(f,a,d) = \Pr^0(f,a)\) and \(\Pr^0(a,d) = \Pr^0(a)\), with ratio \(.3667\) as claimed. Substituting into (16.13) with \(\kappa = .8\):
\begin{equation*} \begin{aligned} \Pr\nolimits^0(f,a,d) - \kappa \Pr\nolimits^0(a,d) &\;\ge\; \delta_{d\mid\neg s}\bigl(-\mu^{f,a,d}_{d\mid\neg s} + \kappa\,\mu^{a,d}_{d\mid\neg s}\bigr)\\ .009802 - .8(.026729) &\;\ge\; \delta_{d\mid\neg s}\bigl(-.00098020 + .8(.017738)\bigr)\\ -.0115812 &\;\ge\; \delta_{d\mid\neg s}\,(.0132102). \end{aligned} \end{equation*}
Hence \(\delta_{d\mid\neg s} \le -.87669\), and since the initial value is \(1\) the new value must satisfy
\begin{equation*} \theta_{d\mid\neg s} \;=\; f_p \;\le\; .12331 . \end{equation*}
So a detector that never misses smoke (\(f_n = 0\)) needs a false positive rate of at most \(12.3\%\).
Method (2): allow \(f_n\) to move too. The only path from \(D\) to \(A\) is \(D \leftarrow S \leftarrow F \rightarrow A\), with \(F\) divergent, so \(F\) d-separates \(D\) from \(A\) and \(S\) from \(A\); hence \(\Pr(s \mid f, a) = .9\), \(\Pr(s \mid \neg f, a) = .01\), and \(D\) enters the odds of \(F\) only through \(\Pr(d \mid f, a) = \Pr(d\mid f)\) and \(\Pr(d\mid \neg f, a) = \Pr(d\mid\neg f)\). With \(q = \Pr(f\mid a) = .3667\), sensor likelihoods \(\Pr(d\mid s) = 1-f_n\), \(\Pr(d \mid \neg s) = f_p\), and Bayes rule in odds form,
\begin{equation*} O(f \mid a, d) \;=\; O(f \mid a)\cdot \frac{\Pr(d\mid f, a)}{\Pr(d \mid \neg f, a)} \;=\; \frac{q}{1-q}\cdot\frac{.9(1-f_n) + .1 f_p}{.01(1-f_n) + .99 f_p}. \end{equation*}
Requiring \(\Pr(f\mid a,d) \ge .8\) is requiring \(O(f\mid a,d) \ge 4\); dividing through by \(f_p\) and writing \(k^{+} = (1-f_n)/f_p\) for the Bayes factor of a positive reading (Section 3.6.4), this is
\begin{equation*} \frac{q}{1-q}\cdot \frac{.9k^{+} + .1}{.01 k^{+} + .99} \;\ge\; 4 . \end{equation*}
With \(q/(1-q) = .57907\) this reads \((.9k^{+}+.1)/(.01k^{+}+.99) \ge 6.9076\), that is,
\begin{equation*} .83092\,k^{+} \;\ge\; 6.73850, \qquad\text{so}\qquad k^{+} \;\ge\; 8.1096 . \end{equation*}
The required reliability is thus a constraint on the ratio alone,
\begin{equation*} \frac{1-f_n}{f_p} \;\ge\; 8.1096, \qquad\text{equivalently}\qquad f_p \;\le\; \frac{1-f_n}{8.1096}, \end{equation*}
as Section 3.6.4 predicts. So \(f_n = 0\) requires \(f_p \le .1233\), matching the Corollary 9 computation; \(f_n = .05\) requires \(f_p \le .1171\); \(f_n = .10\) requires \(f_p \le .1110\).
Let \(N^0\) and \(N\) be Bayesian networks where network \(N\) is obtained from \(N^0\) by changing the CPTs of variables \(X\) and \(Y\) from \(\Theta^0_{X\mid U_X}\) to \(\Theta_{X\mid U_X}\) and from \(\Theta^0_{Y\mid U_Y}\) to \(\Theta_{Y\mid U_Y}\), respectively — that is, changing parameter value \(\theta^0_{x\mid u_X}\) to some new value \(\theta_{x\mid u_X}\) for every \(x\) and \(u_X\), and \(\theta^0_{y\mid u_Y}\) to some new value \(\theta_{y\mid u_Y}\) for every \(y\) and \(u_Y\). Let \(\Pr^0\) and \(\Pr\) be the distributions induced by networks \(N^0\) and \(N\), respectively, and also assume that \(\Pr^0(u_X) > 0\) and \(\Pr^0(u_Y) > 0\) for every \(u_X\) and \(u_Y\). Prove that if the two families \(X, U_X\) and \(Y, U_Y\) are disjoint, that is, they do not share any variables, then
\begin{equation*} D(\Pr\nolimits^0, \Pr) \;=\; D(\Theta^0_{X\mid U_X}, \Theta_{X\mid U_X}) \;+\; D(\Theta^0_{Y\mid U_Y}, \Theta_{Y\mid U_Y}). \end{equation*}
Also prove that if the two families are not disjoint, then the sum of the distances between the CPTs is an upper bound on \(D(\Pr^0, \Pr)\). Here the CD distance between two CPTs is the CD distance of Definition 16.1 applied entrywise, that is,
\begin{equation*} D(\Theta^0_{X\mid U_X}, \Theta_{X\mid U_X}) = \ln \max_{x, u_X} \frac{\theta_{x\mid u_X}}{\theta^0_{x\mid u_X}}
- \ln \min_{x, u_X} \frac{\theta_{x\mid u_X}}{\theta^0_{x\mid u_X}}, \end{equation*}
with the conventions \(0/0 = 1\) and \(\infty/\infty = 1\) of Definition 16.1.
Both claims follow from the pointwise bound \((\ast)\) below, which is an equality exactly when the extreme entries of the two CPTs are realizable in one instantiation. Let \(z\) range over complete instantiations of the network variables \(Z\), write \(x, u_X\) and \(y, u_Y\) for the values \(z\) assigns to the two families, and abbreviate
\begin{equation*} r_X(x, u_X) = \frac{\theta_{x\mid u_X}}{\theta^0_{x\mid u_X}}, \qquad r_Y(y, u_Y) = \frac{\theta_{y\mid u_Y}}{\theta^0_{y\mid u_Y}}, \end{equation*}
and put
\begin{equation*} \begin{aligned} M_X &= \max_{x,u_X} r_X(x,u_X), &\qquad m_X &= \min_{x,u_X} r_X(x,u_X),\\ M_Y &= \max_{y,u_Y} r_Y(y,u_Y), &\qquad m_Y &= \min_{y,u_Y} r_Y(y,u_Y), \end{aligned} \end{equation*}
so that \(D(\Theta^0_{X\mid U_X},\Theta_{X\mid U_X}) = \ln M_X - \ln m_X\) and likewise for \(Y\).
By the chain rule \(\Pr^0(z)\) and \(\Pr(z)\) are products of one parameter per network variable, differing only in the factors from \(X\) and \(Y\), so with \(c(z)\) the product of the parameters from all other variables (identical in both networks),
\begin{equation*} \begin{aligned} \Pr\nolimits^0(z) &= \theta^0_{x\mid u_X}\,\theta^0_{y\mid u_Y}\, c(z),\\ \Pr(z) &= \theta_{x\mid u_X}\,\theta_{y\mid u_Y}\, c(z). \end{aligned} \end{equation*}
valid disjoint or not, \(X\) and \(Y\) being distinct variables, so exactly one factor comes from each changed CPT.
Each CPT ratio straddles \(1\). Fix \(u_X\); since \(\sum_x \theta^0_{x\mid u_X} = \sum_x \theta_{x\mid u_X} = 1\), neither \(\theta_{x\mid u_X} > \theta^0_{x\mid u_X}\) for every \(x\) nor the reverse is possible, so some \(x\) has \(\theta_{x\mid u_X} \le \theta^0_{x\mid u_X}\) and some the reverse. The first gives \(r_X(x,u_X) \le 1\) (clear when \(\theta^0_{x\mid u_X} > 0\), and when \(\theta^0_{x\mid u_X} = 0\) it forces \(\theta_{x\mid u_X} = 0\) and \(r_X = 0/0 = 1\)), the second symmetrically an entry with \(r_X \ge 1\). Therefore
\begin{equation*} m_X \le 1 \le M_X, \qquad\text{and likewise}\qquad m_Y \le 1 \le M_Y . \end{equation*}
The upper bound, disjoint or not, rests on the claim that for every \(z\),
\begin{equation*} m_X\, m_Y \;\le\; \frac{\Pr(z)}{\Pr^0(z)} \;\le\; M_X\, M_Y . \tag{\(\ast\)} \end{equation*}
Four cases.
- (i) \(\Pr^0(z) > 0\)
- then \(c(z), \theta^0_{x\mid u_X}, \theta^0_{y\mid u_Y} > 0\), so \(c(z)\) cancels and \(\Pr(z)/\Pr^0(z) = r_X(x,u_X)\, r_Y(y,u_Y)\), a product of nonnegative ratios lying between \(m_X m_Y\) and \(M_X M_Y\).
- (ii) \(\Pr^0(z) = \Pr(z) = 0\)
- the ratio is \(0/0 = 1\), inside the interval by the straddle.
- (iii) \(\Pr^0(z) = 0 < \Pr(z)\)
- the ratio is \(\infty\); here \(c(z) > 0\) and \(\theta_{x\mid u_X}\theta_{y\mid u_Y} > 0 = \theta^0_{x\mid u_X}\theta^0_{y\mid u_Y}\), so one changed parameter has \(\theta > 0 = \theta^0\), entrywise ratio \(\infty\), and the other factor is \(\ge 1\), giving \(M_X M_Y = \infty\); the lower bound holds as \(m_X m_Y \le 1\).
- (iv) \(\Pr(z) = 0 < \Pr^0(z)\)
- the ratio is \(0\); symmetrically some changed parameter has \(\theta = 0 < \theta^0\), entrywise ratio \(0\), and the other minimum is \(\le 1\) and finite, giving \(m_X m_Y = 0\); the upper bound holds as \(M_X M_Y \ge 1\).
Taking extrema of \((\ast)\) over \(z\) and applying Definition 16.1,
\begin{equation*} \begin{aligned} D(\Pr\nolimits^0,\Pr) &= \ln \max_z \frac{\Pr(z)}{\Pr^0(z)} - \ln \min_z \frac{\Pr(z)}{\Pr^0(z)}\\ &\le \ln (M_X M_Y) - \ln (m_X m_Y)\\ &= (\ln M_X - \ln m_X) + (\ln M_Y - \ln m_Y)\\ &= D(\Theta^0_{X\mid U_X},\Theta_{X\mid U_X}) + D(\Theta^0_{Y\mid U_Y},\Theta_{Y\mid U_Y}), \end{aligned} \end{equation*}
the required upper bound; splitting the logarithms is legitimate since \(M_X, M_Y \ge 1\) and \(m_X, m_Y \le 1\) bar any \(\infty - \infty\).
For equality in the disjoint case it remains to attain the two extremes of \((\ast)\). Choose entries \((x^\star, u_X^\star)\) attaining \(M_X\) and \((y^\star, u_Y^\star)\) attaining \(M_Y\); disjointness of the families is exactly what makes \(x^\star, u_X^\star, y^\star, u_Y^\star\) a consistent instantiation. Under the nondegeneracy hypothesis
\begin{equation*} \Pr\nolimits^0(x, u_X, y, u_Y) > 0 \quad\text{for every instantiation of } X, U_X, Y, U_Y, \tag{\(\dagger\)} \end{equation*}
some complete \(z^\star\) extends \(x^\star, u_X^\star, y^\star, u_Y^\star\) with \(\Pr^0(z^\star) > 0\), and case (i) gives
\begin{equation*} \frac{\Pr(z^\star)}{\Pr^0(z^\star)} = r_X(x^\star,u_X^\star)\, r_Y(y^\star,u_Y^\star) = M_X M_Y . \end{equation*}
The minimizing entries likewise produce a \(z_\star\) with ratio \(m_X m_Y\), so the extrema over \(z\) are \(M_X M_Y\) and \(m_X m_Y\) and the displayed chain becomes a chain of equalities:
\begin{equation*} D(\Pr\nolimits^0,\Pr) = D(\Theta^0_{X\mid U_X},\Theta_{X\mid U_X}) + D(\Theta^0_{Y\mid U_Y},\Theta_{Y\mid U_Y}). \end{equation*}
The printed hypotheses \(\Pr^0(u_X) > 0\) and \(\Pr^0(u_Y) > 0\) do not suffice for this last step (nor does the joint reading \(\Pr^0(u_X,u_Y) > 0\)), so we prove the equality under \((\dagger)\), which holds whenever \(N^0\) is strictly positive and is the two-family analogue of the \(\Pr^0(u) > 0\) of Theorem 16.2.
Let \(N^0\) and \(N\) be Bayesian networks where network \(N\) is obtained from \(N^0\) by changing the CPTs of variables \(X_1, \ldots, X_m\) from \(\Theta^0_{X_i \mid U_{X_i}}\) to \(\Theta_{X_i \mid U_{X_i}}\) (i.e., changing parameter value \(\theta^0_{x_i \mid u_{X_i}}\) to some new value \(\theta_{x_i \mid u_{X_i}}\) for every \(x_i\) and \(u_{X_i}\)). Let \(\Pr^0\) and \(\Pr\) be the distributions induced by networks \(N^0\) and \(N\), respectively, and also assume that \(\Pr^0(u_{X_i}) > 0\) for every \(u_{X_i}\). Devise a procedure that computes \(D(\Pr^0, \Pr)\). Hint: This procedure can be similar to the one used for computing the MPE probability.
Run the MPE algorithms of Chapter 10 twice on the entrywise ratio tables, once maximizing and once minimizing: the CD distance of Definition 16.1 asks for the extremes of a quantity that factorizes over the families of the network, which is exactly what those algorithms compute. Let \(z\) range over complete instantiations of the network variables \(Z\), and for each changed \(X_i\) define the ratio table
\begin{equation*} f_i(X_i, U_{X_i}), \qquad f_i(x_i, u_{X_i}) \;\stackrel{\text{def}}{=}\; \frac{\theta_{x_i \mid u_{X_i}}}{\theta^0_{x_i \mid u_{X_i}}} , \end{equation*}
a factor over exactly the family \(X_i, U_{X_i}\). By the chain rule \(\Pr^0(z)\) and \(\Pr(z)\) are products of one parameter per network variable differing only in the factors from \(X_1, \ldots, X_m\), so with \(c(z)\) the product of the parameters from the remaining variables (identical in both networks), every \(z\) with \(\Pr^0(z) > 0\) has
\begin{equation*} \frac{\Pr(z)}{\Pr^0(z)} = \frac{c(z)\prod_{i=1}^m \theta_{x_i\mid u_{X_i}}}{c(z)\prod_{i=1}^m \theta^0_{x_i\mid u_{X_i}}} = \prod_{i=1}^m f_i(x_i, u_{X_i}), \end{equation*}
where \(x_i, u_{X_i}\) are the values assigned by \(z\) to \(X_i, U_{X_i}\). Hence, by Definition 16.1,
\begin{equation*} D(\Pr\nolimits^0, \Pr) = \ln \Bigl(\max_{z}\ \prod_{i=1}^m f_i \Bigr)
- \ln \Bigl(\min_{z}\ \prod_{i=1}^m f_i \Bigr). \tag{\(\ast\)} \end{equation*}
This is the MPE computation \(\mathrm{MPE}_P = \max_z \prod_{V} \theta_{v \mid u_V}\) with each CPT replaced by its ratio table (and by the constant \(1\) for unchanged variables); nothing in Chapter 10 uses normalization of the tables, so that machinery applies verbatim. The procedure:
- Build the factor set \(\mathcal{F} = \{f_1, \ldots, f_m\}\) by dividing the new CPTs entrywise by the old ones, using \(0/0 = 1\). Unchanged variables contribute nothing (equivalently, the constant factor \(1\)).
- Choose an elimination order \(\pi\) of all network variables \(Z\). Since every \(f_i\) has scope equal to a family of the network, the interaction graph of \(\mathcal{F}\) is a subgraph of the moral graph of \(N^0\); so any order of width \(w\) for the network is an order of width at most \(w\) here.
- Run \(\mathsf{VE\\_MPE}\) (Algorithm 27) on \(\mathcal{F}\) with order \(\pi\): eliminate the variables one at a time, multiplying all factors that mention the variable and then maximizing it out (Definition 10.1). Eliminating all variables leaves a trivial factor whose value is \(R_{\max} = \max_z \prod_i f_i\).
- Run the same elimination again with maximization replaced by minimization, giving \(R_{\min} = \min_z \prod_i f_i\).
- Return \(D(\Pr^0, \Pr) = \ln R_{\max} - \ln R_{\min}\).
The min pass is legitimate because the correctness of \(\mathsf{VE\\_MPE}\) rests on Theorem 10.1, \(\max_X f_1 f_2 = f_1 \max_X f_2\) when \(X\) occurs only in \(f_2\), and the same holds for minimization of nonnegative factors since \(\min(ab,ac) = a\min(b,c)\) for \(a \ge 0\); our \(f_i\) are nonnegative, so the identical induction gives \(\min_z \prod_i f_i\). Alternatively, leave the algorithm alone and call it on the reciprocal tables \(1/f_i\), using
\begin{equation*} \min_z \prod_{i=1}^m f_i \;=\; \Bigl( \max_z \prod_{i=1}^m \frac{1}{f_i} \Bigr)^{-1}, \end{equation*}
valid when all entries \(\theta_{x_i\mid u_{X_i}}\), \(\theta^0_{x_i \mid u_{X_i}}\) are positive. This is the form the hint points at: two MPE computations, one on \(\Theta/\Theta^0\) and one on \(\Theta^0/\Theta\). Each pass eliminates over factors whose scopes are network families, so each costs \(O(n\exp(w))\) time and space, the cost of one MPE computation, and the max-product jointree algorithm may be substituted with the ratio tables assigned to clusters containing their families.
Two points of care, both about instantiations of probability zero.
- (i)
- an entry with \(\theta^0_{x_i \mid u_{X_i}} = 0 < \theta_{x_i \mid u_{X_i}}\) or \(\theta_{x_i\mid u_{X_i}} = 0 < \theta^0_{x_i\mid u_{X_i}}\) puts \(\infty\) or \(0\) in its ratio table. Running both passes in the extended nonnegative reals (no \(0\cdot\infty\) arises, no factor being both) returns \(R_{\max} = \infty\) or \(R_{\min} = 0\), hence \(D(\Pr^0, \Pr) = \infty\), right whenever the offending entry is realizable, as then the supports differ and Exercise 16.1 applies.
- (ii)
- \((\ast)\) ranges over all \(z\), whereas \(\Pr(z)/\Pr^0(z) = \prod_i f_i(z)\) only for \(z\) with \(c(z) > 0\); instantiations killed by an unchanged parameter have \(\Pr(z) = \Pr^0(z) = 0\), true ratio \(1\). So \((\ast)\) is exact under the standing assumption that \(\Pr^0\) is strictly positive, and an upper bound in general. To restore exactness against structural zeros, attach to every unchanged variable \(V\) the indicator table
\begin{equation*} I_V(v, u_V) = \begin{cases} 1 & \text{if } \theta^0_{v\mid u_V} > 0\\ 0 & \text{otherwise,} \end{cases} \end{equation*}
and run the max pass on \(\mathcal{F} \cup \{I_V : V \text{ unchanged}\}\), reading \(0 \cdot \infty\) as \(0\) so masking wins; for the min pass use the tables that are \(1\) where \(\theta^0_{v\mid u_V} > 0\) and \(\infty\) elsewhere, reading \(\infty\cdot 0\) as \(\infty\), so forbidden instantiations are excluded rather than driving the minimum to \(0\). Scopes are unchanged, so the complexity stays \(O(n\exp(w))\). The value \(1\) contributed by the excluded instantiations never falls outside the resulting interval: \(\sum_{z} \Pr(z) = \sum_z \Pr^0(z) = 1\) forces some surviving \(z\) with \(\Pr(z) \le \Pr^0(z)\) and some with \(\Pr(z) \ge \Pr^0(z)\) when the supports agree, and when they do not both this and the passes report \(\infty\) by Exercise 16.1.
Learning: The Maximum Likelihood Approach
Exercises 17.1–17.7
Consider a Bayesian network structure with the following edges \(A \to B\), \(A \to C\), and \(A \to D\) (so \(A\) is a root and \(B\), \(C\), \(D\) are three leaves, each with the single parent \(A\); all four variables are binary with values \(T\) and \(F\)). Compute the ML parameter estimates for this structure given the following data set:
| Case | A | B | C | D |
|---|---|---|---|---|
| 1 | T | F | F | F |
| 2 | T | F | F | T |
| 3 | F | F | T | F |
| 4 | T | T | F | T |
| 5 | F | F | T | T |
| 6 | F | T | T | F |
| 7 | F | T | T | T |
| 8 | T | F | F | T |
| 9 | F | F | T | F |
| 10 | T | T | T | T |
The data set is complete, so by Theorem 17.1 the ML estimates are the empirical conditional frequencies of Equation 17.1,
\begin{equation*} \theta^{ml}_{x|u} \;=\; \mathit{Pr}_{\mathcal D}(x|u) \;=\; \frac{\mathcal D\#(xu)}{\mathcal D\#(u)}, \end{equation*}
with \(\mathcal D\#(\alpha)\) the number of cases satisfying \(\alpha\); they are unique here because both parent instantiations occur, so \(\mathcal D\#(u) > 0\) throughout. Cases \(1,2,4,8,10\) have \(A = T\) and cases \(3,5,6,7,9\) have \(A = F\), so \(\mathcal D\#(a) = \mathcal D\#(\bar a) = 5\) out of \(N = 10\); within \(A = T\) the counts are \(\mathcal D\#(ba) = 2\), \(\mathcal D\#(ca) = 1\), \(\mathcal D\#(da) = 4\), and within \(A = F\) they are \(\mathcal D\#(b\bar a) = 2\), \(\mathcal D\#(c\bar a) = 5\), \(\mathcal D\#(d\bar a) = 2\) (Check!). Hence
\begin{equation*} \begin{aligned} \theta^{ml}_{a} = \theta^{ml}_{\bar a} &= .5, &\qquad \theta^{ml}_{b|a} = \theta^{ml}_{b|\bar a} &= \tfrac{2}{5} = .4, \\ \theta^{ml}_{c|a} &= \tfrac{1}{5} = .2, &\qquad \theta^{ml}_{c|\bar a} &= \tfrac{5}{5} = 1, \\ \theta^{ml}_{d|a} &= \tfrac{4}{5} = .8, &\qquad \theta^{ml}_{d|\bar a} &= \tfrac{2}{5} = .4 , \end{aligned} \end{equation*}
which collect into the CPTs
| A | \(\theta^{ml}_A\) |
|---|---|
| T | .5 |
| F | .5 |
| A | B | \(\theta^{ml}_{B \mid A}\) |
|---|---|---|
| T | T | .4 |
| T | F | .6 |
| F | T | .4 |
| F | F | .6 |
| A | C | \(\theta^{ml}_{C \mid A}\) |
|---|---|---|
| T | T | .2 |
| T | F | .8 |
| F | T | 1 |
| F | F | 0 |
| A | D | \(\theta^{ml}_{D \mid A}\) |
|---|---|---|
| T | T | .8 |
| T | F | .2 |
| F | T | .4 |
| F | F | .6 |
Consider a Bayesian network structure with edges \(A \to B\) and \(B \to C\) (a chain: \(A\) is a root, \(B\) has the single parent \(A\), and \(C\) has the single parent \(B\); all three variables are binary with values \(T\) and \(F\)). Compute the ML parameter estimates for this structure given the following data set:
| Case | A | B | C |
|---|---|---|---|
| 1 | T | F | F |
| 2 | T | F | F |
| 3 | F | F | T |
| 4 | T | F | F |
Are the ML estimates unique for this data set? If not, how many ML estimates do we have in this case?
The data set is complete, so Theorem 17.1 gives the ML estimates as the empirical conditional frequencies \(\theta^{ml}_{x|u} = \mathcal D\#(xu)/\mathcal D\#(u)\) wherever \(\mathcal D\#(u) > 0\):
\begin{equation*} \begin{aligned} \theta^{ml}_{a} &= \tfrac{3}{4} = .75, &\qquad \theta^{ml}_{\bar a} &= \tfrac{1}{4} = .25,\\ \theta^{ml}_{b|a} = \theta^{ml}_{b|\bar a} &= 0, &\qquad \theta^{ml}_{\bar b|a} = \theta^{ml}_{\bar b|\bar a} &= 1,\\ \theta^{ml}_{c|\bar b} &= \tfrac{1}{4} = .25, &\qquad \theta^{ml}_{\bar c|\bar b} &= \tfrac{3}{4} = .75 , \end{aligned} \end{equation*}
from \(N = 4\), \(\mathcal D\#(a) = 3\) (cases \(1,2,4\)), \(\mathcal D\#(\bar a) = 1\), \(\mathcal D\#(b) = 0\), \(\mathcal D\#(\bar b) = 4\) and \(\mathcal D\#(c\bar b) = 1\) (Check!); the row for \(b\) is undefined by Equation 17.1 since \(\mathcal D\#(b) = 0\).
They are not unique. As in Exercise 17.3, \(\mathit{Pr}_{\mathcal D}(b) = 0\) leaves the likelihood free of \(\theta_{c|b}\) and \(\theta_{\bar c|b}\): for complete data the chain rule gives \(\mathit{Pr}_{\theta}(d_i) = \prod_{\mathbf{XU}} \theta_{x_i|u_i}\), so
\begin{equation*} L(\theta|\mathcal D) \;=\; \prod_{\mathbf{XU}} \prod_{xu} \theta_{x|u}^{\,\mathcal D\#(xu)} , \end{equation*}
in which the exponents \(\mathcal D\#(cb)\) and \(\mathcal D\#(\bar c b)\) are \(0\), while Theorem 17.1 pins every other parameter. The ML parameterizations are therefore
\begin{equation*} \{\theta : \theta_{c|b} = t,\ \theta_{\bar c|b} = 1-t,\ t \in [0,1], \ \text{all other parameters as above}\} , \end{equation*}
a one-parameter continuum, hence uncountably many. All attain the same value: cases \(1,2,4\) each have probability \(\theta_{a}\theta_{\bar b|a}\theta_{\bar c|\bar b} = 9/16\) and case \(3\) has \(\theta_{\bar a}\theta_{\bar b|\bar a}\theta_{c|\bar b} = 1/16\), so
\begin{equation*} L(\mathcal G|\mathcal D) \;=\; \left(\tfrac{9}{16}\right)^{3}\cdot\tfrac{1}{16} \;=\; \frac{729}{65536} \;\approx\; 1.11 \times 10^{-2}. \end{equation*}
Let \(\mathcal G\) be a network structure with families \(\mathbf{XU}\) (each family consists of a variable \(X\) together with its parents \(\mathbf U\) in \(\mathcal G\)), let \(\mathcal D\) be a complete data set, and suppose that \(\mathit{Pr}_{\mathcal D}(\mathbf u) = 0\) for some instantiation \(\mathbf u\) of parent set \(\mathbf U\). Show that the likelihood function \(LL(\theta|\mathcal D)\) is independent of parameters \(\theta_{x|\mathbf u}\) for all \(x\).
The parameter \(\theta_{x|\mathbf u}\) enters \(LL(\theta|\mathcal D)\) only through the term \(\mathcal D\#(x\mathbf u)\log\theta_{x|\mathbf u}\), whose coefficient \(\mathit{Pr}_{\mathcal D}(\mathbf u) = 0\) forces to vanish.
Completeness of \(\mathcal D\) makes the chain rule evaluate each case as one parameter per family, \(\mathit{Pr}_{\theta}(d_i) = \prod_{\mathbf{XU}} \theta_{x_i|\mathbf u_i}\); taking logarithms and grouping the \(N\) cases by family instantiation (each \(\log\theta_{x|\mathbf u}\) arising from exactly the \(\mathcal D\#(x\mathbf u)\) cases with \(d_i \models x\mathbf u\)),
\begin{equation*} \begin{aligned} LL(\theta|\mathcal D) &= \sum_{i=1}^{N} \sum_{\mathbf{XU}} \log \theta_{x_i|\mathbf u_i} = \sum_{\mathbf{XU}} \sum_{x\mathbf u} \mathcal D\#(x\mathbf u)\, \log \theta_{x|\mathbf u}. \end{aligned} \end{equation*}
Now \(\mathit{Pr}_{\mathcal D}(\mathbf u) = 0\) means \(\mathcal D\#(\mathbf u) = 0\) (Definition 17.1), and \(x\mathbf u \models \mathbf u\) gives \(0 \le \mathcal D\#(x\mathbf u) \le \mathcal D\#(\mathbf u) = 0\) for every \(x\). So no term mentions \(\theta_{x|\mathbf u}\), and replacing the row \(\theta_{X|\mathbf u}\) by any other distribution over \(X\) leaves \(LL(\theta|\mathcal D)\) unchanged.
Let \(\mathcal G\) be a network structure with families \(\mathbf{XU}\) and let \(\mathcal D\) be a complete data set. Prove the following form for the likelihood of structure \(\mathcal G\):
\begin{equation*} L(\mathcal G|\mathcal D) \;=\; \prod_{\mathbf{XU}} \prod_{x\mathbf u} \left( \theta^{ml}_{x|\mathbf u} \right)^{\mathcal D\#(x\mathbf u)} , \end{equation*}
where \(\theta^{ml}_{x|\mathbf u}\) is the ML estimate for parameter \(\theta_{x|\mathbf u}\), and \(\mathcal D\#(x\mathbf u)\) is the number of cases in \(\mathcal D\) satisfying the family instantiation \(x\mathbf u\).
Since \(L(\mathcal G|\mathcal D) = L(\theta^{ml}|\mathcal D)\) by definition, it suffices to prove for an arbitrary parameterization \(\theta\) of \(\mathcal G\) that
\begin{equation*} (\ast) \qquad L(\theta|\mathcal D) \;=\; \prod_{\mathbf{XU}} \prod_{x\mathbf u} \theta_{x|\mathbf u}^{\,\mathcal D\#(x\mathbf u)} . \end{equation*}
Completeness of \(\mathcal D\) makes the chain rule give \(\mathit{Pr}_{\theta}(d_i) = \prod_{\mathbf{XU}} \theta_{x_i|\mathbf u_i}\), with \(x_i\mathbf u_i\) the unique family instantiation compatible with \(d_i\); multiplying over the \(N\) cases (Equation 17.2) and grouping, for each family, the cases by the instantiation they select, so that \(\theta_{x|\mathbf u}\) is contributed by exactly the \(\mathcal D\#(x\mathbf u)\) cases with \(d_i \models x\mathbf u\),
\begin{equation*} \begin{aligned} L(\theta|\mathcal D) &= \prod_{\mathbf{XU}} \prod_{i=1}^{N} \theta_{x_i|\mathbf u_i} = \prod_{\mathbf{XU}} \prod_{x\mathbf u} \theta_{x|\mathbf u}^{\,\mathcal D\#(x\mathbf u)} , \end{aligned} \end{equation*}
the regrouping being exact because over complete cases the family instantiations are mutually exclusive and exhaustive, \(\sum_{x\mathbf u}\mathcal D\#(x\mathbf u) = N\). Instantiating \((\ast)\) at \(\theta^{ml}_{x|\mathbf u} = \mathit{Pr}_{\mathcal D}(x|\mathbf u)\) (Theorem 17.1) gives the claim; where \(\mathcal D\#(\mathbf u) = 0\) leaves \(\theta^{ml}_{X|\mathbf u}\) undetermined, Exercise 17.3 makes those counts \(0\) and those factors \(1\).
Consider a Bayesian network with edges \(A \to B\) and \(A \to C\) (a common cause: \(A\) is a root with the two children \(B\) and \(C\), and \(B\), \(C\) have no other parents; all variables are binary with values \(T\) and \(F\)), and the parameters \(\theta\):
| A | \(\theta_A\) |
|---|---|
| T | .3 |
| F | .7 |
| A | B | \(\theta_{B \mid A}\) |
|---|---|---|
| T | T | .5 |
| T | F | .5 |
| F | T | .8 |
| F | F | .2 |
| A | C | \(\theta_{C \mid A}\) |
|---|---|---|
| T | T | .1 |
| T | F | .9 |
| F | T | .5 |
| F | F | .5 |
Consider the following data set \(\mathcal D\) (a question mark denotes a missing value):
| Case | A | B | C |
|---|---|---|---|
| 1 | F | ? | T |
| 2 | F | T | T |
| 3 | ? | F | T |
| 4 | ? | T | F |
| 5 | T | F | ? |
What is the expected empirical distribution for data set \(\mathcal D\) given parameters \(\theta\), \(\mathit{Pr}_{\mathcal D,\theta}(.)\)?
By Definition 17.2 with \(N = 5\),
\begin{equation*} \mathit{Pr}_{\mathcal D,\theta}(\alpha) \;=\; \frac{1}{5} \sum_{d_i, c_i \models \alpha} \mathit{Pr}_{\theta}(c_i | d_i), \end{equation*}
\(c_i\) ranging over the instantiations of the variables missing from case \(d_i\). The chain rule \(\mathit{Pr}_{\theta}(abc) = \theta_a \theta_{b|a} \theta_{c|a}\) gives the joint:
| A | B | C | \(\mathit{Pr}_{\theta}\) |
|---|---|---|---|
| T | T | T | \((.3)(.5)(.1) = .015\) |
| T | T | F | \((.3)(.5)(.9) = .135\) |
| T | F | T | \((.3)(.5)(.1) = .015\) |
| T | F | F | \((.3)(.5)(.9) = .135\) |
| F | T | T | \((.7)(.8)(.5) = .280\) |
| F | T | F | \((.7)(.8)(.5) = .280\) |
| F | F | T | \((.7)(.2)(.5) = .070\) |
| F | F | F | \((.7)(.2)(.5) = .070\) |
Normalizing the consistent rows of this table gives each case’s completion weights \(\mathit{Pr}_{\theta}(c_i|d_i)\):
- (i) \(d_1 = \bar a c\), missing \(B\): rows \(.28, .07\) total \(.35\), so \(\mathit{Pr}_{\theta}(b|\bar a c) = .8\), \(\mathit{Pr}_{\theta}(\bar b|\bar a c) = .2\).
- (ii) \(d_2 = \bar a b c\) is complete: single completion, weight \(1\).
- (iii) \(d_3 = \bar b c\), missing \(A\): rows \(.015, .07\) total \(.085\), so \(\mathit{Pr}_{\theta}(a|\bar b c) = 3/17\), \(\mathit{Pr}_{\theta}(\bar a|\bar b c) = 14/17\).
- (iv) \(d_4 = b\bar c\), missing \(A\): rows \(.135, .28\) total \(.415\), so \(\mathit{Pr}_{\theta}(a|b\bar c) = 27/83\), \(\mathit{Pr}_{\theta}(\bar a|b\bar c) = 56/83\).
- (v) \(d_5 = a\bar b\), missing \(C\): rows \(.015, .135\) total \(.15\), so \(\mathit{Pr}_{\theta}(c|a\bar b) = .1\), \(\mathit{Pr}_{\theta}(\bar c|a\bar b) = .9\).
Summing each full instantiation’s weights and dividing by \(5\) — \(a\bar b c\), say, occurs in (iii) and (v), giving \((3/17 + .1)/5 = 47/850\) — yields:
| A | B | C | contributions | \(\mathit{Pr}_{\mathcal D,\theta}(.)\) |
|---|---|---|---|---|
| T | T | T | none | \(0\) |
| T | T | F | \(d_4: 27/83\) | \(27/415 \approx .06506\) |
| T | F | T | \(d_3: 3/17\), \(d_5: .1\) | \(47/850 \approx .05529\) |
| T | F | F | \(d_5: .9\) | \(.18\) |
| F | T | T | \(d_1: .8\), \(d_2: 1\) | \(1.8/5 = .36\) |
| F | T | F | \(d_4: 56/83\) | \(56/415 \approx .13494\) |
| F | F | T | \(d_1: .2\), \(d_3: 14/17\) | \(87/425 \approx .20471\) |
| F | F | F | none | \(0\) |
Consider Exercise 17.5, that is, the Bayesian network with edges \(A \to B\) and \(A \to C\) whose CPTs are \(\theta_a = .3\); \(\theta_{b|a} = .5\), \(\theta_{b|\bar a} = .8\); \(\theta_{c|a} = .1\), \(\theta_{c|\bar a} = .5\), together with the incomplete data set
| Case | A | B | C |
|---|---|---|---|
| 1 | F | ? | T |
| 2 | F | T | T |
| 3 | ? | F | T |
| 4 | ? | T | F |
| 5 | T | F | ? |
and assume that the given CPTs are the initial CPTs \(\theta^{0}\) used by EM. Compute the EM parameter estimates after one iteration of the algorithm.
By Definition 17.3, \(\theta^{1}_{x|\mathbf u} = \mathit{Pr}_{\mathcal D,\theta^{0}}(x\mathbf u) / \mathit{Pr}_{\mathcal D,\theta^{0}}(\mathbf u)\), read off the expected empirical distribution of Exercise 17.5:
| A | B | C | \(\mathit{Pr}_{\mathcal D,\theta^{0}}(.)\) |
|---|---|---|---|
| T | T | T | \(0\) |
| T | T | F | \(27/415 \approx .06506\) |
| T | F | T | \(47/850 \approx .05529\) |
| T | F | F | \(.18\) |
| F | T | T | \(.36\) |
| F | T | F | \(56/415 \approx .13494\) |
| F | F | T | \(87/425 \approx .20471\) |
| F | F | F | \(0\) |
Summing rows gives the marginals
\begin{equation*} \begin{aligned} \mathit{Pr}_{\mathcal D,\theta^{0}}(a) &= \tfrac{27}{415} + \tfrac{47}{850} + \tfrac{9}{50} = \tfrac{2119}{7055} \approx .30035, \\ \mathit{Pr}_{\mathcal D,\theta^{0}}(ab) &= \tfrac{27}{415}, \qquad \mathit{Pr}_{\mathcal D,\theta^{0}}(\bar a b) = .36 + \tfrac{56}{415} = \tfrac{1027}{2075}, \\ \mathit{Pr}_{\mathcal D,\theta^{0}}(ac) &= \tfrac{47}{850}, \qquad \mathit{Pr}_{\mathcal D,\theta^{0}}(\bar a c) = .36 + \tfrac{87}{425} = \tfrac{48}{85}, \end{aligned} \end{equation*}
and dividing by \(\mathit{Pr}_{\mathcal D,\theta^{0}}(a)\) and \(\mathit{Pr}_{\mathcal D,\theta^{0}}(\bar a) = 4936/7055\),
\begin{equation*} \begin{aligned} \theta^{1}_{b|a} &= \tfrac{459}{2119} \approx .21661, \qquad \theta^{1}_{b|\bar a} = \tfrac{17459}{24680} \approx .70741, \\ \theta^{1}_{c|a} &= \tfrac{3901}{21190} \approx .18410, \qquad \theta^{1}_{c|\bar a} = \tfrac{498}{617} \approx .80713 . \end{aligned} \end{equation*}
The estimates after one EM iteration are therefore:
| A | \(\theta^{1}_A\) |
|---|---|
| T | .30035 |
| F | .69965 |
| A | B | \(\theta^{1}_{B \mid A}\) |
|---|---|---|
| T | T | .21661 |
| T | F | .78339 |
| F | T | .70741 |
| F | F | .29259 |
| A | C | \(\theta^{1}_{C \mid A}\) |
|---|---|---|
| T | T | .18410 |
| T | F | .81590 |
| F | T | .80713 |
| F | F | .19287 |
Every parent instantiation has \(\mathit{Pr}_{\mathcal D,\theta^{0}}(\mathbf u) > 0\), so by Theorem 17.5 these are the unique maximizers of \(ELL(\theta|\mathcal D,\theta^{0})\).
Consider Exercise 17.5, that is, the Bayesian network with edges \(A \to B\) and \(A \to C\) whose CPTs are \(\theta_a = .3\); \(\theta_{b|a} = .5\), \(\theta_{b|\bar a} = .8\); \(\theta_{c|a} = .1\), \(\theta_{c|\bar a} = .5\), together with the incomplete data set
| Case | A | B | C |
|---|---|---|---|
| 1 | F | ? | T |
| 2 | F | T | T |
| 3 | ? | F | T |
| 4 | ? | T | F |
| 5 | T | F | ? |
and assume that the given CPTs are those used by the gradient ascent approach for estimating parameters. Decide whether this approach increases or decreases the values of parameters \(\theta_{\bar a}\), \(\theta_{b|a}\), and \(\theta_{\bar c|a}\) in its first iteration. Use the soft-max search space to impose parameter constraints.
All three decrease, each of the three parameters exceeding the EM estimate for its row.
Under the soft-max reparameterization \(\theta_{x|\mathbf u} = e^{\tau_{x|\mathbf u}}/\sum_{x^{\star}} e^{\tau_{x^{\star}|\mathbf u}}\) of Section 17.3.2 gradient ascent steps \(\tau_{x|\mathbf u}\) by \(\eta\,\partial LL/\partial\tau_{x|\mathbf u}\), so the sign of that gradient is the answer. The soft-max derivatives are
\begin{equation*} \frac{\partial \theta_{x|\mathbf u}}{\partial \tau_{x|\mathbf u}} = \theta_{x|\mathbf u}(1 - \theta_{x|\mathbf u}), \qquad \frac{\partial \theta_{x^{\star}|\mathbf u}}{\partial \tau_{x|\mathbf u}} = -\,\theta_{x|\mathbf u}\,\theta_{x^{\star}|\mathbf u} \quad (x^{\star} \neq x), \end{equation*}
by Exercise 17.10 and its off-diagonal companion, \(\tau_{x|\mathbf u}\) leaving every other CPT row untouched; and \(\partial LL/\partial\theta_{x|\mathbf u} = N\,\mathit{Pr}_{\mathcal D,\theta}(x\mathbf u)/\theta_{x|\mathbf u}\) by Theorem 17.8 (Equation 17.10) with Theorem 17.4. Chaining through the whole row, the \(\theta\) factors cancel:
\begin{equation*} \begin{aligned} \frac{\partial LL}{\partial \tau_{x|\mathbf u}} &= \sum_{x^{\star}} \frac{\partial LL}{\partial \theta_{x^{\star}|\mathbf u}} \frac{\partial \theta_{x^{\star}|\mathbf u}}{\partial \tau_{x|\mathbf u}} \\ &= N\mathit{Pr}_{\mathcal D,\theta}(x\mathbf u) - N\theta_{x|\mathbf u}\sum_{x^{\star}} \mathit{Pr}_{\mathcal D,\theta}(x^{\star}\mathbf u) \\ &= N\,\mathit{Pr}_{\mathcal D,\theta}(\mathbf u) \bigl[\, \mathit{Pr}_{\mathcal D,\theta}(x|\mathbf u) - \theta_{x|\mathbf u} \,\bigr]. \end{aligned} \end{equation*}
Every parent instantiation here has \(\mathit{Pr}_{\mathcal D,\theta}(\mathbf u) > 0\), so \(\theta_{x|\mathbf u}\) increases exactly when the EM estimate \(\mathit{Pr}_{\mathcal D,\theta}(x|\mathbf u)\) of Definition 17.3 exceeds it, the two gradients of a binary row being negatives of each other. (Reading Equation 17.8 as the single product \((\partial LL/\partial\theta_{x|\mathbf u})(\partial\theta_{x|\mathbf u}/\partial\tau_{x|\mathbf u})\) instead gives growth iff \(\mathit{Pr}_{\mathcal D,\theta}(x\mathbf u)(1-\theta_{x|\mathbf u}) > \mathit{Pr}_{\mathcal D,\theta}(\bar x\mathbf u)(1-\theta_{\bar x|\mathbf u})\), the same criterion.) Exercises 17.5 and 17.6 supply the conditionals:
\begin{equation*} \begin{aligned} \mathit{Pr}_{\mathcal D,\theta}(\bar a) &= 4936/7055 \approx .69965, \\ \mathit{Pr}_{\mathcal D,\theta}(b|a) &= 459/2119 \approx .21661, \\ \mathit{Pr}_{\mathcal D,\theta}(\bar c|a) &= 17289/21190 \approx .81590 . \end{aligned} \end{equation*}
Each falls below the current value, so each gradient is negative:
| parameter | current \(\theta\) | \(\mathit{Pr}_{\mathcal D,\theta}(x \mid \mathbf u)\) | difference | effect |
|---|---|---|---|---|
| \(\theta_{\bar a}\) | \(.7\) | \(.69965\) | \(-.00035\) | decrease |
| \(\theta_{b\mid a}\) | \(.5\) | \(.21661\) | \(-.28339\) | decrease |
| \(\theta_{\bar c\mid a}\) | \(.9\) | \(.81590\) | \(-.08410\) | decrease |
Explicitly, with \(N = 5\), \(\mathit{Pr}_{\mathcal D,\theta}(\top) = 1\) for the root and \(\mathit{Pr}_{\mathcal D,\theta}(a) \approx .30035\) for the rows conditioned on \(a\):
\begin{equation*} \begin{aligned} \frac{\partial LL}{\partial \tau_{\bar a}} &= 5(1)(.699646 - .7) = -.00177, \\ \frac{\partial LL}{\partial \tau_{b|a}} &= 5(.30035)(.21661 - .5) = -.42558, \\ \frac{\partial LL}{\partial \tau_{\bar c|a}} &= 5(.30035)(.81590 - .9) = -.12629 . \end{aligned} \end{equation*}
Exercises 17.8–17.14
Consider a complete data set \(D\) and let \(G_1\) and \(G_2\) be two complete DAGs (that is, DAGs over the variables of \(D\) in which every pair of nodes is connected by an edge). Prove or disprove
\begin{equation*} \text{LL}(G_1 \mid D) = \text{LL}(G_2 \mid D). \end{equation*}
If the equality does not hold, provide a counterexample.
The equality always holds: every complete DAG has the same log-likelihood given a complete data set, namely \(-N \cdot \text{ENT}_D(\mathbf{X})\).
A complete DAG \(G\) over \(\mathbf X = X_1,\dots,X_n\) has a unique topological order \(X_{\sigma(1)},\dots,X_{\sigma(n)}\) (adjacency makes any two nodes comparable), with parent sets \(\mathbf U_i = \{X_{\sigma(1)},\dots,X_{\sigma(i-1)}\}\), and ML estimates \(\theta^{ml}_{x\mid u} = \Pr_D(x\mid u)\) by Theorem 17.1. Hence for any full instantiation \(\mathbf x\),
\begin{equation*} \begin{aligned} \Pr_{\theta^{ml}}(\mathbf{x}) &= \prod_{i=1}^{n} \theta^{ml}_{x_{\sigma(i)} \mid \mathbf{u}_i} \\ &= \prod_{i=1}^{n} \Pr_D\bigl(x_{\sigma(i)} \mid \mathbf{u}_i\bigr) \\ &= \Pr_D(\mathbf{x}), \end{aligned} \end{equation*}
the last step being the chain rule for \(\Pr_D\) in the order \(\sigma\) (legitimate since \(\Pr_D(\mathbf x) > 0\) forces \(\Pr_D(\mathbf u_i) > 0\), while rows conditioned on zero-count instantiations do not affect the likelihood by Exercise 17.3). So \(G\) with its ML parameters induces \(\Pr_D\) whatever \(\sigma\) is, and
\begin{equation*} \begin{aligned} \text{LL}(G \mid D) &= \sum_{i=1}^{N} \log \Pr_{\theta^{ml}}(d_i) = \sum_{i=1}^{N} \log \Pr_D(d_i) \\ &= N \sum_{\mathbf{x}} \Pr_D(\mathbf{x}) \log \Pr_D(\mathbf{x}) \\ &= -N \cdot \text{ENT}_D(\mathbf{X}), \end{aligned} \end{equation*}
grouping the \(N\) cases by the instantiation they realize via \(D\#(\mathbf x) = N\Pr_D(\mathbf x)\). The right-hand side mentions only \(D\), so \(\text{LL}(G_1\mid D) = \text{LL}(G_2\mid D)\).
Method (2): by Theorem 17.3,
\begin{equation*} \text{LL}(G \mid D) = -N \sum_{i=1}^{n} \text{ENT}_D(X_{\sigma(i)}\mid \mathbf{U}_i). \end{equation*}
With \(\text{ENT}(X \mid \mathbf{U}) = \text{ENT}(X\mathbf{U}) - \text{ENT}(\mathbf{U})\) and \(\mathbf{U}_{i+1} = \mathbf{U}_i \cup \{X_{\sigma(i)}\}\) the sum telescopes:
\begin{equation*} \begin{aligned} \sum_{i=1}^{n} \text{ENT}_D(X_{\sigma(i)} \mid \mathbf{U}_i) &= \sum_{i=1}^{n} [\text{ENT}_D(\mathbf{U}_{i+1}) - \text{ENT}_D(\mathbf{U}_i)] \\ &= \text{ENT}_D(X_1,\dots,X_n), \end{aligned} \end{equation*}
since \(\mathbf{U}_1 = \emptyset\) has zero entropy and \(\mathbf{U}_{n+1} = \mathbf{X}\); the value is invariant under \(\sigma\).
What happens if we apply the EM algorithm to a complete data set? That is, what estimates does it return as a function of the initial estimates with which it starts?
On complete data EM ignores its initial estimates entirely and returns the ML estimates \(\theta^{ml}_{x \mid u} = \Pr_D(x \mid u)\) after a single iteration, after which it sits at a fixed point.
Let \(\theta^0\) be any start with \(\Pr_{\theta^0}(d_i) > 0\) for every case (needed for Definition 17.3 to apply; hence the usual strictly positive initialization). Each complete case instantiates every variable, so the missing set \(\mathbf C_i\) of Definition 17.2 is empty, \(d_i\) is its own sole completion, and \(\Pr_{\theta^0}(xu\mid d_i) \in \{0,1\}\) according as \(d_i \models xu\) or not. Hence the E-step returns the ordinary empirical distribution,
\begin{equation*} \begin{aligned} \Pr_{D,\theta^0}(\alpha) &= \frac{1}{N}\sum_{i=1}^{N} \Pr_{\theta^0}(\alpha \mid d_i) \\ &= \frac{D\#(\alpha)}{N} = \Pr_D(\alpha), \end{aligned} \end{equation*}
by Theorem 17.4, with \(\theta^0\) dropped out. The M-step (17.7) then gives
\begin{equation*} \theta^1_{x\mid u} = \frac{\sum_i \Pr_{\theta^0}(xu\mid d_i)}{\sum_i \Pr_{\theta^0}(u\mid d_i)} = \frac{D\#(xu)}{D\#(u)} = \Pr_D(x \mid u), \end{equation*}
the ML estimate of Theorem 17.1. Nothing beyond positivity of \(\theta^0\) was used, and \(\theta^1 = \theta^{ml}\) is itself positive on every case (each \(d_i\) has \(D\#(d_i) \ge 1\)), so repeating gives \(\theta^2 = \theta^1\): EM converges in one iteration, onto the unique maximum of the log-likelihood, as Theorem 17.7 predicts. (Where \(D\#(u) = 0\) both parts of (17.7) vanish and \(\theta^1_{x\mid u}\) stays at \(\theta^0_{x\mid u}\), harmlessly: by Exercise 17.3 the likelihood ignores those parameters.)
When performing gradient ascent on the log-likelihood function one must respect the constraints \(\theta_{x\mid u} \in [0,1]\) and \(\sum_x \theta_{x \mid u} = 1\). Section 17.3.2 handles this by searching in the soft-max space: for each parameter \(\theta_{x\mid u}\) one introduces a variable \(\tau_{x \mid u}\) with values in \((-\infty, \infty)\) and defines
\begin{equation*} \theta_{x\mid u} \;\overset{\text{def}}{=}\; \frac{e^{\tau_{x\mid u}}}{\sum_{x^\star} e^{\tau_{x^\star \mid u}}}. \end{equation*}
Gradient ascent then uses the gradient of Equation 17.8,
\begin{equation*} \frac{\partial \text{LL}(\theta \mid D)}{\partial \tau_{x\mid u}} = \frac{\partial \text{LL}(\theta \mid D)}{\partial \theta_{x\mid u}} \cdot \frac{\partial \theta_{x\mid u}}{\partial \tau_{x\mid u}}. \end{equation*}
Compute the derivative \(\dfrac{\partial \theta_{x\mid u}}{\partial \tau_{x\mid u}}\) given in Equation 17.8.
\(\partial \theta_{x\mid u}/\partial \tau_{x\mid u} = \theta_{x\mid u}(1 - \theta_{x\mid u})\). Writing \(Z_u = \sum_{x^\star} e^{\tau_{x^\star\mid u}}\), so that \(\partial Z_u/\partial \tau_{x\mid u} = e^{\tau_{x\mid u}}\), the quotient rule gives
\begin{equation*} \begin{aligned} \frac{\partial \theta_{x\mid u}}{\partial \tau_{x \mid u}} &= \frac{e^{\tau_{x\mid u}} Z_u - e^{2\tau_{x\mid u}}}{Z_u^2} \\ &= \frac{e^{\tau_{x\mid u}}}{Z_u}\left(1 - \frac{e^{\tau_{x\mid u}}}{Z_u}\right) \\ &= \theta_{x\mid u}\bigl(1 - \theta_{x \mid u}\bigr). \end{aligned} \end{equation*}
Substituting this and Theorem 17.8 into (17.8),
\begin{equation*} \frac{\partial \text{LL}(\theta\mid D)}{\partial \tau_{x\mid u}} = \theta_{x\mid u}(1-\theta_{x\mid u}) \sum_{i=1}^{N} \frac{\Pr_\theta(xu \mid d_i)}{\theta_{x\mid u}} = (1-\theta_{x\mid u}) \sum_{i=1}^{N} \Pr_\theta(xu\mid d_i). \end{equation*}
The map is not coordinate-wise: \(\tau_{x\mid u}\) moves every \(\theta_{x^\star\mid u}\) of the same column, with
\begin{equation*} \frac{\partial \theta_{y\mid u^\star}}{\partial \tau_{x\mid u}} = \delta_{u u^\star}\,\theta_{y\mid u}\bigl(\delta_{xy} - \theta_{x\mid u}\bigr) \end{equation*}
(the \(\delta_{uu^\star}\) because a different parent instantiation uses disjoint \(\tau\) variables), so the exact chain rule is the sum \(\sum_{x^\star}(\partial\text{LL}/\partial\theta_{x^\star\mid u})(\partial\theta_{x^\star\mid u}/\partial\tau_{x\mid u})\), which by Theorem 17.8 collapses to \(\sum_{i}[\Pr_\theta(xu\mid d_i) - \theta_{x\mid u}\Pr_\theta(u\mid d_i)]\) (Exercise 17.7), rather than the single product displayed in (17.8).
Compute an ML tree structure for the data set in Exercise 17.1. What is the total number of ML tree structures for this data set? The data set of Exercise 17.1 is over the binary variables \(A, B, C, D\):
| Case | A | B | C | D |
|---|---|---|---|---|
| 1 | T | F | F | F |
| 2 | T | F | F | T |
| 3 | F | F | T | F |
| 4 | T | T | F | T |
| 5 | F | F | T | T |
| 6 | F | T | T | F |
| 7 | F | T | T | T |
| 8 | T | F | F | T |
| 9 | F | F | T | F |
| 10 | T | T | T | T |
Recall that a tree structure is a DAG in which every node has at most one parent and whose skeleton is a spanning tree; such a structure is obtained by choosing a root and directing all edges away from it.
One ML tree is \(A \to C\), \(A \to D\), \(C \to B\), and there are \(8\) in all. By Theorem 17.10 the ML trees are exactly the orientations of the maximum spanning trees of the complete graph on \(A,B,C,D\) weighted by \(\text{MI}_D\), since \(\text{tScore}(G\mid D) = \sum_{U\to X}\text{MI}_D(X,U)\). From the \(N = 10\) cases,
\begin{equation*} \begin{aligned} &D\#(A{=}T)=5, \quad D\#(B{=}T)=4, \\ &D\#(C{=}T)=6, \quad D\#(D{=}T)=6, \end{aligned} \end{equation*}
and the six pairwise count tables (rows are the first variable’s value):
| pair | TT | TF | FT | FF |
|---|---|---|---|---|
| A,B | 2 | 3 | 2 | 3 |
| A,C | 1 | 4 | 5 | 0 |
| A,D | 4 | 1 | 2 | 3 |
| B,C | 3 | 1 | 3 | 3 |
| B,D | 3 | 1 | 3 | 3 |
| C,D | 3 | 3 | 3 | 1 |
With \(\text{MI}_D(X,U) = \sum_{x,u}\Pr_D(xu)\log_2 \frac{\Pr_D(xu)}{\Pr_D(x)\Pr_D(u)}\): the pair \(A,B\) factors exactly (\(0.2 = 0.5 \times 0.4\), and likewise the other three entries), so \(\text{MI}_D(A,B) = 0\). For \(A,C\):
\begin{equation*} \begin{aligned} \text{MI}_D(A,C) &= 0.1\log_2\tfrac{0.1}{0.3} + 0.4\log_2\tfrac{0.4}{0.2}
- 0.5\log_2\tfrac{0.5}{0.3} \\ &= 0.4 + \tfrac12\log_2 5 - \tfrac35 \log_2 3 \;=\; 0.60999 . \end{aligned} \end{equation*}
For \(A,D\):
\begin{equation*} \begin{aligned} \text{MI}_D(A,D) &= 0.4\log_2\tfrac{4}{3} + 0.1\log_2\tfrac12
- 0.2\log_2\tfrac23 + 0.3\log_2\tfrac32 \\ &= 0.12451 . \end{aligned} \end{equation*}
The pairs \(B,C\), \(B,D\), \(C,D\) share the count multiset \(\{3,3,3,1\}\) against marginals \(\{6,4\}\) and \(\{4,6\}\), hence share a value:
\begin{equation*} \begin{aligned} \text{MI}_D(B,C) &= \text{MI}_D(B,D) = \text{MI}_D(C,D) \\ &= 2\bigl(0.3 \log_2 \tfrac{0.3}{0.24}\bigr) + 0.3\log_2\tfrac{0.3}{0.36} \\ &\quad + 0.1 \log_2 \tfrac{0.1}{0.16} \\ &= 0.04644 . \end{aligned} \end{equation*}
Collected:
| edge | \(\text{MI}_D\) |
|---|---|
| A-B | 0.00000 |
| A-C | 0.60999 |
| A-D | 0.12451 |
| B-C | 0.04644 |
| B-D | 0.04644 |
| C-D | 0.04644 |
Kruskal on these weights takes \(A\text{-}C\), then \(A\text{-}D\); the remaining edge must attach \(B\), and of the candidates \(B\text{-}C\), \(B\text{-}D\) (both \(0.04644\)) and \(A\text{-}B\) (\(0\)) the first two tie, while \(C\text{-}D\), tied in weight, would close a cycle. So the maximum spanning trees are
\begin{equation*} T_1 = \{A\text{-}C,\; A\text{-}D,\; B\text{-}C\} \quad\text{or}\quad T_2 = \{A\text{-}C,\; A\text{-}D,\; B\text{-}D\}, \end{equation*}
both of cost
\begin{equation*} 0.60999 + 0.12451 + 0.04644 = 0.78094 . \end{equation*}
Enumerating the \(4^{4-2} = 16\) spanning trees on four labeled nodes confirms \(T_1, T_2\) are the only maximizers (next best \(0.73450\), the star at \(A\)). Rooting \(T_1\) at \(A\) gives \(A \to C\), \(A \to D\), \(C \to B\), whose ML parameters \(\theta^{ml}_{x\mid u} = \Pr_D(x\mid u)\) (Theorem 17.1) are read off the counts:
| \(A\) | \(\theta_a\) |
|---|---|
| T | 1/2 |
| F | 1/2 |
| \(A\) | \(C\) | \(\theta_{c\mid a}\) |
|---|---|---|
| T | T | 1/5 |
| T | F | 4/5 |
| F | T | 1 |
| F | F | 0 |
| \(A\) | \(D\) | \(\theta_{d\mid a}\) |
|---|---|---|
| T | T | 4/5 |
| T | F | 1/5 |
| F | T | 2/5 |
| F | F | 3/5 |
| \(C\) | \(B\) | \(\theta_{b\mid c}\) |
|---|---|---|
| T | T | 1/2 |
| T | F | 1/2 |
| F | T | 1/4 |
| F | F | 3/4 |
Each of the two maximum spanning trees yields exactly \(n = 4\) directed trees, one per root, pairwise distinct because different roots orient differently, and the two skeletons differ; hence \(2 \times 4 = 8\) ML tree structures. For \(T_1\):
\begin{equation*} \begin{aligned} &\text{root } A: && A\to C,\; A \to D,\; C\to B \\ &\text{root } B: && B \to C,\; C \to A,\; A \to D \\ &\text{root } C: && C \to A,\; C\to B,\; A \to D \\ &\text{root } D: && D \to A,\; A\to C,\; C \to B \end{aligned} \end{equation*}
and the four for \(T_2\) are obtained by replacing the edge between \(B\) and \(C\) with one between \(B\) and \(D\).
Consider a Bayesian network structure consisting of the single edge \(X \to Y\) (so the parameters are \(\theta_x\) for the root \(X\) and \(\theta_{y\mid x}\) for \(Y\)), and a data set \(D\) of size \(N\) in which \(X\) is hidden and \(Y\) is observed in every case of \(D\). Show that ML estimates are characterized by
\begin{equation*} \sum_{x} \theta_x\, \theta_{y\mid x} \;=\; \frac{D\#(y)}{N} \end{equation*}
for all values \(y\); that is, ML estimates are those that ensure \(\Pr(y) = D\#(y)/N\) for all \(y\).
The log-likelihood depends on \(\theta\) only through the induced marginal \(\Pr_\theta(Y)\), which Lemma 17.1 maximizes uniquely at \(\Pr_D(Y)\). Every case \(d_i\) is an instantiation \(y_i\) of \(Y\), so
\begin{equation*} \begin{aligned} \text{LL}(\theta \mid D) &= \sum_{i=1}^{N} \log \Pr_\theta(d_i) = \sum_{i=1}^{N} \log \Pr_\theta(y_i) \\ &= \sum_{y} D\#(y) \log \Pr_\theta(y) = N \sum_{y} \Pr_D(y) \log \Pr_\theta(y), \end{aligned} \end{equation*}
grouping the cases by the value of \(Y\) they report, with \(\Pr_D(y) = D\#(y)/N\); and summing out the hidden root, \(\Pr_\theta(y) = \sum_x \theta_x\theta_{y\mid x}\).
Lemma 17.1, applied to the fixed distribution \(\Pr_D(Y)\) against the variable \(\Pr_\theta(Y)\), bounds \(\sum_y \Pr_D(y)\log\Pr_\theta(y) \le \sum_y \Pr_D(y)\log\Pr_D(y)\) with equality iff \(\Pr_\theta(Y) = \Pr_D(Y)\), so
\begin{equation*} \text{LL}(\theta \mid D) \;\le\; -N \cdot \text{ENT}_D(Y), \end{equation*}
with equality exactly when \(\sum_x \theta_x \theta_{y\mid x} = D\#(y)/N\) for all \(y\). The bound is attained, since \(\theta_{y\mid x} = D\#(y)/N\) for every \(x\) is a legitimate CPT meeting it whatever the root parameters, so \(-N\,\text{ENT}_D(Y)\) is the maximum and the displayed condition characterizes the ML estimates.
Consider a Bayesian network structure with edges \(X \to Y\) and \(Y \to Z\) (a chain, with parameters \(\theta_x\), \(\theta_{y\mid x}\) and \(\theta_{z\mid y}\)), and a data set \(D\) of size \(N\) in which \(Y\) is hidden yet \(X\) and \(Z\) are observed in every case of \(D\). Provide a characterization of the ML estimates for this problem, together with some concrete parameter estimates that satisfy the characterization.
Assuming \(|Y| \ge \min(|X|,|Z|)\) (so in particular for binary variables), \(\theta\) is an ML estimate iff it reproduces the empirical joint over the observed variables:
\begin{equation*} \Pr_\theta(x,z) \;=\; \theta_x \sum_y \theta_{y\mid x}\theta_{z\mid y} \;=\; \frac{D\#(xz)}{N} \quad\text{for all } x,z, \end{equation*}
equivalently, if and only if
\begin{equation*} \theta_x = \frac{D\#(x)}{N} \quad\text{and}\quad \sum_y \theta_{y\mid x}\theta_{z\mid y} = \frac{D\#(xz)}{D\#(x)} \end{equation*}
for all \(x\) with \(D\#(x) > 0\) and all \(z\) (the rows \(\theta_{Y\mid x}\) at \(D\#(x)=0\) being unconstrained); the maximum log-likelihood is \(-N\,\text{ENT}_D(X,Z)\).
Each case \(d_i\) is an instantiation \(x_i z_i\) of \(X\) and \(Z\) only, so, writing \(M(z\mid x) \overset{\text{def}}{=} \sum_y \theta_{y\mid x}\theta_{z\mid y}\) — a distribution over \(Z\) for each \(x\), with \(\Pr_\theta(x,z) = \theta_x M(z\mid x)\) — and splitting the logarithm,
\begin{equation*} \begin{aligned} \text{LL}(\theta\mid D) &= \sum_{i=1}^{N}\log \Pr_\theta(x_i z_i) = \sum_{x,z} D\#(xz)\log \Pr_\theta(x,z) , \end{aligned} \end{equation*}
\begin{equation*} \begin{aligned} \text{LL}(\theta \mid D) &= \underbrace{\sum_{x} D\#(x)\log \theta_x}_{\textstyle S_1} \;+\; \underbrace{\sum_{x} \sum_z D\#(xz) \log M(z\mid x)}_{\textstyle S_2}. \end{aligned} \end{equation*}
The two groups are disjoint — \(S_1\) involves only \(\theta_x\), \(S_2\) only \(\theta_{y\mid x}, \theta_{z\mid y}\) — so they maximize independently. By Lemma 17.1 with the fixed \(\Pr_D(X)\) against the variable \(\theta_X\),
\begin{equation*} S_1 = N\sum_x \Pr_D(x)\log\theta_x \le N \sum_x \Pr_D(x)\log \Pr_D(x), \end{equation*}
with equality only for \(\theta_x = D\#(x)/N\). Grouping \(S_2\) by \(x\), with \(\Pr_D(z\mid x) = D\#(xz)/D\#(x)\),
\begin{equation*} S_2 = \sum_{x\,:\,D\#(x)>0} D\#(x) \sum_z \Pr_D(z\mid x)\log M(z\mid x). \end{equation*}
Each inner sum is again of Lemma 17.1’s form, so \(S_2 \le \sum_x D\#(x)\sum_z \Pr_D(z\mid x)\log\Pr_D(z\mid x)\) with equality iff \(M(z\mid x) = \Pr_D(z\mid x)\) for every \(x\) with \(D\#(x)>0\). That \(M\) is realizable by the chain: the realizable \(M\) are exactly the products
\begin{equation*} M = A B, \qquad A = [\theta_{y\mid x}]_{|X|\times|Y|}, \qquad B = [\theta_{z\mid y}]_{|Y|\times|Z|}, \end{equation*}
with \(A\) and \(B\) row-stochastic. Two cases realize \([\Pr_D(z\mid x)]\):
- (i) \(|Y| \ge |X|\): fix an injection \(x_j \mapsto y_j\), set \(\theta_{y_j\mid x_j}=1\) (all other entries of \(A\) zero, so \(A\) selects rows of \(B\)), and set row \(y_j\) of \(B\) to \(\Pr_D(\cdot \mid x_j)\), the leftover rows arbitrary.
- (ii) \(|Y|\ge|Z|\): fix an injection \(z_k \mapsto y_k\), set \(\theta_{z_k \mid y_k}=1\) (so \(B\) embeds \(Z\) into \(Y\)), and set \(A = [\Pr_D(z\mid x)]\) padded with zero columns.
Either way \(AB = [\Pr_D(z\mid x)]\) and the bound is attained. Combining the two bounds,
\begin{equation*} \text{LL}^{\max} = \sum_{x,z} D\#(xz) \log \frac{D\#(xz)}{N} = -N\,\text{ENT}_D(X,Z), \end{equation*}
attained exactly when \(\theta_x = D\#(x)/N\) and \(M(z\mid x) = \Pr_D(z\mid x)\), i.e. when \(\Pr_\theta(x,z) = D\#(xz)/N\).
For concrete estimates take \(|Y| \ge |X|\) and let \(Y\) be a deterministic copy of \(X\):
\begin{equation*} \theta_{y_j \mid x_j} = 1, \qquad \theta_{z\mid y_j} = \frac{D\#(x_j z)}{D\#(x_j)}, \qquad \theta_{x_j} = \frac{D\#(x_j)}{N}. \end{equation*}
Then
\begin{equation*} \Pr_\theta(x_j, z) = \frac{D\#(x_j)}{N}\cdot 1 \cdot \frac{D\#(x_j z)}{D\#(x_j)} = \frac{D\#(x_jz)}{N}, \end{equation*}
as required. For a numeric instance, let all three be binary with \(N = 10\) and counts
| \(X\) | \(Z\) | count |
|---|---|---|
| T | T | 4 |
| T | F | 1 |
| F | T | 2 |
| F | F | 3 |
Then the estimates are
| \(X\) | \(\theta_x\) |
|---|---|
| T | .5 |
| F | .5 |
| \(X\) | \(Y\) | \(\theta_{y\mid x}\) |
|---|---|---|
| T | T | 1 |
| T | F | 0 |
| F | T | 0 |
| F | F | 1 |
| \(Y\) | \(Z\) | \(\theta_{z\mid y}\) |
|---|---|---|
| T | T | .8 |
| T | F | .2 |
| F | T | .4 |
| F | F | .6 |
matching the empirical joint (Check!).
Consider the naive Bayes network structure of Figure 17.15: a single root node \(C\) with \(m\) children \(A_1, A_2, \dots, A_m\), so the edges are \(C \to A_i\) for \(i = 1,\dots,m\) and there are no other edges. Suppose that \(D\) is a data set of size \(N\) in which variable \(C\) is hidden and variables \(A_1,\dots,A_m\) are observed in all cases. Show that if EM is applied to this problem with parameters having uniform initial values, then it will converge in one step, returning the following estimates:
\begin{equation*} \theta_c = \frac{1}{|C|}, \qquad \theta_{a_i \mid c} = \frac{D\#(a_i)}{N}. \end{equation*}
Here \(|C|\) is the cardinality of variable \(C\), \(N\) is the size of the given data set, and \(D\#(a_i)\) is the number of cases in the data set that contain instantiation \(a_i\) of variable \(A_i\).
Uniform parameters make the posterior over the hidden class uniform in every case, which collapses both steps. With \(\theta^0_c = 1/|C|\), \(\theta^0_{a_i\mid c} = 1/|A_i|\) and a case \(d_j = a_1^j,\dots,a_m^j\) instantiating all attributes, the chain rule gives
\begin{equation*} \Pr_{\theta^0}(c, d_j) = \theta^0_c \prod_{i=1}^{m}\theta^0_{a_i^j \mid c} = \frac{1}{|C|}\prod_{i=1}^{m}\frac{1}{|A_i|}, \end{equation*}
independent of \(c\); summing over \(c\) gives \(\Pr_{\theta^0}(d_j) = \prod_i 1/|A_i| > 0\), so conditioning is legitimate and \(\Pr_{\theta^0}(c\mid d_j) = 1/|C|\) throughout. In the M-step (17.7) the root has empty parent set, so the denominator is \(N\):
\begin{equation*} \theta^1_c = \frac{\sum_{j=1}^{N}\Pr_{\theta^0}(c\mid d_j)}{N} = \frac{N \cdot \frac{1}{|C|}}{N} = \frac{1}{|C|}. \end{equation*}
Since \(A_i\) is observed in every case, \(d_j\) already determines it, so
\begin{equation*} \Pr_{\theta^0}(a_i c \mid d_j) = \begin{cases} \Pr_{\theta^0}(c\mid d_j) = \frac{1}{|C|}, & \text{if } d_j \models a_i, \\[2pt] 0, & \text{otherwise,} \end{cases} \end{equation*}
Hence
\begin{equation*} \begin{aligned} \theta^1_{a_i\mid c} &= \frac{\sum_j \Pr_{\theta^0}(a_i c\mid d_j)}{\sum_j \Pr_{\theta^0}(c\mid d_j)} = \frac{\sum_{j\,:\,d_j \models a_i} \frac{1}{|C|}}{\sum_{j=1}^{N}\frac{1}{|C|}} \\ &= \frac{\frac{1}{|C|}D\#(a_i)}{\frac{1}{|C|}N} = \frac{D\#(a_i)}{N} . \end{aligned} \end{equation*}
as claimed. Repeating the E-step at \(\theta^1\),
\begin{equation*} \Pr_{\theta^1}(c, d_j) = \frac{1}{|C|}\prod_{i=1}^{m}\frac{D\#(a_i^j)}{N}, \end{equation*}
again independent of \(c\), and positive because \(d_j\) contains \(a_i^j\), so \(D\#(a_i^j) \ge 1\). Thus \(\Pr_{\theta^1}(c\mid d_j) = 1/|C|\) once more, and since the M-step used the current parameters only through this uniform posterior, \(\theta^2 = \theta^1\).
Exercises 17.15–17.20
Consider the naive Bayes network structure in Figure 17.15 and let \(\Pr_\theta(\cdot)\) be the distribution induced by this structure and parametrization \(\theta\).
Figure 17.15 is the naive Bayes structure over variables \(C, A_1, \ldots, A_m\): node \(C\) is a root with no parents, and the only edges are \(C \to A_1\), \(C \to A_2\), \ldots, \(C \to A_m\). Thus the network has one CPT \(\Theta_C\) with parameters \(\theta_c\) and \(m\) CPTs \(\Theta_{A_i \mid C}\) with parameters \(\theta_{a_i \mid c}\).
Let us refer to variable \(C\) as the class variable, variables \(A_1, \ldots, A_m\) as the attributes, and each instantiation \(a_1, \ldots, a_m\) as an instance. Suppose that we now use this network as a classifier where we assign to each instance \(a_1, \ldots, a_m\) the class \(c\) that maximizes \(\Pr_\theta(c \mid a_1, \ldots, a_m)\). Show that when variable \(C\) is binary, the class of instance \(a_1, \ldots, a_m\) is \(c\) if
\begin{equation*} \log \theta_c + \sum_{i=1}^{m} \log \theta_{a_i \mid c} \;>\; \log \theta_{\bar c} + \sum_{i=1}^{m} \log \theta_{a_i \mid \bar c}. \end{equation*}
Note: This is known as a naive Bayes classifier.
The families of Figure 17.15 are \(C\) and \(A_iC\), so for the instance \(\alpha = a_1,\ldots,a_m\) the chain rule gives
\begin{equation*} \Pr_\theta(c, \alpha) = \theta_c \prod_{i=1}^{m}\theta_{a_i\mid c}, \qquad \Pr_\theta(\bar c, \alpha) = \theta_{\bar c} \prod_{i=1}^{m}\theta_{a_i\mid \bar c}. \end{equation*}
Since \(C\) is binary, \(\alpha\) is classified \(c\) exactly when \(\Pr_\theta(c\mid\alpha) > \Pr_\theta(\bar c\mid\alpha)\); multiplying through by the common normalizing constant \(\Pr_\theta(\alpha)\) (positive, else \(\alpha\) has no posterior) compares the two joints instead, and the strictly increasing \(\log\) gives
\begin{equation*} \log \theta_c + \sum_{i=1}^{m}\log\theta_{a_i\mid c} \;>\; \log \theta_{\bar c} + \sum_{i=1}^{m}\log\theta_{a_i\mid\bar c}, \end{equation*}
the stated rule. (With \(\log 0 = -\infty\) the equivalence survives zero parameters on one side.)
Consider Exercise 17.15 (the naive Bayes structure of Figure 17.15, with class variable \(C\) as the single root and attributes \(A_1, \ldots, A_m\) as its children). Let \(D\) be a complete data set that contains the cases \(c^i, a_1^i, \ldots, a_m^i\) for \(i = 1, \ldots, N\), and let \(\Pr_D(\cdot)\) be the empirical distribution induced by data set \(D\). Define the conditional log-likelihood function as
\begin{equation*} CLL(D \mid \theta) \;\stackrel{\text{def}}{=}\; \sum_{i=1}^{N} \log \Pr_\theta(c^i \mid a_1^i, \ldots, a_m^i). \end{equation*}
Define also the conditional KL divergence as
\begin{equation*} \sum_{a_1, \ldots, a_m} \Pr_D(a_1, \ldots, a_m) \cdot KL\bigl(\Pr_D(C \mid a_1, \ldots, a_m),\, \Pr_\theta(C \mid a_1, \ldots, a_m)\bigr). \end{equation*}
Show that a parametrization \(\theta\) maximizes the conditional log-likelihood function iff it minimizes the conditional KL divergence.
The two criteria differ by a constant: \(CLL(D\mid\theta) = -N(ENT_D(C\mid\mathbf A) + CKL(\theta))\), whose first term is free of \(\theta\).
Write \(\alpha\) for an instance and \(\mathbf A\) for \(A_1,\ldots,A_m\); sums range over \(\alpha\) with \(\Pr_D(\alpha) > 0\), where we may assume \(\Pr_\theta(\alpha) > 0\) (else \(CLL = -\infty\) and \(CKL = +\infty\), and both criteria reject \(\theta\)). Grouping the cases by the instantiation they realize, each contributing \(D\#(c,\alpha) = N\Pr_D(c,\alpha)\) identical terms,
\begin{equation*} \begin{aligned} CLL(D \mid \theta) &= \sum_{i=1}^{N} \log \Pr_\theta(c^i \mid \alpha^i) \\ &= N \sum_{c, \alpha} \Pr_D(c, \alpha) \log \Pr_\theta(c \mid \alpha) \\ &= N \sum_{\alpha} \Pr_D(\alpha) \sum_{c} \Pr_D(c \mid \alpha) \log \Pr_\theta(c \mid \alpha), \end{aligned} \end{equation*}
the last line by the chain rule for \(\Pr_D\). Expanding the KL divergence by its definition (Appendix B), splitting the logarithm of the ratio and weighting by \(\Pr_D(\alpha)\),
\begin{equation*} \begin{aligned} CKL(\theta) &\stackrel{\text{def}}{=} \sum_{\alpha} \Pr_D(\alpha)\, KL\bigl(\Pr_D(C \mid \alpha), \Pr_\theta(C \mid \alpha)\bigr) \\ &= \sum_{\alpha} \Pr_D(\alpha) \sum_{c} \Pr_D(c \mid \alpha) \log \Pr_D(c \mid \alpha) \\ &\quad - \sum_{\alpha} \Pr_D(\alpha) \sum_{c} \Pr_D(c \mid \alpha) \log \Pr_\theta(c \mid \alpha). \end{aligned} \end{equation*}
The first double sum is \(-ENT_D(C\mid\mathbf A)\) by definition; the second is \(CLL(D\mid\theta)/N\) by the display above. Hence
\begin{equation*} CLL(D \mid \theta) \;=\; -N \bigl( ENT_D(C \mid \mathbf{A}) + CKL(\theta) \bigr), \end{equation*}
affine in \(CKL(\theta)\) with negative slope \(-N\) and \(\theta\)-free intercept. So \(CLL(D\mid\theta) \ge CLL(D\mid\theta’)\) iff \(CKL(\theta) \le CKL(\theta’)\), and the maximizers of the one are the minimizers of the other.
Consider Exercise 17.16: the naive Bayes structure of Figure 17.15 with class variable \(C\) as the single root and attributes \(A_1, \ldots, A_m\) as its children, a complete data set \(D\) containing the cases \(c^i, a_1^i, \ldots, a_m^i\) for \(i = 1, \ldots, N\), and the conditional log-likelihood
\begin{equation*} CLL(D \mid \theta) = \sum_{i=1}^{N} \log \Pr_\theta(c^i \mid a_1^i, \ldots, a_m^i). \end{equation*}
Let \(D^{\prime}\) be an incomplete data set that is obtained from data set \(D\) by removing the values of class variable \(C\); that is, \(D^{\prime}\) contains the cases \(a_1^i, \ldots, a_m^i\) for \(i = 1, \ldots, N\). Show that
\begin{equation*} LL(D \mid \theta) \;=\; CLL(D \mid \theta) + LL(D^{\prime} \mid \theta). \end{equation*}
The identity is the chain rule \(\Pr_\theta(c^i,\alpha^i) = \Pr_\theta(c^i\mid\alpha^i)\Pr_\theta(\alpha^i)\), taken in logarithms and summed over cases.
Write \(\alpha^i\) for the instance \(a_1^i,\ldots,a_m^i\); case \(i\) of \(D\) is \(c^i,\alpha^i\), while case \(i\) of \(D’\) records only \(\alpha^i\), whose probability is the marginal \(\Pr_\theta(\alpha^i) = \sum_c \Pr_\theta(c,\alpha^i)\) (Section 17.3). Assuming \(\Pr_\theta(\alpha^i) > 0\) for every case,
\begin{equation*} \begin{aligned} LL(D \mid \theta) &= \sum_{i=1}^{N} \log \Pr_\theta(c^i, \alpha^i) \\ &= \sum_{i=1}^{N} \log \Pr_\theta(c^i \mid \alpha^i) \;+\; \sum_{i=1}^{N} \log \Pr_\theta(\alpha^i) \\ &= CLL(D \mid \theta) + LL(D^{\prime} \mid \theta), \end{aligned} \end{equation*}
as required. (If \(\Pr_\theta(\alpha^i) = 0\) for some case then \(\Pr_\theta(c^i,\alpha^i) = 0\) too, and the identity reads \(-\infty = -\infty + (-\infty)\) under the convention \(CLL(D\mid\theta) = -\infty\).)
Consider the structure in Figure 17.6(b) and a data set with a single case:
\begin{equation*} C = \text{no}, \qquad T = ?, \qquad I = \text{yes}. \end{equation*}
Figure 17.6(b) is the network structure that explicates a nonignorable missing-data mechanism for the medical example of Section 17.3.3. It has three nodes and two edges:
\begin{equation*} C \longrightarrow T \longrightarrow I . \end{equation*}
Here \(C\) is the medical condition with values yes and no, \(T\) is the test for that condition with values \(+ve\) and \(-ve\), and \(I\) is the missing-data indicator for \(T\) (Definition 17.4), with \(I = \text{yes}\) meaning that the value of \(T\) is missing from the data set. The parameter sets are \(\theta_{C}\), \(\theta_{T \mid C}\) and \(\theta_{I \mid T}\); in particular the missingness of the test result depends on the test result itself, which is why the mechanism is not MAR (Definition 17.5) and cannot be ignored.
Show that the ML estimates are characterized as follows:
- \(\theta_{C=\text{no}}\) is \(1\).
- One of the following must be true for the parameters of test \(T\) and missing-data indicator \(I\):
- \(\theta_{T=-ve \mid C=\text{no}} = 1\) and \(\theta_{I=\text{yes} \mid T=-ve} = 1\)
- \(\theta_{T=+ve \mid C=\text{no}} = 1\) and \(\theta_{I=\text{yes} \mid T=+ve} = 1\)
- \(\theta_{I=\text{yes} \mid T=-ve} = \theta_{I=\text{yes} \mid T=+ve} = 1\).
The likelihood is \(L(\theta\mid D) = \Pr_\theta(C = \text{no}, I = \text{yes})\), the single case recording \(C = \text{no}\) together with \(I = \text{yes}\) (that \(T\) is missing), and its maximum value is \(1\). Summing the unobserved \(T\) out of the structure \(C \to T \to I\),
\begin{equation*} \begin{aligned} L(\theta \mid D) &= \sum_{t} \Pr_\theta(C = \text{no},\, T = t,\, I = \text{yes}) \\ &= \sum_{t} \theta_{C=\text{no}} \cdot \theta_{T=t \mid C=\text{no}} \cdot \theta_{I=\text{yes} \mid T=t} \\ &= \theta_{C=\text{no}} \cdot \Bigl( \theta_{-ve \mid \text{no}}\, \theta_{\text{yes} \mid -ve} + \theta_{+ve \mid \text{no}}\, \theta_{\text{yes} \mid +ve} \Bigr), \end{aligned} \end{equation*}
abbreviating \(\theta_{t \mid \text{no}} = \theta_{T = t \mid C = \text{no}}\) and \(\theta_{\text{yes} \mid t} = \theta_{I = \text{yes} \mid T = t}\). Call the bracket \(S(\theta)\); it is a convex combination of \(\theta_{\text{yes}\mid -ve}, \theta_{\text{yes}\mid +ve} \in [0,1]\), so \(L(\theta\mid D) \le 1\) with the bound attained at \(\theta_{C=\text{no}} = \theta_{\text{yes}\mid -ve} = \theta_{\text{yes}\mid +ve} = 1\). Hence \(\theta\) is ML iff \(\theta_{C=\text{no}} = 1\) — the first bullet — and \(S(\theta) = 1\). Writing \(\lambda = \theta_{-ve\mid\text{no}}\), so that \(S(\theta) = \lambda\theta_{\text{yes}\mid -ve} + (1-\lambda)\theta_{\text{yes}\mid +ve} \le 1\), equality holds iff \(\lambda(1 - \theta_{\text{yes}\mid -ve}) = 0\) and \((1-\lambda)(1 - \theta_{\text{yes}\mid +ve}) = 0\), that is, iff \(\theta_{\text{yes}\mid t} = 1\) for every \(t\) with \(\theta_{t\mid\text{no}} > 0\):
- (i) \(\lambda = 1\): forces \(\theta_{I=\text{yes}\mid T=-ve} = 1\), the first listed alternative.
- (ii) \(\lambda = 0\): forces \(\theta_{I=\text{yes}\mid T=+ve} = 1\), the second alternative.
- (iii) \(0 < \lambda < 1\): forces both, the third alternative, with \(\theta_{T\mid C=\text{no}}\) unconstrained.
Conversely each case gives \(S(\theta) = 1\) (Check!), so with \(\theta_{C=\text{no}} = 1\) each attains \(L(\theta\mid D) = 1\).
Consider the data set \(D\) in Exercise 17.1 and the following network structures:
- \(G_1\): \(A \to B\), \(B \to C\), \(C \to D\), and \(A \to D\)
- \(G_2\): \(A \to B\), \(B \to C\), \(C \to D\), and \(B \to D\).
The data set \(D\) of Exercise 17.1 is the following complete data set over the binary variables \(A, B, C, D\) (values \(T\) and \(F\)):
| Case | A | B | C | D |
|---|---|---|---|---|
| 1 | T | F | F | F |
| 2 | T | F | F | T |
| 3 | F | F | T | F |
| 4 | T | T | F | T |
| 5 | F | F | T | T |
| 6 | F | T | T | F |
| 7 | F | T | T | T |
| 8 | T | F | F | T |
| 9 | F | F | T | F |
| 10 | T | T | T | T |
Which structure has a higher likelihood given \(D\)? What is the exact value for \(LL(G_1 \mid D) - LL(G_2 \mid D)\)?
\(G_1\) has the higher likelihood, by \(LL(G_1\mid D) - LL(G_2\mid D) = 15\log 3 - 5\log 5 - 12 \approx 0.165\) (logarithms base \(2\), \(N = 10\)).
By Theorem 17.3, \(LL(G\mid D) = -N\sum_{XU} ENT_D(X\mid U)\) over the families of \(G\), which are
\begin{equation*} \begin{aligned} G_1 &:\quad A,\; BA,\; CB,\; DCA, \\ G_2 &:\quad A,\; BA,\; CB,\; DCB . \end{aligned} \end{equation*}
They differ only in the family of \(D\), so all other entropy terms cancel and
\begin{equation*} LL(G_1 \mid D) - LL(G_2 \mid D) = -N\bigl( ENT_D(D \mid C, A) - ENT_D(D \mid C, B) \bigr), \end{equation*}
each family score computed from counts as \(-N\,ENT_D(X\mid U) = \sum_{xu} D\#(xu)\log\frac{D\#(xu)}{D\#(u)}\). For \(DCA\):
| C | A | \(D\#(C,A)\) | \(D=F\) | \(D=T\) | cases |
|---|---|---|---|---|---|
| F | T | 4 | 1 | 3 | 1, 2, 4, 8 |
| T | F | 5 | 3 | 2 | 3, 5, 6, 7, 9 |
| T | T | 1 | 0 | 1 | 10 |
| F | F | 0 | 0 | 0 | none |
(The instantiation \(C = F, A = F\) never occurs and contributes nothing, by Exercise 17.3.) Hence
\begin{equation*} \begin{aligned} -N \cdot ENT_D(D \mid C, A) &= 1\log \tfrac{1}{4} + 3\log \tfrac{3}{4}
- 3\log \tfrac{3}{5} + 2\log \tfrac{2}{5} + 1\log 1 \\ &= -2 + 3(\log 3 - 2) + 3(\log 3 - \log 5) + 2(1 - \log 5) \\ &= -6 + 6\log 3 - 5\log 5 . \end{aligned} \end{equation*}
For \(DCB\):
| C | B | \(D\#(C,B)\) | \(D=F\) | \(D=T\) | cases |
|---|---|---|---|---|---|
| F | F | 3 | 1 | 2 | 1, 2, 8 |
| F | T | 1 | 0 | 1 | 4 |
| T | F | 3 | 2 | 1 | 3, 5, 9 |
| T | T | 3 | 1 | 2 | 6, 7, 10 |
The three parent instantiations with three cases each split \(1\)–\(2\) or \(2\)–\(1\), so each contributes \(1\log\frac13 + 2\log\frac23\), while \(C = F, B = T\) contributes \(1\log 1 = 0\). Hence
\begin{equation*} \begin{aligned} -N \cdot ENT_D(D \mid C, B) &= 3\Bigl( 1\log \tfrac{1}{3} + 2\log \tfrac{2}{3} \Bigr) \\ &= 3\bigl( -\log 3 + 2(1 - \log 3) \bigr) \\ &= 6 - 9\log 3 . \end{aligned} \end{equation*}
Subtracting,
\begin{equation*} \begin{aligned} LL(G_1 \mid D) - LL(G_2 \mid D) &= \bigl( -6 + 6\log 3 - 5\log 5 \bigr) - \bigl( 6 - 9\log 3 \bigr) \\ &= 15 \log 3 - 5 \log 5 - 12 . \end{aligned} \end{equation*}
which is \(\log\frac{3^{15}}{5^5 \cdot 2^{12}} = \log\frac{14348907}{12800000} \approx 0.165 > 0\), so \(G_1\) wins.
Compute the MDL score for the network structure in Figure 17.10(c) given the data set in (17.11).
Figure 17.10(c) is the complete DAG over the four variables \(A, B, C, D\) obtained from the tree of Figure 17.10(a) by adding all remaining edges consistent with the variable order \(B, D, C, A\). Its edges are
\begin{equation*} B \to D, \quad B \to C, \quad B \to A, \quad D \to C, \quad D \to A, \quad C \to A, \end{equation*}
so the families are \(B\), \(DB\), \(CBD\) and \(ABCD\). All four variables are binary.
The data set (17.11) is the following complete data set of size \(N = 5\):
| Case | A | B | C | D |
|---|---|---|---|---|
| 1 | a1 | b1 | c2 | d1 |
| 2 | a1 | b1 | c2 | d2 |
| 3 | a1 | b2 | c1 | d1 |
| 4 | a2 | b1 | c1 | d2 |
| 5 | a1 | b1 | c2 | d2 |
Recall from (17.14) that the MDL score of a structure \(G\) given a data set \(D\) of size \(N\) is
\begin{equation*} MDL(G \mid D) \;=\; LL(G \mid D) - \frac{\log_2 N}{2} \, \lVert G \rVert , \end{equation*}
where \(\lVert G \rVert\) is the dimension of \(G\), that is, the number of independent network parameters.
\(MDL(G\mid D) = 2 - \tfrac{25}{2}\log_2 5 \approx -27.0\), from \(LL(G\mid D) = 2 - 5\log 5\) and \(\lVert G\rVert = 15\) at \(N = 5\) (logarithms base \(2\) throughout). By the definition of dimension,
\begin{equation*} \lVert G \rVert = \sum_{i} \lVert X_i \mathbf{U}_i \rVert, \qquad \lVert X_i \mathbf{U}_i \rVert = (X_i\# - 1)\,\mathbf{U}_i\# , \end{equation*}
where \(X_i\#\) and \(\mathbf{U}_i\#\) are the numbers of instantiations of \(X_i\) and of its parents \(\mathbf{U}_i\). With all four variables binary and families \(B\), \(DB\), \(CBD\), \(ABCD\):
| Family | Parents | \((X\# - 1)\) | \(\mathbf{U}\#\) | Dimension |
|---|---|---|---|---|
| \(B\) | none | 1 | 1 | 1 |
| \(DB\) | \(B\) | 1 | 2 | 2 |
| \(CBD\) | \(B,D\) | 1 | 4 | 4 |
| \(ABCD\) | \(B,C,D\) | 1 | 8 | 8 |
Hence \(\lVert G\rVert = 1 + 2 + 4 + 8 = 15\). Since \(G\) is a complete DAG its ML parametrization induces exactly \(\Pr_D\) (Exercise 17.8), so
\begin{equation*} LL(G \mid D) \;=\; \sum_{i=1}^{N} \log \Pr_D(d_i) \;=\; \sum_{\alpha} D\#(\alpha) \log \frac{D\#(\alpha)}{N}, \end{equation*}
\(\alpha\) ranging over complete instantiations. Cases \(2\) and \(5\) coincide, the rest are distinct:
| Instantiation | Count | \(\Pr_D\) |
|---|---|---|
| \(a1, b1, c2, d1\) | 1 | 1/5 |
| \(a1, b1, c2, d2\) | 2 | 2/5 |
| \(a1, b2, c1, d1\) | 1 | 1/5 |
| \(a2, b1, c1, d2\) | 1 | 1/5 |
Hence
\begin{equation*} \begin{aligned} LL(G \mid D) &= 3\log \tfrac{1}{5} + 2 \log \tfrac{2}{5} \\ &= -3\log 5 + 2\bigl(1 - \log 5\bigr) \\ &= 2 - 5\log 5 \;\approx\; 2 - 11.6096 \;=\; -9.61 . \end{aligned} \end{equation*}
Method (2): decomposing over the families of \(G\) by Theorem 17.3,
\begin{equation*} LL(G \mid D) = -N\bigl( ENT_D(B) + ENT_D(D \mid B) + ENT_D(C \mid B, D) + ENT_D(A \mid B, C, D) \bigr). \end{equation*}
Computing each term from counts:
- \(B\): \(b1\) occurs \(4\) times, \(b2\) once, so \(-N \cdot ENT_D(B) = 4\log\frac{4}{5} + \log\frac{1}{5} = 8 - 5\log 5 \approx -3.61\).
- \(D \mid B\): among the four \(b1\) cases, \(d1\) once and \(d2\) three times; the single \(b2\) case has \(d1\). So \(-N \cdot ENT_D(D \mid B) = \log\frac{1}{4} + 3\log\frac{3}{4} = -8 + 3\log 3 \approx -3.25\).
- \(C \mid B, D\): the only parent instantiation with more than one case is \(b1, d2\) (cases \(2, 4, 5\)), where \(c2\) occurs twice and \(c1\) once. So \(-N \cdot ENT_D(C \mid B, D) = 2\log\frac{2}{3} + \log\frac{1}{3} = 2 - 3\log 3 \approx -2.75\).
- \(A \mid B, C, D\): within every parent instantiation of \(A\) the value of \(A\) is constant (cases \(2\) and \(5\) agree completely), so all conditional probabilities are \(1\) and \(-N \cdot ENT_D(A \mid B, C, D) = 0\).
Adding, \(LL(G\mid D) = (8 - 5\log 5) + (-8 + 3\log 3) + (2 - 3\log 3) = 2 - 5\log 5\) as before. With penalty weight \(\tfrac{\log_2 5}{2} = 1.16096\),
\begin{equation*} \begin{aligned} MDL(G \mid D) &= LL(G \mid D) - \frac{\log_2 5}{2}\,\lVert G \rVert \\ &= \bigl(2 - 5\log_2 5\bigr) - \tfrac{15}{2}\log_2 5 \\ &= 2 - \tfrac{25}{2}\log_2 5 \\ &\approx -9.61 - 17.41 \\ &= -27.02 . \end{aligned} \end{equation*}
Against the other two structures of Figure 17.10, scored in Section 17.4.3:
| Structure | \(\lVert G \rVert\) | \(LL(G \mid D)\) | Penalty | MDL |
|---|---|---|---|---|
| (a) tree | 7 | -12.1 | 8.1 | -20.2 |
| (b) DAG with \(D \to A\) | 9 | -10.1 | 10.4 | -20.5 |
| (c) complete DAG | 15 | -9.6 | 17.4 | -27.0 |
The complete DAG has the largest log-likelihood, as Theorem 17.11 requires, and the worst MDL score.
Learning: The Bayesian Approach
Exercises 18.1–18.7
Consider the meta-network in Figure 18.2 and the corresponding data set \(D\).
The base network of Figure 18.1 has three binary variables: \(H\) (health aware), \(S\) (smokes), \(E\) (exercises regularly), with edges \(H \to S\) and \(H \to E\). The meta-network of Figure 18.2 is built from \(N\) instances of this structure, the \(i\)th instance containing \(H_i, S_i, E_i\) with edges \(H_i \to S_i\) and \(H_i \to E_i\). Three parameter-set nodes are added, namely \(\theta_H\), \(\theta_{S|\bar h}\) and \(\theta_{E|\bar h}\), together with the edges \(\theta_H \to H_i\), \(\theta_{S|\bar h} \to S_i\) and \(\theta_{E|\bar h} \to E_i\) for every \(i = 1, \dots, N\). The parameter sets \(\theta_{S|h}\) and \(\theta_{E|h}\) do not appear as nodes because their values are fixed.
The data set \(D\) is
| Case | \(H\) | \(S\) | \(E\) |
|---|---|---|---|
| 1 | F | F | T |
| 2 | T | F | T |
| 3 | T | F | T |
| 4 | F | F | F |
| 5 | F | T | F |
Assume the following fixed values of parameter sets:
\begin{equation*} \theta_{S|h} = (.1, .9), \qquad \theta_{E|h} = (.8, .2). \end{equation*}
For the remaining sets, suppose that we have the following prior distributions:
| \(\theta_H = (\theta_h, \theta_{\bar h})\) | \(P(\theta_H)\) |
|---|---|
| \((.75, .25)\) | 80% |
| \((.90, .10)\) | 20% |
| \(\theta_{S\vert\bar h} = (\theta_{s\vert\bar h}, \theta_{\bar s\vert\bar h})\) | \(P(\theta_{S\vert\bar h})\) |
|---|---|
| \((.25, .75)\) | 10% |
| \((.50, .50)\) | 90% |
| \(\theta_{E\vert\bar h} = (\theta_{e\vert\bar h}, \theta_{\bar e\vert\bar h})\) | \(P(\theta_{E\vert\bar h})\) |
|---|---|
| \((.50, .50)\) | 35% |
| \((.75, .25)\) | 65% |
Compute the following given the data set \(D\):
- (a) The maximum likelihood parameter estimates.
- (b) The MAP parameter estimates.
- (c) The Bayesian parameter estimates.
Compute the probability of observing an individual who is a smoker and exercises regularly given each of the above parameter estimates. Compute also \(P(S_6 = s, E_6 = e \mid D)\) with respect to the meta-network.
Since \(D\) is complete, the likelihood (18.7), the prior (18.5) and the posterior (18.6) all factorize over the free parameter sets \(\theta_H\), \(\theta_{S|\bar h}\), \(\theta_{E|\bar h}\), each of which is therefore maximized on its own; \(\theta_{S|h}\) and \(\theta_{E|h}\) are fixed and play no part. The counts are (writing \(h\) for \(H = T\), \(s\) for \(S = T\), \(e\) for \(E = T\))
\begin{equation*} \begin{aligned} D\#(h) &= 2, & D\#(\bar h) &= 3,\\ D\#(s,\bar h) &= 1, & D\#(\bar s,\bar h) &= 2,\\ D\#(e,\bar h) &= 1, & D\#(\bar e,\bar h) &= 2. \end{aligned} \end{equation*}
(a) Each set maximizes its own likelihood factor \(\prod_x \theta_{x|u}^{D\#(xu)}\):
\begin{equation*} \begin{aligned} \theta_H &: \ (.75)^2(.25)^3 = .0087890625 \;>\; (.90)^2(.10)^3 = .00081,\\ \theta_{S|\bar h} &: \ (.25)(.75)^2 = .140625 \;>\; (.50)(.50)^2 = .125,\\ \theta_{E|\bar h} &: \ (.50)(.50)^2 = .125 \;>\; (.75)(.25)^2 = .046875, \end{aligned} \end{equation*}
so \(\theta^{ml}\) takes \(\theta_H = (.75,.25)\), \(\theta_{S|\bar h} = (.25,.75)\) and \(\theta_{E|\bar h} = (.50,.50)\).
(b) By Theorem 18.4 each posterior is proportional to prior times the factor above:
\begin{equation*} \begin{aligned} \theta_H &: \ .80(.0087890625) = .00703125 \;>\; .20(.00081) = .000162,\\ \theta_{S|\bar h} &: \ .10(.140625) = .0140625 \;<\; .90(.125) = .1125,\\ \theta_{E|\bar h} &: \ .35(.125) = .04375 \;>\; .65(.046875) = .03046875, \end{aligned} \end{equation*}
so \(\theta^{ma}\) takes \(\theta_H = (.75,.25)\), \(\theta_{S|\bar h} = (.50,.50)\) and \(\theta_{E|\bar h} = (.50,.50)\), the prior having flipped \(\theta_{S|\bar h}\) relative to maximum likelihood.
(c) Normalizing those three lists gives the posteriors of Theorem 18.4,
\begin{equation*} \begin{aligned} P(\theta_H = (.75,.25) \mid D) &= \tfrac{3125}{3197} \approx 97.75\%,\\ P(\theta_{S|\bar h} = (.25,.75) \mid D) &= \tfrac{1}{9} \approx 11.11\%,\\ P(\theta_{E|\bar h} = (.50,.50) \mid D) &= \tfrac{56}{95} \approx 58.95\%, \end{aligned} \end{equation*}
the alternatives taking the complements, and the Bayesian estimates are their expectations (Definition 18.3):
\begin{equation*} \begin{aligned} \theta^{be}_{h} &= .75 \times \tfrac{3125}{3197} + .90 \times \tfrac{72}{3197} \approx .7534,\\ \theta^{be}_{s|\bar h} &= .25 \times \tfrac{1}{9} + .50 \times \tfrac{8}{9} = \tfrac{17}{36} \approx .4722,\\ \theta^{be}_{e|\bar h} &= .50 \times \tfrac{56}{95} + .75 \times \tfrac{39}{95} = \tfrac{229}{380} \approx .6026, \end{aligned} \end{equation*}
with \(\theta^{be}_{\bar h} \approx .2466\), \(\theta^{be}_{\bar s|\bar h} \approx .5278\), \(\theta^{be}_{\bar e|\bar h} \approx .3974\), and the fixed sets keeping their values (their posteriors being point masses).
In the base network \(S \leftarrow H \to E\) we have \(\mathit{Pr}_\theta(s,e) = \theta_h \theta_{s|h} \theta_{e|h} + \theta_{\bar h}\theta_{s|\bar h}\theta_{e|\bar h}\), with \(\theta_{s|h} = .1\) and \(\theta_{e|h} = .8\) throughout, so
\begin{equation*} \begin{aligned} \mathit{Pr}_{\theta^{ml}}(s,e) &= (.75)(.1)(.8) + (.25)(.25)(.50) = .09125,\\ \mathit{Pr}_{\theta^{ma}}(s,e) &= (.75)(.1)(.8) + (.25)(.50)(.50) = .1225,\\ \mathit{Pr}_{\theta^{be}}(s,e) &\approx (.7534)(.1)(.8)
- (.2466)(.4722)(.6026) \approx .13045 . \end{aligned} \end{equation*}
The data set being complete, Theorem 18.3 with \(\alpha\) the event \(S = s, E = e\) gives
\begin{equation*} P(S_6 = s, E_6 = e \mid D) = \mathit{Pr}_{\theta^{be}}(s,e) \approx 13.05\% , \end{equation*}
which is what summing \(\mathit{Pr}_\theta(s,e) P(\theta \mid D)\) over the eight parametrizations, as Theorem 18.2 prescribes, returns as well.
Consider a network structure \(A \to B\) where variables \(A\) and \(B\) are binary, with values \(a_1, a_2\) and \(b_1, b_2\). Suppose that we have the following priors on parameter sets:
| \(\theta_A = (\theta_{a_1}, \theta_{a_2})\) | \(P(\theta_A)\) |
|---|---|
| \((.80, .20)\) | 70% |
| \((.20, .80)\) | 30% |
| \(\theta_{B\vert a_1} = (\theta_{b_1\vert a_1}, \theta_{b_2\vert a_1})\) | \(P(\theta_{B\vert a_1})\) |
|---|---|
| \((.90, .10)\) | 50% |
| \((.10, .90)\) | 50% |
| \(\theta_{B\vert a_2} = (\theta_{b_1\vert a_2}, \theta_{b_2\vert a_2})\) | \(P(\theta_{B\vert a_2})\) |
|---|---|
| \((.95, .05)\) | 60% |
| \((.05, .95)\) | 40% |
Compute the posterior distributions of parameter sets given the data set
| \(D\) | \(A\) | \(B\) |
|---|---|---|
| \(d_1\) | \(a_1\) | \(b_2\) |
| \(d_2\) | \(a_1\) | \(b_2\) |
| \(d_3\) | \(a_1\) | \(b_1\) |
| \(d_4\) | \(a_2\) | \(b_2\) |
Compute also the expected parameter values given this data set. Finally, evaluate the query \(P(A_5 = a_1 \mid B_5 = b_2, D)\).
The data set is complete, so Theorem 18.1 gives parameter independence given \(D\) and Theorem 18.4 gives each posterior in closed form,
\begin{equation*} P(\theta_{X|u} \mid D) = \eta \, P(\theta_{X|u}) \prod_x \theta_{x|u}^{D\#(xu)} . \end{equation*}
With counts \(D\#(a_1) = 3\), \(D\#(a_2) = 1\), \(D\#(b_1 a_1) = 1\), \(D\#(b_2 a_1) = 2\), \(D\#(b_1 a_2) = 0\) and \(D\#(b_2 a_2) = 1\), prior times likelihood term gives
\begin{equation*} \begin{aligned} \theta_A &: \ .70(.80)^3(.20) = .07168, \quad .30(.20)^3(.80) = .00192,\\ \theta_{B|a_1} &: \ .50(.90)(.10)^2 = .0045, \quad .50(.10)(.90)^2 = .0405,\\ \theta_{B|a_2} &: \ .60(.05) = .03, \quad .40(.95) = .38, \end{aligned} \end{equation*}
and normalizing by \(.0736\), \(.045\) and \(.41\) respectively,
\begin{equation*} \begin{aligned} P(\theta_A = (.80,.20) \mid D) &= \tfrac{112}{115} \approx 97.39\%, & P(\theta_A = (.20,.80) \mid D) &= \tfrac{3}{115},\\ P(\theta_{B|a_1} = (.90,.10) \mid D) &= 10\%, & P(\theta_{B|a_1} = (.10,.90) \mid D) &= 90\%,\\ P(\theta_{B|a_2} = (.95,.05) \mid D) &= \tfrac{3}{41}, & P(\theta_{B|a_2} = (.05,.95) \mid D) &= \tfrac{38}{41}, \end{aligned} \end{equation*}
the joint posterior being the product of the three (Theorem 18.1). The expected parameter values are the Bayesian estimates of Definition 18.3:
\begin{equation*} \begin{aligned} \theta^{be}_{a_1} &= .80 \times \tfrac{112}{115} + .20 \times \tfrac{3}{115} = \tfrac{451}{575} \approx .7843,\\ \theta^{be}_{b_1|a_1} &= .90 \times .10 + .10 \times .90 = .18,\\ \theta^{be}_{b_1|a_2} &= .95 \times \tfrac{3}{41} + .05 \times \tfrac{38}{41} = \tfrac{19}{164} \approx .1159, \end{aligned} \end{equation*}
with \(\theta^{be}_{a_2} = \tfrac{124}{575}\), \(\theta^{be}_{b_2|a_1} = .82\) and \(\theta^{be}_{b_2|a_2} = \tfrac{145}{164}\). Completeness of \(D\) lets Theorem 18.3, in the conditional form of Exercise 18.7, answer the query by inference on the base network \(A \to B\) at \(\theta^{be}\):
\begin{equation*} \begin{aligned} P(A_5 = a_1 \mid B_5 = b_2, D) &= \mathit{Pr}_{\theta^{be}}(a_1 \mid b_2) = \frac{\theta^{be}_{a_1}\theta^{be}_{b_2|a_1}} {\theta^{be}_{a_1}\theta^{be}_{b_2|a_1} + \theta^{be}_{a_2}\theta^{be}_{b_2|a_2}}\\ &= \frac{.64317}{.64317 + .19066} = \tfrac{758131}{982881} \approx 77.13\% . \end{aligned} \end{equation*}
Consider Exercise 18.2, which concerns the network structure \(A \to B\) with binary variables \(A\) (values \(a_1, a_2\)) and \(B\) (values \(b_1, b_2\)), and the parameter sets
\begin{equation*} \begin{aligned} \theta_A &\in \{(.80,.20), (.20,.80)\},\\ \theta_{B|a_1} &\in \{(.90,.10), (.10,.90)\},\\ \theta_{B|a_2} &\in \{(.95,.05), (.05,.95)\}. \end{aligned} \end{equation*}
Describe a meta-network that captures the following constraint
\begin{equation*} \theta_{B|a_1} = (.90,.10) \ \text{ iff } \ \theta_{B|a_2} = (.05,.95). \end{equation*}
Add the single edge \(\theta_{B|a_1} \to \theta_{B|a_2}\) to the meta-network of Exercise 18.2 and make \(\theta_{B|a_2}\) a deterministic function of its parent. A meta-network as given by Definition 18.2 cannot express the constraint — its parameter-set nodes are all roots, hence mutually independent (Theorem 18.1) — but Section 18.2.3 permits exactly this relaxation.
So keep the instance variables \(A_i \to B_i\) and the edges \(\theta_A \to A_i\), \(\theta_{B|a_1} \to B_i\), \(\theta_{B|a_2} \to B_i\) for \(i = 1,\dots,N\); the node \(\theta_{B|a_1}\) retains its prior and \(\theta_{B|a_2}\) gets the CPT
| \(\theta_{B\vert a_1}\) | \(\theta_{B\vert a_2}\) | \(P(\theta_{B\vert a_2} \mid \theta_{B\vert a_1})\) |
|---|---|---|
| \((.90,.10)\) | \((.95,.05)\) | 0 |
| \((.90,.10)\) | \((.05,.95)\) | 1 |
| \((.10,.90)\) | \((.95,.05)\) | 1 |
| \((.10,.90)\) | \((.05,.95)\) | 0 |
whose two zero rows encode the “only if” and the “if” halves of the biconditional. The rest, including the instance CPTs (18.1), is unchanged: \(P(B_i \mid A_i = a_k, \theta_{B|a_1}, \theta_{B|a_2}) = \theta_{B|a_k}\).
The priors of Exercise 18.2 cannot both survive: the constraint forces \(P(\theta_{B|a_1} = (.90,.10)) = P(\theta_{B|a_2} = (.05,.95))\), which the given \(50\%\) and \(40\%\) violate. Keeping \(P(\theta_{B|a_1}) = (50\%,50\%)\) induces \(P(\theta_{B|a_2} = (.05,.95)) = 50\%\).
Method (2): introduce a binary root \(T\) with \(T \to \theta_{B|a_1}\) and \(T \to \theta_{B|a_2}\), where \(T = t\) stands for the hypothesis “\(\theta_{B|a_1} = (.90,.10)\) and \(\theta_{B|a_2} = (.05,.95)\)” and \(T = \bar t\) for its complement, both CPTs being deterministic:
\begin{equation*} \begin{aligned} P(\theta_{B|a_1} = (.90,.10) \mid t) &= 1, & P(\theta_{B|a_1} = (.10,.90) \mid \bar t) &= 1,\\ P(\theta_{B|a_2} = (.05,.95) \mid t) &= 1, & P(\theta_{B|a_2} = (.95,.05) \mid \bar t) &= 1. \end{aligned} \end{equation*}
Both dependencies being functional, this is the same distribution as before with \(P(t) = P(\theta_{B|a_1} = (.90,.10))\).
Consider a Bayesian network structure with three binary variables \(A\), \(B\), and \(C\) and two edges \(A \to B\) and \(A \to C\). Suppose that the CPTs for variables \(B\) and \(C\) are equal and these CPTs are independent of the one for variable \(A\). Draw the structure of a meta-network for this situation. Develop a closed form for computing the posterior distribution on parameter set \(\theta_{B|a_1}\) given a complete data set \(D\). Assume first that parameter sets are discrete, deriving a closed form that resembles Equation 18.4. Then generalize the form to continuous parameter sets with Dirichlet distributions.
Here Equation 18.4 is the statement of Theorem 18.4: for a discrete parameter set \(\theta_{X|u}\) and a complete data set \(D\),
\begin{equation*} P(\theta_{X|u} \mid D) = \eta \, P(\theta_{X|u}) \prod_x \theta_{x|u}^{D\#(xu)} , \end{equation*}
where \(\eta\) is a normalizing constant.
Tying the two CPTs pools the counts of the two children, and the closed form becomes
\begin{equation*} P(\theta_{B|a_1} \mid D) = \eta \, P(\theta_{B|a_1}) \prod_{j} \theta_{b_j|a_1}^{\,D\#(b_j a_1) + D\#(c_j a_1)} , \end{equation*}
that is, (18.4) with \(D\#(b\,a_1)\) replaced by the pooled count \(M\#(b\,a_1)\) defined below. Here \(b_j \leftrightarrow c_j\) is the correspondence under which the two CPTs are equal, so that the assumption reads \(\theta_{c_j|a_k} = \theta_{b_j|a_k}\) and the model has three distinct parameter sets, not five: \(\theta_A\), \(\theta_{B|a_1}\), \(\theta_{B|a_2}\), the last two doing double duty as the parameters of \(C\).
The meta-network is \(N\) instances \(A_i \to B_i\), \(A_i \to C_i\) beneath three parameter roots, with edges
\begin{equation*} \theta_A \to A_i, \qquad \theta_{B|a_1} \to B_i,\ \theta_{B|a_1} \to C_i, \qquad \theta_{B|a_2} \to B_i,\ \theta_{B|a_2} \to C_i \end{equation*}
for \(i = 1,\dots,N\), so every \(B_i\) and every \(C_i\) has the three parents \(A_i\), \(\theta_{B|a_1}\), \(\theta_{B|a_2}\). This departs from Definition 18.2 in one respect only, one parameter node per parent instantiation feeding both children instead of separate nodes for the families \(B \mid A\) and \(C \mid A\); every parameter node is still a root. The instance CPTs follow (18.1) with the shared sets, \(P(B_i \mid A_i = a_k, \theta) = P(C_i \mid A_i = a_k, \theta) = \theta_{B|a_k}\), the vector \(\theta_{B|a_k}\) read in the second case as assigning \(\theta_{b_j|a_k}\) to \(C_i = c_j\).
Parameter independence survives: instantiating every \(A_i, B_i, C_i\) to its value in \(D\) prunes the edges out of each observed \(A_i\) (Section 6.9.2) and makes \(\theta_{B|a_k} \to B_i\), \(\theta_{B|a_k} \to C_i\) prunable whenever \(A_i \ne a_k\), leaving \(\theta_A\), \(\theta_{B|a_1}\), \(\theta_{B|a_2}\) with no common neighbours, hence pairwise d-separated by the evidence, so \(P(\theta \mid D)\) factorizes as in Theorem 18.1.
For the closed form, let \(D\) be complete of size \(N\) with cases \(d_i = (a^i, b^i, c^i)\). By (18.7), and since every factor \(\theta_{c^i|a^i}\) is again one of the \(\theta_{b_j|a_k}\),
\begin{equation*} \begin{aligned} P(D \mid \theta) &= \prod_{i=1}^{N} \theta_{a^i} \, \theta_{b^i | a^i} \, \theta_{c^i | a^i} = \prod_{k} \theta_{a_k}^{D\#(a_k)} \ \prod_{k} \prod_{j} \theta_{b_j|a_k}^{\,M\#(b_j a_k)}, \end{aligned} \end{equation*}
where \(M\#(b_j a_k) \overset{\text{def}}{=} D\#(b_j a_k) + D\#(c_j a_k)\) counts both children’s observations of the shared distribution for parent value \(a_k\); note \(\sum_j M\#(b_j a_k) = 2 D\#(a_k)\). Multiplying by the factorized prior \(P(\theta_A)P(\theta_{B|a_1})P(\theta_{B|a_2})\) and summing out \(\theta_A\) and \(\theta_{B|a_2}\) leaves the marginal displayed at the outset; \(\theta_{B|a_2}\) obeys the same form, \(\theta_A\) obeys (18.4) unchanged.
For continuous sets, a Dirichlet prior \(\rho(\theta_{B|a_1}) = \eta_0 \prod_b \theta_{b|a_1}^{\,\psi_{b|a_1} - 1}\) (Definition 18.5) meets the same likelihood factor, which does not depend on discreteness, so
\begin{equation*} \begin{aligned} \rho(\theta_{B|a_1} \mid D) &= \eta \, \rho(\theta_{B|a_1}) \prod_b \theta_{b|a_1}^{\,M\#(b\,a_1)} = \eta^{\prime} \prod_b \theta_{b|a_1}^{\,\psi_{b|a_1} + M\#(b\,a_1) - 1} , \end{aligned} \end{equation*}
again Dirichlet, with exponents \(\psi^{\prime}_{b_j|a_1} = \psi_{b_j|a_1} + D\#(b_j a_1) + D\#(c_j a_1)\) — the analogue of (18.15) in Theorem 18.9 with pooled counts — and equivalent sample size \(\psi^{\prime}_{B|a_1} = \psi_{B|a_1} + 2 D\#(a_1)\). The Dirichlet expectation (18.10) then gives the analogue of (18.16),
\begin{equation*} \theta^{be}_{b_j|a_1} = \frac{\psi_{b_j|a_1} + D\#(b_j\,a_1) + D\#(c_j\,a_1)} {\psi_{B|a_1} + 2\,D\#(a_1)} . \end{equation*}
Consider a meta-network as given by Definition 18.2. Let \(\Sigma\) contain \(X_N\) for every variable \(X\) in structure \(G\) and let \(\Gamma\) contain \(X_1, \dots, X_{N-1}\) for every variable \(X\) in structure \(G\). Show that \(\Sigma\) is d-separated from \(\Gamma\) by the nodes representing parameter sets.
Recall Definition 18.2: a meta-network of size \(N\) for structure \(G\) is constructed from \(N\) instances of \(G\), with variable \(X\) of \(G\) appearing as \(X_i\) in the \(i\)th instance; and for every variable \(X\) of \(G\) and parent instantiation \(u\), the meta-network contains a node \(\theta_{X|u}\) together with the edges \(\theta_{X|u} \to X_1, \dots, \theta_{X|u} \to X_N\).
Every path between \(\Sigma\) and \(\Gamma\) passes through a parameter node as a divergent valve, which the set \(\Theta\) of all parameter-set nodes \(\theta_{X|u}\) closes.
By Definition 18.2 the meta-network’s nodes split into \(\Theta\) and the instance sets \(V_i = \{X_i : X \text{ a variable of } G\}\), and its edges are of two kinds only: intra-instance edges \(U_i \to X_i\), one for each edge \(U \to X\) of \(G\) and each \(i\), and parameter edges \(\theta_{X|u} \to X_i\). Hence no edge joins \(V_i\) to \(V_j\) for \(i \ne j\).
Let \(P\) be a path (a sequence of distinct nodes, consecutive ones adjacent in either direction) from \(X_N \in \Sigma \subseteq V_N\) to \(Y_j \in \Gamma \subseteq V_j\) with \(j < N\), and let \(W\) be the first node on \(P\) outside \(V_N\), which exists because \(Y_j \notin V_N\). Its predecessor lies in \(V_N\), so \(W\) is adjacent to a node of \(V_N\) and is therefore no instance node at all: \(W \in \Theta\). Nor is \(W\) an endpoint, the endpoints lying in \(\Sigma\) and \(\Gamma\), which are disjoint from \(\Theta\); so \(P\) contains a subpath \(W^{\prime} \leftarrow W \to W^{\prime\prime}\), both edges directed away from \(W\) because Definition 18.2 gives a parameter node only outgoing edges. This divergent valve is closed by \(W \in \Theta\), so \(P\) is blocked, and as \(P\) was arbitrary,
\begin{equation*} d\text{-}sep(\Sigma, \Theta, \Gamma) \end{equation*}
holds; by soundness of d-separation, \(\Sigma\) and \(\Gamma\) are independent given \(\Theta\).
Consider Theorem 18.2 and show that \(\mathit{Pr}_\theta(\alpha) = P(\alpha_i \mid \theta)\), where \(\alpha_i\) results from replacing every variable \(X\) in \(\alpha\) by its instance \(X_i\).
Here \(P\) is the meta-distribution induced by a meta-network as given by Definition 18.2, \(\theta\) is an instantiation of all its parameter-set nodes (a parametrization of the base structure \(G\)), and \(\mathit{Pr}_\theta\) is the base distribution induced by \(G\) under \(\theta\). Theorem 18.2 states that, given discrete parameter sets and a data set \(D\) of size \(N\),
\begin{equation*} P(\alpha_{N+1} \mid D) = \sum_\theta \mathit{Pr}_\theta(\alpha) P(\theta \mid D). \end{equation*}
Given \(\theta\), the \(N\) instances are independent copies of the base network, so instance \(i\) carries exactly the distribution \(\mathit{Pr}_\theta\).
Fix \(\theta\) with \(P(\theta) > 0\), and for an instantiation \(\mathbf x\) of \(G\)’s variables \(X^{(1)},\dots,X^{(n)}\) write \(\mathbf x^i\) for the corresponding instantiation of \(V_i = \{X^{(1)}_i,\dots,X^{(n)}_i\}\); the map \(\mathbf x \mapsto \mathbf x^i\) is a bijection. The meta-network is a Bayesian network, so by the chain rule (Chapter 3),
\begin{equation*} P(\theta, \mathbf{x}^1, \dots, \mathbf{x}^N) = \Big[\prod_{X, u} P(\theta_{X|u})\Big] \prod_{i=1}^{N} \prod_{X} P(x_i \mid u_i, \theta), \end{equation*}
with \(x_i\) and \(u_i\) the values of \(X_i\) and its instance parents in \(\mathbf x^i\). The bracketed factor is \(P(\theta)\), the parameter nodes being roots, and \(P(x_i \mid u_i, \theta) = \theta_{x|u}\) by the semantics (18.1) of instance CPTs, so dividing by \(P(\theta)\),
\begin{equation*} P(\mathbf{x}^1, \dots, \mathbf{x}^N \mid \theta) = \prod_{i=1}^{N} \prod_{X} \theta_{x|u} = \prod_{i=1}^{N} \mathit{Pr}_\theta(\mathbf{x}^i), \end{equation*}
the last equality being the chain rule for the base network \((G, \theta)\). Summing out the instances other than \(i\),
\begin{equation*} \begin{aligned} P(\mathbf{x}^i \mid \theta) &= \mathit{Pr}_\theta(\mathbf{x}^i) \prod_{j \ne i} \Big[ \sum_{\mathbf{x}^j} \mathit{Pr}_\theta(\mathbf{x}^j) \Big] = \mathit{Pr}_\theta(\mathbf{x}^i), \end{aligned} \end{equation*}
each bracketed sum being \(1\). Finally, the substitution \(X \mapsto X_i\) is uniform and commutes with the Boolean connectives, so \(\mathbf{x} \models \alpha\) iff \(\mathbf{x}^i \models \alpha_i\), and
\begin{equation*} \begin{aligned} P(\alpha_i \mid \theta) &= \sum_{\mathbf{x}^i \models \alpha_i} P(\mathbf{x}^i \mid \theta) = \sum_{\mathbf{x} \models \alpha} \mathit{Pr}_\theta(\mathbf{x}) = \mathit{Pr}_\theta(\alpha). \end{aligned} \end{equation*}
Consider Theorem 18.3 and show that
\begin{equation*} P(\alpha_{N+1} \mid \beta_{N+1}, D) = \mathit{Pr}_{\theta^{be}}(\alpha \mid \beta). \end{equation*}
Theorem 18.3 states that, given discrete parameter sets and a complete data set \(D\) of size \(N\),
\begin{equation*} P(\gamma_{N+1} \mid D) = \mathit{Pr}_{\theta^{be}}(\gamma), \end{equation*}
where \(\gamma_{N+1}\) is obtained from the event \(\gamma\) by replacing every variable \(X\) by its instance \(X_{N+1}\), and \(\theta^{be}\) are the Bayesian estimates of Definition 18.3 given \(D\).
The substitution \(X \mapsto X_{N+1}\) leaves the Boolean structure of a sentence untouched, so \((\alpha \wedge \beta)_{N+1} = \alpha_{N+1} \wedge \beta_{N+1}\), with \(\alpha \wedge \beta\) again an event over the base variables. The data set \(D\) is complete, the hypothesis of Theorem 18.3, so applying (18.3) first with \(\gamma = \alpha \wedge \beta\) and then with \(\gamma = \beta\),
\begin{equation*} \begin{aligned} P(\alpha_{N+1} \mid \beta_{N+1}, D) &= \frac{P\big((\alpha \wedge \beta)_{N+1} \mid D\big)}{P(\beta_{N+1} \mid D)} = \frac{\mathit{Pr}_{\theta^{be}}(\alpha \wedge \beta)} {\mathit{Pr}_{\theta^{be}}(\beta)}\\ &= \mathit{Pr}_{\theta^{be}}(\alpha \mid \beta), \end{aligned} \end{equation*}
as required; the standing assumption \(P(\beta_{N+1} \mid D) > 0\) makes the left side defined, and equals \(\mathit{Pr}_{\theta^{be}}(\beta)\) by the second application, so the right side is defined too.
Exercises 18.8–18.14
Consider Theorem 18.2 and show that
\begin{equation*} P(\alpha_{N+1} \mid \beta_{N+1}, D) = \sum_{\theta} \mathit{Pr}_{\theta}(\alpha \mid \beta)\, P(\theta \mid \beta_{N+1}, D). \end{equation*}
Here the meta-network is the one of Definition 18.2: it contains a node for every discrete parameter set \(\theta_{X\mid u}\) of the base structure \(G\), together with \(N+1\) instances \(X_1,\dots,X_{N+1}\) of each base variable \(X\) and the edges \(\theta_{X\mid u} \to X_i\); the data set \(D\) of size \(N\) is asserted as evidence on instances \(1,\dots,N\). As in Theorem 18.2, the event \(\alpha_{N+1}\) is obtained from the base-network event \(\alpha\) by replacing every occurrence of a variable \(X\) by its instance \(X_{N+1}\), and similarly for \(\beta_{N+1}\). Assume \(P(\beta_{N+1} \mid \theta) > 0\) for every parametrization \(\theta\) with \(P(\theta \mid D) > 0\).
Case analysis on \(\theta\) (the parametrizations are mutually exclusive and exhaustive) gives
\begin{equation*} P(\alpha_{N+1} \mid \beta_{N+1}, D) = \sum_{\theta} P(\alpha_{N+1} \mid \beta_{N+1}, D, \theta)\, P(\theta \mid \beta_{N+1}, D), \end{equation*}
so it suffices that \(P(\alpha_{N+1} \mid \beta_{N+1}, D, \theta) = \mathit{Pr}_{\theta}(\alpha\mid\beta)\).
(i) The data drop out. With \(\Delta\) the instance-\((N+1)\) variables, \(\Gamma\) those of instances \(1,\dots,N\), and \(\Theta\) the parameter nodes, Exercise 18.5 gives \(d\text{-}sep(\Delta,\Theta,\Gamma)\) – the edges \(\theta_{X\mid u} \to X_i\) are the only ones joining instances, each a diverging valve at a root closed by instantiating \(\Theta\) – hence \(I_{P}(\Delta,\Theta,\Gamma)\) by soundness of d-separation (Theorem 4.2). Applying it to \(\alpha_{N+1}\wedge\beta_{N+1}\) and to \(\beta_{N+1}\), both events over \(\Delta\) while \(D\) is over \(\Gamma\), and dividing, \(P(\alpha_{N+1}\mid\beta_{N+1},D,\theta) = P(\alpha_{N+1}\mid\beta_{N+1},\theta)\).
(ii) Instance \(N+1\) is the base network \((G,\theta)\). Exercise 18.6 gives \(P(\gamma_{N+1}\mid\theta) = \mathit{Pr}_{\theta}(\gamma)\), and \(\gamma \mapsto \gamma_{N+1}\) is a renaming, so \((\alpha\wedge\beta)_{N+1} = \alpha_{N+1}\wedge\beta_{N+1}\) and
\begin{equation*} P(\alpha_{N+1} \mid \beta_{N+1}, \theta) = \frac{\mathit{Pr}_{\theta}(\alpha \wedge \beta)} {\mathit{Pr}_{\theta}(\beta)} = \mathit{Pr}_{\theta}(\alpha \mid \beta), \end{equation*}
the division legitimate since \(P(\beta_{N+1}\mid\theta) > 0\) by assumption.
Consider Theorem 18.4. Show that
\begin{equation*} P(D \mid \theta_{X\mid u}) \;\propto\; \prod_{x} \left(\theta_{x\mid u}\right)^{D\#(xu)} . \end{equation*}
Here \(\theta_{X\mid u}\) is a discrete parameter set of the base structure, \(D\) is a complete data set of size \(N\), and \(D\#(xu)\) is the number of cases in \(D\) that contain the family instantiation \(xu\) (Definition 17.1). Theorem 18.4 states that
\begin{equation*} P(\theta_{X\mid u} \mid D) = \eta\, P(\theta_{X\mid u}) \prod_{x} \left(\theta_{x\mid u}\right)^{D\#(xu)}, \end{equation*}
where \(\eta\) is a normalizing constant. The proportionality to be shown is with respect to \(\theta_{X\mid u}\): the omitted constant may depend on \(D\) but not on the value of the parameter set.
Read Theorem 18.4 backwards through Bayes rule. Fix \(\theta_{X\mid u}\) with \(P(\theta_{X\mid u}) > 0\) (a zero prior leaves \(P(D\mid\theta_{X\mid u})\) undefined); equating Bayes rule with Theorem 18.4 and cancelling the nonzero prior,
\begin{equation*} P(D \mid \theta_{X\mid u}) = \eta\, P(D) \prod_{x} \left(\theta_{x\mid u}\right)^{D\#(xu)} , \end{equation*}
and both \(\eta\) and \(P(D)\) are fixed by \(D\) alone.
Method (2): directly, exhibiting the constant. By the pruning argument in the proof of Theorem 18.4 (\(D\) complete, so every instance node is instantiated), what remains around \(\theta_{X\mid u}\) is an isolated naive Bayes structure with root \(\theta_{X\mid u}\) and children \(X_i\), \(i \in I = \{i : u \sim d_i\}\). Split \(D = D_1 D_2\) with \(D_1\) the instantiation of those \(X_i\); the children are independent given the root and each has CPT \(\theta_{X\mid u}\) under \(u\), so collecting the \(D\#(xu)\) indices whose value is \(x\),
\begin{equation*} P(D_1 \mid \theta_{X\mid u}) = \prod_{i \in I} \theta_{x_i \mid u} = \prod_{x} \left(\theta_{x\mid u}\right)^{D\#(xu)} . \end{equation*}
The same pruning gives \(P(\theta_{X\mid u}\mid D) = P(\theta_{X\mid u}\mid D_1)\), equivalently \(P(D_2 \mid D_1, \theta_{X\mid u}) = P(D_2\mid D_1)\), whence \(P(D\mid\theta_{X\mid u}) = P(D_2\mid D_1)\prod_x (\theta_{x\mid u})^{D\#(xu)}\) with \(P(D_2\mid D_1) = P(D)/P(D_1)\) free of \(\theta_{X\mid u}\).
Prove Equation 18.9. That is, let \(D = d_1,\dots,d_N\) be a (possibly incomplete) data set and let \(\theta^{k}\) be a parametrization of the base structure \(G\). Definition 18.4 defines the expected count of an event \(\alpha\) over base-network variables as
\begin{equation*} D\#(\alpha \mid \theta^{k}) \;\overset{\text{def}}{=}\; \sum_{D^{c}} \Big[ [D D^{c}]\#(\alpha) \Big]\, P(D^{c} \mid D, \theta^{k}), \end{equation*}
where \(D^{c}\) ranges over the completions of \(D\), each assigning values to exactly those variables that have missing values in \(D\), so that \(D D^{c}\) is a complete data set, and \([D D^{c}]\#(\alpha)\) is the count of \(\alpha\) in that complete data set in the sense of Definition 17.1. Show that
\begin{equation*} D\#(\alpha \mid \theta^{k}) = \sum_{i=1}^{N} \mathit{Pr}_{\theta^{k}}(\alpha \mid d_i) . \tag{18.9} \end{equation*}
Unfold the count into indicators; the exchanged sum is a posterior. Write \(\alpha_i\) for \(\alpha\) with each base variable \(X\) replaced by \(X_i\), and \(d^{c}_i\) for the part of \(D^{c}\) filling case \(i\). Since \(D D^{c}\) has the same \(N\) cases, the \(i\)-th being the complete instantiation \(d_i d^{c}_i\), Definition 17.1 gives \([D D^{c}]\#(\alpha) = \sum_{i} \mathbf{1}[\, d_i d^{c}_i \models \alpha \,]\), so exchanging the two finite sums,
\begin{equation*} D\#(\alpha \mid \theta^{k}) = \sum_{i=1}^{N} \sum_{D^{c}} \mathbf{1}\big[\, d_i d^{c}_i \models \alpha \,\big]\, P(D^{c} \mid D, \theta^{k}) = \sum_{i=1}^{N} P(\alpha_i \mid D, \theta^{k}) , \end{equation*}
the inner sum collapsing because the completions are mutually exclusive and exhaustive and each \(D D^{c}\) decides \(\alpha_i\). Two reductions finish it.
(i) With \(\Delta_i\) the instance variables of case \(i\) and \(\Gamma_i\) those of the cases \(j \ne i\), Exercise 18.5 gives \(d\text{-}sep(\Delta_i,\Theta,\Gamma_i)\) – the edges \(\theta_{X\mid u}\to X_j\) are the only ones joining instances, each a diverging valve at a root – so by Theorem 4.2 and \(D = d_i D_{-i}\), \(P(\alpha_i\mid D,\theta^{k}) = P(\alpha_i\mid d_i,\theta^{k})\).
(ii) Exercise 18.6 gives \(P(\gamma_i\mid\theta^{k}) = \mathit{Pr}_{\theta^{k}}(\gamma)\); applying it to \(\alpha\wedge d_i\) and to \(d_i\) and dividing,
\begin{equation*} P(\alpha_i \mid d_i, \theta^{k}) = \frac{\mathit{Pr}_{\theta^{k}}(\alpha \wedge d_i)}{\mathit{Pr}_{\theta^{k}}(d_i)} = \mathit{Pr}_{\theta^{k}}(\alpha \mid d_i), \end{equation*}
the denominator positive because Definition 18.4 presupposes \(P(D\mid\theta^{k}) > 0\), which Equation 18.7 factors as \(\prod_j \mathit{Pr}_{\theta^{k}}(d_j)\).
Prove Equation 18.27, which appears on Page 514. That is, consider a network structure with families \(XU\), continuous parameter sets with prior Dirichlet densities of exponents \(\psi_{x\mid u}\) and equivalent sample sizes \(\psi_{X\mid u} = \sum_{x} \psi_{x\mid u}\), and a complete data set \(D = d_1,\dots,d_N\). Write \(D_i = d_1,\dots,d_i\) (so \(D_0\) is empty and \(D_N = D\)). The proof of Theorem 18.12 uses Equations 18.14 and 18.16 with the chain rule of Bayesian networks to obtain
\begin{equation*} P(d_i \mid D_{i-1}) = \prod_{xu \sim d_i} \frac{\psi_{x\mid u} + D_{i-1}\#(xu)} {\psi_{X\mid u} + D_{i-1}\#(u)}, \end{equation*}
and then the chain rule of probability calculus to obtain
\begin{equation*} P(D) = \prod_{i=1}^{N} P(d_i \mid D_{i-1}) = \prod_{i=1}^{N} \prod_{xu \sim d_i} \frac{\psi_{x\mid u} + D_{i-1}\#(xu)} {\psi_{X\mid u} + D_{i-1}\#(u)} . \end{equation*}
Show that rearranging the terms of this expression gives
\begin{equation*} P(D) = \prod_{XU} \prod_{u} \frac{\prod_{x} (\psi_{x\mid u})(\psi_{x\mid u}+1)\cdots (\psi_{x\mid u} + D\#(xu) - 1)} {(\psi_{X\mid u})(\psi_{X\mid u}+1)\cdots (\psi_{X\mid u} + D\#(u) - 1)} . \tag{18.27} \end{equation*}
Here \(xu \sim d_i\) means that the family instantiation \(xu\) is compatible with case \(d_i\), and an empty product (when a count is zero) equals \(1\).
Pure reindexing: all factors are positive reals and the products finite, so they may be reordered freely. Because \(D\) is complete, each family \(XU\) has exactly one instantiation \(x_i u_i\) compatible with \(d_i\), and the parent instantiations \(u\) partition the cases, so
\begin{equation*} P(D) = \prod_{XU} \; \prod_{u} \;\prod_{i \,:\, u \sim d_i} \frac{\psi_{x_i \mid u} + D_{i-1}\#(x_i u)} {\psi_{X\mid u} + D_{i-1}\#(u)} . \end{equation*}
Fix \(XU\) and \(u\).
(i) Denominators. Let \(k_1 < \cdots < k_n\) enumerate the indices with \(u \sim d_i\), so \(n = D\#(u)\); the cases among \(d_1,\dots,d_{k_j-1}\) compatible with \(u\) are exactly \(k_1,\dots,k_{j-1}\), whence \(D_{k_j-1}\#(u) = j-1\) and
\begin{equation*} \prod_{i \,:\, u \sim d_i} \big(\psi_{X\mid u} + D_{i-1}\#(u)\big) = \prod_{j=0}^{D\#(u)-1} \big(\psi_{X\mid u} + j\big) . \end{equation*}
(ii) Numerators. Partition those cases further by the value \(x_i\) of \(X\); for fixed \(x\) the same argument gives \(D_{i_\ell-1}\#(xu) = \ell-1\) along the indices \(i_1 < \cdots < i_{D\#(xu)}\) with \(xu \sim d_i\), so
\begin{equation*} \prod_{i \,:\, u \sim d_i} \big(\psi_{x_i \mid u} + D_{i-1}\#(x_i u)\big) = \prod_{x} \prod_{\ell=0}^{D\#(xu)-1} \big(\psi_{x\mid u} + \ell\big) . \end{equation*}
Both leaves use the empty-product convention when the count is \(0\) (Check!), and dividing (ii) by (i) then multiplying over \(u\) and \(XU\) gives (18.27). Since \(\Gamma(a+k)/\Gamma(a) = a(a+1)\cdots(a+k-1)\) for \(a>0\) and integer \(k \ge 0\) (induction from \(\Gamma(a+1) = a\Gamma(a)\)), this is Equation 18.21.
Let \(D\) be an incomplete data set and let \(D^{c}\) denote a completion of \(D\), that is, an instantiation of exactly those variables that have missing values in \(D\), so that \(D D^{c}\) is a complete data set. Show that the expected value of a network parameter \(\theta_{x\mid u}\) given data set \(D\) is
\begin{equation*} \mathit{Ex}(\theta_{x\mid u}) = \sum_{D^{c}} f(D D^{c})\, P(D^{c} \mid D), \end{equation*}
where \(f(D D^{c})\) is the value of the Bayesian estimate \(\theta^{be}_{x\mid u}\) given the complete data set \(D D^{c}\).
Case analysis of the posterior on the completions does it, the completions being mutually exclusive and exhaustive since they instantiate exactly the missing variables.
(i) Discrete parameter sets. Definition 18.3 makes \(\mathit{Ex}(\theta_{x\mid u}) = \sum_{\theta_{X\mid u}} \theta_{x\mid u}\, P(\theta_{X\mid u}\mid D)\); with \(P(\theta_{X\mid u}\mid D) = \sum_{D^{c}} P(\theta_{X\mid u}\mid D D^{c})P(D^{c}\mid D)\) (Section 18.3.3) and the two finite sums exchanged,
\begin{equation*} \mathit{Ex}(\theta_{x\mid u}) = \sum_{D^{c}} P(D^{c} \mid D) \sum_{\theta_{X\mid u}} \theta_{x\mid u}\, P(\theta_{X\mid u} \mid D D^{c}) , \end{equation*}
whose inner sum is Definition 18.3 for \(D D^{c}\), that is \(f(D D^{c})\).
(ii) Continuous parameter sets. Definition 18.6 makes \(\mathit{Ex}(\theta_{x\mid u}) = \int \theta_{x\mid u}\, \rho(\theta_{X\mid u}\mid D)\, d\theta_{X\mid u}\), and Section 18.4.6 gives the same case analysis for densities, \(\rho(\theta_{X\mid u}\mid D) = \sum_{D^{c}} \rho(\theta_{X\mid u}\mid D D^{c})P(D^{c}\mid D)\); the sum is finite, so it exchanges with the integral and
\begin{equation*} \mathit{Ex}(\theta_{x\mid u}) = \sum_{D^{c}} P(D^{c} \mid D) \int \theta_{x\mid u}\, \rho(\theta_{X\mid u} \mid D D^{c})\, d\theta_{X\mid u} = \sum_{D^{c}} f(D D^{c})\, P(D^{c} \mid D), \end{equation*}
the inner integral being Definition 18.6 for \(D D^{c}\).
Consider a network structure \(A \to B\) where variables \(A\) and \(B\) are binary, with values \(a_1, a_2\) and \(b_1, b_2\) respectively, and the Dirichlet priors are given by the following exponents:
| \(\psi_{a_1}\) | \(\psi_{a_2}\) | \(\psi_{b_1\mid a_1}\) | \(\psi_{b_2\mid a_1}\) | \(\psi_{b_1\mid a_2}\) | \(\psi_{b_2\mid a_2}\) |
|---|---|---|---|---|---|
| 10 | 30 | 2 | 2 | 10 | 40 |
Suppose that we are given the following data set \(D\):
| A | B | |
|---|---|---|
| \(d_1\) | \(a_1\) | \(b_2\) |
| \(d_2\) | \(a_1\) | \(b_1\) |
| \(d_3\) | \(a_2\) | \(b_1\) |
Compute:
- (a) The Bayesian parameter estimates \(\theta^{be}_{a_1}\), \(\theta^{be}_{b_1\mid a_1}\), and \(\theta^{be}_{b_1\mid a_2}\).
- (b) The marginal likelihood \(P(D)\).
\(\theta^{be}_{a_1} = 12/43\), \(\theta^{be}_{b_1\mid a_1} = 1/2\), \(\theta^{be}_{b_1\mid a_2} = 11/51\), and \(P(D) = 11/5740\). The data set is complete, so part (a) is Equation 18.16 and part (b) is Theorem 18.12.
Counts. The families are \(A\) (trivial parent instantiation \(\top\)) and \(B\mid A\) (parent instantiations \(a_1, a_2\)):
| event | count |
|---|---|
| \(\top\) | 3 |
| \(a_1\) | 2 |
| \(a_2\) | 1 |
| \(b_1 a_1\) | 1 |
| \(b_2 a_1\) | 1 |
| \(b_1 a_2\) | 1 |
| \(b_2 a_2\) | 0 |
with equivalent sample sizes \(\psi_{A} = 10 + 30 = 40\), \(\psi_{B\mid a_1} = 4\) and \(\psi_{B\mid a_2} = 50\).
(a) Equation 18.16, \(\theta^{be}_{x\mid u} = (\psi_{x\mid u} + D\#(xu))/(\psi_{X\mid u} + D\#(u))\), gives
\begin{equation*} \begin{aligned} \theta^{be}_{a_1} &= \frac{10 + 2}{40 + 3} = \frac{12}{43} \approx 0.2791, \\ \theta^{be}_{b_1 \mid a_1} &= \frac{2 + 1}{4 + 2} = \frac{1}{2}, \\ \theta^{be}_{b_1 \mid a_2} &= \frac{10 + 1}{50 + 1} = \frac{11}{51} \approx 0.2157 . \end{aligned} \end{equation*}
(b) Theorem 18.12 contributes one factor per family and parent instantiation, each Gamma ratio being the rising product \(\Gamma(a+k)/\Gamma(a) = a(a+1)\cdots(a+k-1)\) of Exercise 18.11:
\begin{equation*} \begin{aligned} A &: \frac{\Gamma(40)}{\Gamma(43)} \frac{\Gamma(12)}{\Gamma(10)} \frac{\Gamma(31)}{\Gamma(30)} = \frac{(10)(11)(30)}{(40)(41)(42)} = \frac{55}{1148}, \\ B\mid a_1 &: \frac{\Gamma(4)}{\Gamma(6)} \frac{\Gamma(3)}{\Gamma(2)} \frac{\Gamma(3)}{\Gamma(2)} = \frac{(2)(2)}{(4)(5)} = \frac{1}{5}, \\ B\mid a_2 &: \frac{\Gamma(50)}{\Gamma(51)} \frac{\Gamma(11)}{\Gamma(10)} \frac{\Gamma(40)}{\Gamma(40)} = \frac{10}{50} = \frac{1}{5}, \end{aligned} \end{equation*}
the last ratio the empty product \(1\) because \(D\#(b_2a_2) = 0\). Multiplying, \(P(D) = \tfrac{55}{1148}\cdot\tfrac15\cdot\tfrac15 = \tfrac{11}{5740} \approx 0.0019164\).
Method (2) for (b): the chain rule with Theorem 18.8 (Equation 18.14), each factor \(P(d_i\mid D_{i-1}) = \mathit{Pr}_{\theta^{be}_i}(d_i)\) evaluated from the earlier cases by Equation 18.16 – \(P(d_1) = \tfrac{10}{40}\cdot\tfrac{2}{4} = \tfrac18\), \(P(d_2\mid d_1) = \tfrac{11}{41}\cdot\tfrac{2}{5} = \tfrac{22}{205}\), \(P(d_3\mid d_1d_2) = \tfrac{30}{42}\cdot\tfrac{10}{50} = \tfrac17\) – whose product is again \(11/5740\).
Consider the network structure \(A \to B\) and the Dirichlet priors from Exercise 18.13. That is, \(A\) and \(B\) are binary with values \(a_1,a_2\) and \(b_1,b_2\), the only edge is \(A \to B\), and the prior exponents are
| \(\psi_{a_1}\) | \(\psi_{a_2}\) | \(\psi_{b_1\mid a_1}\) | \(\psi_{b_2\mid a_1}\) | \(\psi_{b_1\mid a_2}\) | \(\psi_{b_2\mid a_2}\) |
|---|---|---|---|---|---|
| 10 | 30 | 2 | 2 | 10 | 40 |
Compute the expected values of parameters \(\theta_{a_1}\), \(\theta_{b_1\mid a_1}\), and \(\theta_{b_1\mid a_2}\) given the following data set:
| A | B | |
|---|---|---|
| \(d_1\) | \(a_1\) | \(b_2\) |
| \(d_2\) | ? | \(b_1\) |
| \(d_3\) | \(a_2\) | ? |
Hint: perform case analysis on the missing values in the data set.
\(\mathit{Ex}(\theta_{a_1}) = 605/2279\), \(\mathit{Ex}(\theta_{b_1\mid a_1}) = 117/265\), and \(\mathit{Ex}(\theta_{b_1\mid a_2}) = 2827/13515\). By Exercise 18.12,
\begin{equation*} \mathit{Ex}(\theta_{x\mid u}) = \sum_{D^{c}} f(D D^{c})\, P(D^{c} \mid D), \qquad P(D^{c} \mid D) = \frac{P(D D^{c})}{\sum_{D^{c}} P(D D^{c})}, \end{equation*}
with \(f\) given by Equation 18.16 and each \(P(D D^{c})\) a complete-data marginal likelihood from Theorem 18.12, as in Exercise 18.13; the denominator is \(P(D)\) because the four completions are mutually exclusive and exhaustive.
The four completed data sets and their counts.
| comp. | \(A_2\) | \(B_3\) | \(\#a_1\) | \(\#a_2\) | \(\#b_1a_1\) | \(\#b_2a_1\) | \(\#b_1a_2\) | \(\#b_2a_2\) |
|---|---|---|---|---|---|---|---|---|
| \(D^{c}_1\) | \(a_1\) | \(b_1\) | 2 | 1 | 1 | 1 | 1 | 0 |
| \(D^{c}_2\) | \(a_1\) | \(b_2\) | 2 | 1 | 1 | 1 | 0 | 1 |
| \(D^{c}_3\) | \(a_2\) | \(b_1\) | 1 | 2 | 0 | 1 | 2 | 0 |
| \(D^{c}_4\) | \(a_2\) | \(b_2\) | 1 | 2 | 0 | 1 | 1 | 1 |
Marginal likelihoods. With \(\psi_A = 40\), \(\psi_{B\mid a_1} = 4\), \(\psi_{B\mid a_2} = 50\) and each Gamma ratio a rising product (Exercise 18.11), the family \(A\) factor depends only on \((\#a_1,\#a_2)\):
\begin{equation*} \frac{(10)(11)\,(30)}{(40)(41)(42)} = \frac{55}{1148} \;\;\text{at } (2,1), \qquad \frac{(10)\,(30)(31)}{(40)(41)(42)} = \frac{155}{1148} \;\;\text{at } (1,2). \end{equation*}
The \(B\mid a_1\) factor is \(\tfrac{(2)(2)}{(4)(5)} = \tfrac{1}{5}\) when \(\#a_1=2\) with one case of each value of \(B\), and \(\tfrac{2}{4} = \tfrac{1}{2}\) when \(\#a_1=1\) with that case \(b_2\); the \(B\mid a_2\) factor is
\begin{equation*} \frac{10}{50} = \frac{1}{5},\quad \frac{40}{50} = \frac{4}{5},\quad \frac{(10)(11)}{(50)(51)} = \frac{11}{255},\quad \frac{(10)(40)}{(50)(51)} = \frac{8}{51} \end{equation*}
for \(D^{c}_1,\dots,D^{c}_4\) respectively. Multiplying,
| completion | \(A\) factor | \(B\mid a_1\) | \(B\mid a_2\) | \(P(D D^{c})\) | value |
|---|---|---|---|---|---|
| \(D^{c}_1\) | \(55/1148\) | \(1/5\) | \(1/5\) | \(11/5740\) | \(0.0019164\) |
| \(D^{c}_2\) | \(55/1148\) | \(1/5\) | \(4/5\) | \(11/1435\) | \(0.0076655\) |
| \(D^{c}_3\) | \(155/1148\) | \(1/2\) | \(11/255\) | \(341/117096\) | \(0.0029121\) |
| \(D^{c}_4\) | \(155/1148\) | \(1/2\) | \(8/51\) | \(155/14637\) | \(0.0105896\) |
Summing gives the marginal likelihood of the incomplete data set,
\begin{equation*} P(D) = \frac{11}{5740} + \frac{11}{1435} + \frac{341}{117096} + \frac{155}{14637} = \frac{53}{2296} \approx 0.0230836 , \end{equation*}
and dividing each row by it gives the posterior over completions. Put over the common denominator \(13515 = 5 \cdot 51 \cdot 53\):
\begin{equation*} \begin{aligned} P(D^{c}_1 \mid D) &= \tfrac{1122}{13515} = \tfrac{22}{265} \approx 0.08302, \\ P(D^{c}_2 \mid D) &= \tfrac{4488}{13515} = \tfrac{88}{265} \approx 0.33208, \\ P(D^{c}_3 \mid D) &= \tfrac{1705}{13515} = \tfrac{341}{2703} \approx 0.12616, \\ P(D^{c}_4 \mid D) &= \tfrac{6200}{13515} = \tfrac{1240}{2703} \approx 0.45875, \end{aligned} \end{equation*}
Complete-data estimates. By Equation 18.16, with \(D\#(\top) = 3\) throughout:
| comp. | \(\theta_{a_1}\) | \(\theta_{b_1\mid a_1}\) | \(\theta_{b_1\mid a_2}\) |
|---|---|---|---|
| \(D^{c}_1\) | \(12/43\) | \(3/6 = 1/2\) | \(11/51\) |
| \(D^{c}_2\) | \(12/43\) | \(3/6 = 1/2\) | \(10/51\) |
| \(D^{c}_3\) | \(11/43\) | \(2/5\) | \(12/52 = 3/13\) |
| \(D^{c}_4\) | \(11/43\) | \(2/5\) | \(11/52\) |
The entries are \((10+\#a_1)/43\), \((2+\#b_1a_1)/(4+\#a_1)\), and \((10+\#b_1a_2)/(50+\#a_2)\) with the counts from the previous table (Check!).
The expectations. Averaging each column against the posterior over completions:
\begin{equation*} \begin{aligned} \mathit{Ex}(\theta_{a_1}) &= \frac{12}{43}\cdot\frac{1122 + 4488}{13515}
- \frac{11}{43}\cdot\frac{1705 + 6200}{13515} \\ &= \frac{12 \cdot 5610 + 11 \cdot 7905}{43 \cdot 13515} = \frac{154275}{581145} = \frac{605}{2279} \approx 0.26547 . \end{aligned} \end{equation*}
\begin{equation*} \begin{aligned} \mathit{Ex}(\theta_{b_1\mid a_1}) &= \frac{1}{2}\cdot\frac{5610}{13515}
- \frac{2}{5}\cdot\frac{7905}{13515} \\ &= \frac{2805 + 3162}{13515} = \frac{5967}{13515} = \frac{117}{265} \approx 0.44151 . \end{aligned} \end{equation*}
\begin{equation*} \begin{aligned} \mathit{Ex}(\theta_{b_1\mid a_2}) &= \frac{11}{51}\cdot\frac{1122}{13515}
- \frac{10}{51}\cdot\frac{4488}{13515} \\ &\quad {}+ \frac{3}{13}\cdot\frac{1705}{13515}
- \frac{11}{52}\cdot\frac{6200}{13515} \\
&= \frac{1}{13515}\left(242 + 880
- \frac{5115}{13} + \frac{17050}{13}\right) \\ &= \frac{1}{13515}\left(242 + 880 + \frac{22165}{13}\right) \\ &= \frac{242 + 880 + 1705}{13515} = \frac{2827}{13515} \approx 0.20917 . \end{aligned} \end{equation*}
Exercises 18.15–18.21
Consider a meta-network that induces a meta-distribution \(P\), let \(D\) be an incomplete data set, and let \(\theta\) be a parametrization. Describe a Gibbs sampler that can be used for estimating the expectation of \(P(\theta \mid D, D_c)\) with respect to the distribution \(P(D_c \mid D)\), where \(D_c\) is a completion of the data set \(D\). That is, describe a Gibbs-Markov chain for the distribution \(P(C \mid D)\), where \(C\) are the variables with missing values in \(D\), and then show how we can simulate this chain. Solve this problem for both discrete and continuous parameter sets.
Recall the setting of Definition 18.2: the meta-network for a base structure \(G\) with families \(XU\) contains a root node \(\theta_{X|u}\) for every family \(XU\) and every parent instantiation \(u\), together with \(N\) copies (slices) of the base network, the \(i\)-th slice containing a node \(X_i\) for every base variable \(X\). The parents of \(X_i\) are \(U_i\) together with the parameter sets \(\theta_{X|u}\), and \(P(x_i \mid u_i, \theta_{X|u_i}) = \theta_{x|u_i}\). A case \(d_i\) of \(D\) is a partial instantiation of the slice-\(i\) variables, and a completion \(D_c\) assigns values to exactly the variables that are missing in \(D\).
Run a collapsed Gibbs chain whose state is \(C\) alone, with \(\theta\) marginalized out. An instantiation \(c\) of \(C = C^1,\dots,C^m\), the variables missing in \(D\), is exactly a completion \(D_c\), so \(P(C\mid D)\) and \(P(D_c\mid D)\) are one distribution and the target \(P(\theta\mid D) = \sum_{D_c} P(\theta\mid D,D_c)P(D_c\mid D)\) is an expectation under it.
The chain. One sweep visits each \(C^j\) in turn and redraws it from \(P(C^j \mid D, c^{-j})\), \(c^{-j} = c \setminus c^j\) – the Gibbs construction of Chapter 15 applied to the meta-network under evidence \(D\). Each single-variable update is reversible with respect to \(P(C\mid D)\), so the sweep leaves \(P(C\mid D)\) invariant; the chain is ergodic once every such conditional is positive, automatic under Dirichlet priors since \(\psi_{x|u}\ge 1\) makes the density positive on the interior of the simplex.
Simulating it. Since \(C^j\) is a single base variable, \(P(C^j = z \mid D, c^{-j}) = \eta\, P(D\, c^{-j}\, z)\) with \(\eta\) normalizing over the values \(z\) and \(D\,c^{-j}z\) complete. So only complete-data marginal likelihoods are needed, and for complete data the parameter sets decouple (Theorem 18.1, by the pruning of Figure 18.3), giving:
- discrete parameter sets, from \(P(\theta) = \prod_{XU}\prod_u P(\theta_{X|u})\) (18.5) and \(P(D_c\mid\theta) = \prod_{xu}\theta_{x|u}^{\,D_c\#(xu)}\) (Exercise 18.9),
\begin{equation*} P(D_c) \;=\; \prod_{XU} \prod_{u} \Bigl(\, \sum_{\theta_{X|u}} P(\theta_{X|u}) \prod_{x} \theta_{x|u}^{\,D_c\#(xu)} \Bigr); \end{equation*}
- continuous parameter sets with Dirichlet priors (Definition 18.5), the closed form (18.21),
\begin{equation*} P(D_c) \;=\; \prod_{XU} \prod_{u} \frac{\Gamma(\psi_{X|u})}{\Gamma\bigl(\psi_{X|u} + D_c\#(u)\bigr)} \prod_{x} \frac{\Gamma\bigl(\psi_{x|u} + D_c\#(xu)\bigr)}{\Gamma(\psi_{x|u})}. \end{equation*}
Only ratios across \(z\) are needed, and flipping one missing \(X_i\) moves only the counts of the family \(XU\) and of the families of the children of \(X\), by \(\pm 1\), so with \(\Gamma(z+1) = z\Gamma(z)\) everything else cancels: writing \(\hat{D}\) for the complete data set with \(X_i\) removed from all counts and \(v_i(z)\) for the parent instantiation of \(Y_i\) when \(X_i = z\),
\begin{equation*} P\bigl(X_i = z \mid D, c^{-j}\bigr) \;=\; \eta \cdot \frac{\psi_{z|u_i} + \hat{D}\#(z u_i)}{\psi_{X|u_i} + \hat{D}\#(u_i)} \prod_{Y \in \mathrm{ch}(X)} \frac{\psi_{y_i|v_i(z)} + \hat{D}\#\bigl(y_i\, v_i(z)\bigr)} {\psi_{Y|v_i(z)} + \hat{D}\#\bigl(v_i(z)\bigr)}, \end{equation*}
at cost \(O(|X| \cdot |\mathrm{ch}(X)|)\) per variable.
The estimator. Discard a burn-in prefix, collect \(c^{(1)},\dots,c^{(T)}\), and take \(P(\theta\mid D) \approx \frac1T \sum_t P(\theta \mid D, c^{(t)})\), each term closed-form because \(D\,c^{(t)}\) is complete: Theorems 18.1 and 18.4 give
\begin{equation*} P\bigl(\theta \mid D\,c^{(t)}\bigr) = \prod_{XU}\prod_{u} \eta\, P(\theta_{X|u}) \prod_x \theta_{x|u}^{\,D\,c^{(t)}\#(xu)} \end{equation*}
in the discrete case, and Theorem 18.9 makes each continuous factor Dirichlet with exponents \(\psi_{x|u} + D\,c^{(t)}\#(xu)\):
\begin{equation*} \rho(\theta \mid D) \;\approx\; \frac{1}{T}\sum_{t=1}^{T} \prod_{XU}\prod_{u} \rho_{\mathrm{Dir}}\Bigl(\theta_{X|u} \,;\, \bigl\{\psi_{x|u} + D\,c^{(t)}\#(xu)\bigr\}_x \Bigr). \end{equation*}
Identify the relationship between the expected counts of Definition 18.4 and the expected empirical distribution of Definition 17.2.
For reference, Definition 18.4 defines the expected count of an event \(\alpha\) given parameter estimates \(\theta^k\) as
\begin{equation*} D\#(\alpha \mid \theta^k) \;\stackrel{\mathrm{def}}{=}\; \sum_{D_c} \Bigl[ [D D_c]\#(\alpha) \Bigr] P(D_c \mid D, \theta^k), \end{equation*}
where \(D_c\) ranges over the completions of \(D\) and \([DD_c]\#(\alpha)\) is the ordinary count of Definition 17.1 in the completed data set. Definition 17.2 defines the expected empirical distribution of \(D\) under \(\theta^k\) as
\begin{equation*} \mathrm{Pr}_{D,\theta^k}(\alpha) \;\stackrel{\mathrm{def}}{=}\; \frac{1}{N} \sum_{d_i, c_i \models \alpha} \mathrm{Pr}_{\theta^k}(c_i \mid d_i), \end{equation*}
where \(C_i\) are the variables with missing values in case \(d_i\) and the sum ranges over pairs \((i, c_i)\) with \(c_i\) an instantiation of \(C_i\) such that \(d_i c_i \models \alpha\).
The relationship is
\begin{equation*} D\#(\alpha \mid \theta^k) \;=\; N \cdot \mathrm{Pr}_{D,\theta^k}(\alpha), \end{equation*}
exactly as \(D\#(\alpha) = N \cdot \mathrm{Pr}_D(\alpha)\) in Definition 17.1.
A completion \(D_c\) is a tuple \((c_1, \ldots, c_N)\) with \(c_i\) an instantiation of \(C_i\). By Exercise 18.5 the parameter-set roots d-separate the slices of the meta-network from one another, and by Exercise 18.6 each slice given \(\theta^k\) is the base network \((G,\theta^k)\), so the \(N\) cases are independent given \(\theta^k\): \(P(D_c \mid D, \theta^k) = \prod_{j} \mathrm{Pr}_{\theta^k}(c_j \mid d_j)\). With \([D D_c]\#(\alpha) = \sum_{i} [\, d_i c_i \models \alpha \,]\) in Iverson brackets (Definition 17.1), Definition 18.4 and an exchange of summations give
\begin{equation*} D\#(\alpha \mid \theta^k) = \sum_{i=1}^{N} \; \sum_{c_1,\ldots,c_N} [\, d_i c_i \models \alpha \,] \prod_{j=1}^{N} \mathrm{Pr}_{\theta^k}(c_j \mid d_j). \end{equation*}
In the \(i\)-th inner sum the \(c_j\), \(j \ne i\), enter only through the factors \(\mathrm{Pr}_{\theta^k}(c_j \mid d_j)\), which sum to \(1\), so they marginalize away and
\begin{equation*} D\#(\alpha \mid \theta^k) = \sum_{i=1}^{N} \sum_{c_i \,:\, d_i c_i \models \alpha} \mathrm{Pr}_{\theta^k}(c_i \mid d_i) = \sum_{d_i, c_i \models \alpha} \mathrm{Pr}_{\theta^k}(c_i \mid d_i) = N \cdot \mathrm{Pr}_{D,\theta^k}(\alpha), \end{equation*}
the last step being precisely Definition 17.2.
Show that Algorithm 50, ML EM, is a special case of Algorithm 52, MAP EM C, in the case where all parameter sets \(\theta_{X|u}\) have noninformative priors (i.e., all Dirichlet exponents are equal to \(1\)). Note: in this case, the fixed points of Algorithm 52 are also stationary points of the log-likelihood function.
For reference, the two algorithms differ only in their accumulation and update lines. Both take a structure \(G\) with families \(XU\), initial estimates \(\theta^0\), and a data set \(D\) of size \(N\), and both iterate the following until convergence. Algorithm 50 (ML EM) sets \(c_{xu} \leftarrow 0\) for every family instantiation \(xu\), accumulates \(c_{xu} \leftarrow c_{xu} + \mathrm{Pr}_{\theta^k}(xu \mid d_i)\) over the cases \(d_i\), and then updates
\begin{equation*} \theta^{k+1}_{x|u} \;=\; \frac{c_{xu}}{\sum_{x^\star} c_{x^\star u}} . \end{equation*}
Algorithm 52 (MAP EM C) takes in addition a Dirichlet prior \(\psi_{x|u} / \psi_{X|u}\) for each parameter set, sets \(c_{xu} \leftarrow 0\) and \(c_u \leftarrow 0\), accumulates both \(c_{xu} \leftarrow c_{xu} + \mathrm{Pr}_{\theta^k}(xu \mid d_i)\) and \(c_u \leftarrow c_u + \mathrm{Pr}_{\theta^k}(u \mid d_i)\) over the cases, and then updates
\begin{equation*} \theta^{k+1}_{x|u} \;=\; \frac{c_{xu} + \psi_{x|u} - 1}{c_u + \psi_{X|u} - |X|} , \end{equation*}
where \(\psi_{X|u} = \sum_x \psi_{x|u}\) and \(|X|\) is the number of values of \(X\).
With \(\psi_{x|u} \equiv 1\) the two algorithms agree line for line, hence generate the same sequence \(\theta^0,\theta^1,\dots\) from the same \(\theta^0\).
Accumulators. Both compute \(c_{xu} = \sum_{i} \mathrm{Pr}_{\theta^k}(xu\mid d_i)\), which by (18.9) is \(D\#(xu\mid\theta^k)\). Algorithm 52’s extra \(c_u = D\#(u\mid\theta^k)\) is redundant: for fixed \(u\) the events \(x^\star u\) are mutually exclusive with disjunction \(u\), so
\begin{equation*} c_u \;=\; \sum_{i=1}^{N} \mathrm{Pr}_{\theta^k}(u \mid d_i) \;=\; \sum_{i=1}^{N} \sum_{x^\star} \mathrm{Pr}_{\theta^k}(x^\star u \mid d_i) \;=\; \sum_{x^\star} c_{x^\star u} , \end{equation*}
Algorithm 50’s denominator.
Updates. All exponents \(1\) give \(\psi_{x|u} - 1 = 0\) and \(\psi_{X|u} - |X| = 0\), so Algorithm 52’s update collapses to \(\theta^{k+1}_{x|u} = c_{xu}/c_u = c_{xu}/\sum_{x^\star} c_{x^\star u}\), which is Algorithm 50’s. The remaining lines – initialization, the case loop, the convergence test, the return – are identical.
The note. By Definition 18.5 exponents all \(1\) make each \(\rho(\theta_{X|u})\) the constant density on the simplex, so \(\rho(\theta)\) is constant by (18.18) and \(\rho(\theta\mid D) = \eta^{\prime}\,P(D\mid\theta)\); hence \(\log\rho(\theta\mid D)\) and \(LL(\theta\mid D) = \log P(D\mid\theta)\) differ by an additive constant and share their stationary points on the feasible set.
The Hessian matrix of the Laplace approximation is specified in terms of three types of second partial derivatives, with respect to:
- a single parameter \(\theta_{x|u}\);
- parameters \(\theta_{x|u}\) and \(\theta_{x^\star|u}\) of the same parameter set \(\theta_{X|u}\), where \(x \ne x^\star\);
- parameters \(\theta_{x|u}\) and \(\theta_{y|v}\) of two different parameter sets \(\theta_{X|u}\) and \(\theta_{Y|v}\).
(a) Show that the partial derivative of the Dirichlet density of parameter set \(\theta_{X|u}\) with respect to parameter \(\theta_{x|u}\) is
\begin{equation*} \frac{\partial \rho(\theta_{X|u})}{\partial \theta_{x|u}} \;=\; \frac{\psi_{x|u} - 1}{\theta_{x|u}} \cdot \rho(\theta_{X|u}). \end{equation*}
(b) Given (a), show that the partial derivative of the prior density of network parameters \(\rho(\theta)\) is
\begin{equation*} \frac{\partial \rho(\theta)}{\partial \theta_{x|u}} \;=\; \frac{\psi_{x|u} - 1}{\theta_{x|u}} \cdot \rho(\theta). \end{equation*}
(c) Given (a) and (b), show how to compute the second partial derivatives
\begin{equation*} \frac{\partial^2 \rho(\theta)}{\partial \theta_{x|u}\, \partial \theta_{x|u}}, \qquad \frac{\partial^2 \rho(\theta)}{\partial \theta_{x|u}\, \partial \theta_{x^\star|u}}, \qquad \frac{\partial^2 \rho(\theta)}{\partial \theta_{x|u}\, \partial \theta_{y|v}}. \end{equation*}
Here \(\rho(\theta_{X|u}) = \eta \prod_x \theta_{x|u}^{\,\psi_{x|u} - 1}\) is the Dirichlet density of Definition 18.5 with exponents \(\psi_{x|u} \ge 1\), and \(\rho(\theta) = \prod_{XU}\prod_u \rho(\theta_{X|u})\) is the prior density of network parameters, as given by (18.18).
Abbreviate \(a_{x|u} = \psi_{x|u} - 1 \ge 0\).
(a) Only the factor indexed by \(x\) of \(\rho(\theta_{X|u}) = \eta \prod_{x^\star} \theta_{x^\star|u}^{\,a_{x^\star|u}}\) (Definition 18.5) depends on \(\theta_{x|u}\), so
\begin{equation*} \frac{\partial \rho(\theta_{X|u})}{\partial \theta_{x|u}} = \eta \, a_{x|u}\, \theta_{x|u}^{\,a_{x|u} - 1} \prod_{x^\star \ne x} \theta_{x^\star|u}^{\,a_{x^\star|u}} = \frac{\psi_{x|u} - 1}{\theta_{x|u}} \cdot \rho(\theta_{X|u}), \end{equation*}
multiplying and dividing by \(\theta_{x|u} > 0\) on the interior.
(b) Distinct parameter sets involve disjoint parameters, so exactly one factor of \(\rho(\theta) = \prod_{YV}\prod_{v}\rho(\theta_{Y|v})\) (18.18) depends on \(\theta_{x|u}\); with \(R\) the product of the others (free of \(\theta_{x|u}\)) and (a),
\begin{equation*} \frac{\partial \rho(\theta)}{\partial \theta_{x|u}} = R \cdot \frac{a_{x|u}}{\theta_{x|u}} \rho(\theta_{X|u}) = \frac{\psi_{x|u} - 1}{\theta_{x|u}} \cdot \rho(\theta). \end{equation*}
(c) Differentiate (b) once more; all that matters is whether \(1/\theta_{x|u}\) depends on the second differentiation variable.
(i) A single parameter \(\theta_{x|u}\). It does, so the product rule gives two terms:
\begin{equation*} \begin{aligned} \frac{\partial^2 \rho(\theta)}{\partial \theta_{x|u} \partial \theta_{x|u}} &= -\frac{a_{x|u}}{\theta_{x|u}^{2}} \rho(\theta)
- \frac{a_{x|u}}{\theta_{x|u}} \cdot \frac{a_{x|u}}{\theta_{x|u}} \rho(\theta) \\ &= \frac{(\psi_{x|u} - 1)(\psi_{x|u} - 2)}{\theta_{x|u}^{2}} \cdot \rho(\theta). \end{aligned} \end{equation*}
(ii), (iii) Two distinct parameters \(\theta_{x|u}, \theta_{y|v}\), whether of the same set (\(\theta_{y|v} = \theta_{x^\star|u}\), \(x \ne x^\star\)) or of different sets. Now \(1/\theta_{x|u}\) is constant in \(\theta_{y|v}\), so one term survives and (b) applies again to \(\rho(\theta)\):
\begin{equation*} \frac{\partial^2 \rho(\theta)}{\partial \theta_{x|u} \partial \theta_{y|v}} = \frac{a_{x|u}}{\theta_{x|u}} \cdot \frac{\partial \rho(\theta)}{\partial \theta_{y|v}} = \frac{(\psi_{x|u} - 1)(\psi_{y|v} - 1)} {\theta_{x|u}\, \theta_{y|v}} \cdot \rho(\theta). \end{equation*}
Analogously to Exercise 18.18, consider partial derivatives of the likelihood of network parameters \(P(D \mid \theta)\).
(a) Show that the partial derivative of the likelihood \(P(D \mid \theta)\) with respect to parameter \(\theta_{x|u}\) is
\begin{equation*} \frac{\partial P(D \mid \theta)}{\partial \theta_{x|u}} \;=\; P(D \mid \theta) \cdot \frac{D\#(xu \mid \theta)}{\theta_{x|u}} . \end{equation*}
(b) Given (a), show how to compute the second partial derivatives
\begin{equation*} \frac{\partial^2 P(D \mid \theta)}{\partial \theta_{x|u}\, \partial \theta_{x|u}}, \qquad \frac{\partial^2 P(D \mid \theta)}{\partial \theta_{x|u}\, \partial \theta_{x^\star|u}}, \qquad \frac{\partial^2 P(D \mid \theta)}{\partial \theta_{x|u}\, \partial \theta_{y|v}} , \end{equation*}
the second being with respect to two parameters \(\theta_{x|u}, \theta_{x^\star|u}\) (\(x \ne x^\star\)) of the same parameter set, and the third with respect to parameters of two different parameter sets \(\theta_{X|u}\) and \(\theta_{Y|v}\).
Here \(P(D \mid \theta) = \prod_{i=1}^{N} \mathrm{Pr}_\theta(d_i)\) as given by (18.20) (equivalently (18.7)), \(D\) is a data set of size \(N\) that need not be complete, and \(D\#(\alpha \mid \theta)\) is the expected count of Definition 18.4, computable by (18.9) as \(D\#(\alpha \mid \theta) = \sum_{i=1}^{N} \mathrm{Pr}_\theta(\alpha \mid d_i)\).
Two facts about the base network’s polynomial do all the work, both resting on its multilinearity in the parameters (a term is a complete instantiation, so two parameters of one family never share a term). For any evidence \(e\):
- by Theorem 12.2, equation (12.4), \(\frac{\partial \mathrm{Pr}_\theta(e)}{\partial \theta_{x|u}} = \frac{\mathrm{Pr}_\theta(xu, e)}{\theta_{x|u}}\);
- second derivatives in two parameters of the same family vanish (Exercise 12.4(b)), and otherwise (Exercise 12.5) \(\frac{\partial^2 \mathrm{Pr}_\theta(e)}{\partial \theta_{x|u} \partial \theta_{y|v}} = \frac{\mathrm{Pr}_\theta(xu, yv, e)}{\theta_{x|u}\,\theta_{y|v}}\).
The second fact’s two cases are one statement, since distinct parameters of the same family make \(xu, yv\) inconsistent and so \(\mathrm{Pr}_\theta(xu, yv, e) = 0\); only \(\theta_{x|u} = \theta_{y|v}\) is exceptional. Abbreviate \(p_i = \mathrm{Pr}_\theta(d_i)\), so \(P(D\mid\theta) = \prod_i p_i\), and put
\begin{equation*} \begin{aligned} D\#(xu \mid \theta) &= \sum_{i=1}^N \mathrm{Pr}_\theta(xu \mid d_i), \\ D\#(xu, yv \mid \theta) &= \sum_{i=1}^N \mathrm{Pr}_\theta(xu \wedge yv \mid d_i), \\ S(xu, yv \mid \theta) &= \sum_{i=1}^N \mathrm{Pr}_\theta(xu \mid d_i)\, \mathrm{Pr}_\theta(yv \mid d_i), \end{aligned} \end{equation*}
the first two expected counts (Definition 18.4, evaluated by (18.9)), the third a sum of products of two per-case posteriors rather than a count.
Part (a). Differentiating \(\prod_i p_i\) and dividing by it,
\begin{equation*} \frac{\partial P(D \mid \theta)}{\partial \theta_{x|u}} = P(D \mid \theta) \sum_{i=1}^{N} \frac{1}{p_i} \frac{\partial p_i}{\partial \theta_{x|u}} = P(D \mid \theta) \sum_{i=1}^{N} \frac{\mathrm{Pr}_\theta(xu \mid d_i)}{\theta_{x|u}} , \end{equation*}
by the first fact with \(e = d_i\), and the sum is \(D\#(xu\mid\theta)/\theta_{x|u}\).
Part (b). For any two parameters \(\theta_1, \theta_2\), differentiating \(\prod_i p_i\) twice, dividing by it, and writing \(\alpha_i = (\partial p_i / \partial \theta_1)/p_i\), \(\beta_i = (\partial p_i / \partial \theta_2)/p_i\), \(\gamma_i = (\partial^2 p_i / \partial \theta_1 \partial \theta_2)/p_i\),
\begin{equation*} \frac{\partial^2 P(D \mid \theta)}{\partial \theta_1 \partial \theta_2} = P(D \mid \theta) \left[ \Bigl(\sum_i \alpha_i\Bigr)\Bigl(\sum_i \beta_i\Bigr)
- \sum_i \alpha_i \beta_i + \sum_i \gamma_i \right], \end{equation*}
the correction \(-\sum_i \alpha_i\beta_i\) deleting the diagonal \(i = j\), which the product of sums contains but the genuine cross terms \(i \ne j\) do not. With \(\theta_1 = \theta_{x|u}\), \(\theta_2 = \theta_{y|v}\) the two facts give
\begin{equation*} \alpha_i = \frac{\mathrm{Pr}_\theta(xu \mid d_i)}{\theta_{x|u}},\quad \beta_i = \frac{\mathrm{Pr}_\theta(yv \mid d_i)}{\theta_{y|v}},\quad \gamma_i = \frac{\mathrm{Pr}_\theta(xu \wedge yv \mid d_i)}{\theta_{x|u}\,\theta_{y|v}}, \end{equation*}
with \(\gamma_i \equiv 0\) whenever the two parameters belong to the same family (including \(\theta_1 = \theta_2\), where \(p_i\) is linear in that parameter). Hence:
(i), (ii) Same set: \(\theta_{x|u}\) with itself, or with \(\theta_{x^\star|u}\), \(x \ne x^\star\). Here \(\gamma_i = 0\), so
\begin{equation*} \frac{\partial^2 P(D \mid \theta)}{\partial \theta_{x|u} \partial \theta_{x^\star|u}} = P(D \mid \theta) \cdot \frac{D\#(xu \mid \theta)\, D\#(x^\star u \mid \theta) - S(xu, x^\star u \mid \theta)}{\theta_{x|u}\,\theta_{x^\star|u}} , \end{equation*}
which at \(x^\star = x\) reads \(P(D\mid\theta)\bigl[D\#(xu\mid\theta)^2 - \sum_i \mathrm{Pr}_\theta(xu\mid d_i)^2\bigr]/\theta_{x|u}^{2}\).
(iii) Different sets, \(\theta_{x|u}\) and \(\theta_{y|v}\). The joint term survives:
\begin{equation*} \frac{\partial^2 P(D \mid \theta)}{\partial \theta_{x|u} \partial \theta_{y|v}} = P(D \mid \theta) \cdot \frac{D\#(xu \mid \theta) D\#(yv \mid \theta) - S(xu, yv \mid \theta) + D\#(xu, yv \mid \theta)}{\theta_{x|u}\,\theta_{y|v}} . \end{equation*}
Consider the second partial derivative
\begin{equation*} \frac{\partial^2 \log \rho(D, \theta)}{\partial \theta_{x|u}\, \partial \theta_{y|v}} (\theta^{ma}) \end{equation*}
used in the Laplace approximation. Show how this derivative can be computed by performing inference on a Bayesian network with parametrization \(\theta^{ma}\). What is the complexity of computing all the second partial derivatives (i.e., computing the Hessian)? Hint: use the fact that \(\rho(D, \theta) = P(D \mid \theta)\rho(\theta)\) and consider Exercises 18.18 and 18.19.
Recall from (18.22) that the Laplace approximation is
\begin{equation*} \log P(D) \approx \log P(D \mid \theta^{ma}) + \log \rho(\theta^{ma})
- \frac{d}{2}\log(2\pi) - \frac{1}{2}\log |\Sigma| , \end{equation*}
where \(d\) is the number of independent parameters, \(\theta^{ma}\) are the MAP estimates, and \(\Sigma\) is the matrix whose entries are the negated second partial derivatives above, evaluated at \(\theta^{ma}\).
Every entry is a sum of per-case family posteriors in the base network \((G,\theta^{ma})\) plus a prior term needing no inference. Since \(\log \rho(D,\theta) = \log P(D\mid\theta) + \log\rho(\theta)\), the two halves are Exercises 18.19 and 18.18 on the log scale.
The prior term. By Definition 18.5 and (18.18), \(\log \rho(\theta) = \log \eta + \sum_{XU} \sum_{u} \sum_{x} (\psi_{x|u} - 1) \log \theta_{x|u}\), in which each parameter appears in exactly one summand, so
\begin{equation*} \frac{\partial^2 \log \rho(\theta)}{\partial \theta_{x|u}\, \partial \theta_{y|v}} = \begin{cases} -\dfrac{\psi_{x|u} - 1}{\theta_{x|u}^{2}}, & \theta_{y|v} = \theta_{x|u}, \\[2ex] 0, & \text{otherwise.} \end{cases} \end{equation*}
The prior thus touches only the diagonal of \(\Sigma\), from the exponents and the MAP estimates alone.
The likelihood term. Differentiating twice through \(\partial^2 \log f = f^{-1}\partial^2 f - (f^{-1}\partial_1 f)(f^{-1}\partial_2 f)\), the bracket of Exercise 18.19(b) loses its \((\sum_i\alpha_i)(\sum_i\beta_i)\) term:
\begin{equation*} \frac{\partial^2 \log P(D \mid \theta)}{\partial \theta_1\, \partial \theta_2} = \sum_{i=1}^{N} \bigl(\gamma_i - \alpha_i \beta_i\bigr), \end{equation*}
with \(\alpha_i,\beta_i,\gamma_i\) the per-case ratios computed there from Theorem 12.2, equation (12.4). For \(\theta_1 = \theta_{x|u}\), \(\theta_2 = \theta_{y|v}\) distinct this is
\begin{equation*} \frac{\partial^2 \log P(D \mid \theta)}{\partial \theta_{x|u}\, \partial \theta_{y|v}} = \frac{1}{\theta_{x|u}\,\theta_{y|v}} \sum_{i=1}^{N} \Bigl[ \mathrm{Pr}_\theta(xu \wedge yv \mid d_i)
- \mathrm{Pr}_\theta(xu \mid d_i)\, \mathrm{Pr}_\theta(yv \mid d_i) \Bigr], \end{equation*}
a sum of per-case covariances of the indicators of \(xu\) and \(yv\), whose first term vanishes for two distinct parameters of one set; and for \(\theta_1 = \theta_2 = \theta_{x|u}\), where \(\gamma_i = 0\) and \(\alpha_i = \beta_i\),
\begin{equation*} \frac{\partial^2 \log P(D \mid \theta)}{\partial \theta_{x|u}\, \partial \theta_{x|u}} = - \frac{1}{\theta_{x|u}^{2}} \sum_{i=1}^{N} \mathrm{Pr}_\theta(xu \mid d_i)^{2} . \end{equation*}
Adding the two contributions at \(\theta^{ma}\) gives the Hessian entries. For \(\theta_{y|v} \ne \theta_{x|u}\),
\begin{equation*} \frac{\partial^2 \log \rho(D, \theta)}{\partial \theta_{x|u} \partial \theta_{y|v}} (\theta^{ma}) = \frac{\displaystyle\sum_{i=1}^{N} \Bigl[ \mathrm{Pr}_{\theta^{ma}}(xu \wedge yv \mid d_i)
- \mathrm{Pr}_{\theta^{ma}}(xu \mid d_i) \mathrm{Pr}_{\theta^{ma}}(yv \mid d_i) \Bigr]} {\theta^{ma}_{x|u}\, \theta^{ma}_{y|v}} , \end{equation*}
and on the diagonal,
\begin{equation*} \frac{\partial^2 \log \rho(D, \theta)}{\partial \theta_{x|u} \partial \theta_{x|u}} (\theta^{ma}) = - \frac{1}{\bigl(\theta^{ma}_{x|u}\bigr)^{2}} \left[ \sum_{i=1}^{N} \mathrm{Pr}_{\theta^{ma}}(xu \mid d_i)^{2}
- \psi_{x|u} - 1 \right]. \end{equation*}
How inference supplies these. Every quantity is a posterior in the base network \((G,\theta^{ma})\) under evidence \(d_i\); the meta-network is never used.
- \(\mathrm{Pr}_{\theta^{ma}}(xu \mid d_i)\) is a family marginal, so one jointree propagation per case (or one circuit evaluation with its derivatives, Theorem 12.2) yields all family marginals for that case, and \(N\) propagations give every \(\sum_i \mathrm{Pr}(xu\mid d_i)\mathrm{Pr}(yv\mid d_i)\).
- \(\mathrm{Pr}_{\theta^{ma}}(xu \wedge yv \mid d_i)\) is a two-family joint marginal: read off directly if both families share a cluster, else by the chain rule \(\mathrm{Pr}(xu \wedge yv \mid d_i) = \mathrm{Pr}(xu \mid d_i \wedge yv)\, \mathrm{Pr}(yv \mid d_i)\), so one extra propagation with evidence \(d_i \wedge yv\) delivers the whole Hessian row indexed by \(\theta_{y|v}\) for case \(d_i\).
Complexity. With \(d\) independent parameters, \(n\) variables and width \(w\): \(N d\) propagations at \(O(n \exp(w))\) each, one per case and per family instantiation \(yv\) used as auxiliary evidence; \(O(N d^2)\) arithmetic to accumulate the \(O(d^2)\) entries, each a sum over \(N\) cases of two products; and \(O(d^3)\) for \(|\Sigma|\). The total is \(O(N d\, n \exp(w) + N d^{2} + d^{3})\), dominated in practice by \(N d\, n \exp(w)\) – a factor of \(d\) more inference than one EM iteration, which is why the text sets these entries to \(0\) for \(X \ne Y\) and works with a block-diagonal \(\Sigma\).
Extend the structural meta-network in Figure 18.6 to allow for reasoning about incomplete data sets. That is, the meta-network needs to have additional nodes to allow us to assert an incomplete data set as evidence.
The structural meta-network of Figure 18.6(b) is built for a problem with two binary variables \(A\) and \(B\) and has the following structure. There is a root node \(\Omega\) with three values \(G_1, G_2, G_3\), corresponding to the three possible network structures over \(A\) and \(B\), and six root parameter-set nodes \(\theta_{A|b_1}, \theta_{A|b_2}, \theta_A, \theta_B, \theta_{B|a_1}, \theta_{B|a_2}\). There is one further node \(A_iB_i\) per case \(i = 1, \ldots, N\); it is a single lumped variable with the four values \(a_1b_1, a_1b_2, a_2b_1, a_2b_2\), and its parents are \(\Omega\) together with all six parameter sets. The correspondence between structures and parameter sets is
\begin{equation*} \begin{aligned} \Omega = G_1 \;&:\; \text{structure } A,\; B \;&&\text{with parameter sets } \theta_A,\, \theta_B ; \\ \Omega = G_2 \;&:\; \text{structure } A \to B \;&&\text{with } \theta_A,\, \theta_{B|a_1},\, \theta_{B|a_2} ; \\ \Omega = G_3 \;&:\; \text{structure } B \to A \;&&\text{with } \theta_B,\, \theta_{A|b_1},\, \theta_{A|b_2} . \end{aligned} \end{equation*}
So the CPT of \(A_iB_i\) is \(P(a b \mid \Omega = G_1, \theta) = \theta_a \theta_b\), \(P(a b \mid \Omega = G_2, \theta) = \theta_a \theta_{b|a}\), and \(P(a b \mid \Omega = G_3, \theta) = \theta_b \theta_{a|b}\). By contrast, the parameter meta-network of Figure 18.6(a), which assumes the fixed structure \(A \to B\), keeps \(A_i\) and \(B_i\) as separate nodes: \(\theta_A\) is a parent of every \(A_i\), \(A_i\) is a parent of \(B_i\), and \(\theta_{B|a_1}, \theta_{B|a_2}\) are parents of every \(B_i\).
Give each lumped node its components back as deterministic children. In Figure 18.6(b) the lumping of \(A\) and \(B\) into \(A_iB_i\) is unavoidable – which of \(A_i, B_i\) is the other’s parent depends on \(\Omega\), while a Bayesian network has a fixed DAG – so “only \(A\) observed” is the disjunction \(A_iB_i \in \{a_1b_1, a_1b_2\}\) rather than an instantiation.
The construction. For each case \(i\) add two leaves whose single parent is \(A_iB_i\): \(A_i\) with values \(a_1,a_2\) and \(B_i\) with values \(b_1,b_2\), with the projection CPTs
\begin{equation*} P\bigl(A_i = a \mid A_iB_i = a^{\prime}b^{\prime}\bigr) = \bigl[\, a = a^{\prime} \,\bigr], \qquad P\bigl(B_i = b \mid A_iB_i = a^{\prime}b^{\prime}\bigr) = \bigl[\, b = b^{\prime} \,\bigr]. \end{equation*}
Everything else – the root \(\Omega\), the six parameter-set roots, and the lumped node \(A_iB_i\) with parents \(\Omega\) and all six parameter sets – is unchanged.
Asserting the data. Instantiate exactly those of \(A_i, B_i\) recorded in \(d_i\): an \(A\)-only case becomes \(A_i = a_1\), a complete case \(A_i = a_1 \wedge B_i = b_2\), an empty case nothing, so \(D\) is an ordinary instantiation of a subset of the variables.
Correctness. The new nodes are leaves, so pruning them (Theorem 6.4, Section 6.9.1) leaves the marginal over \(\Omega, \theta, A_1B_1,\dots,A_NB_N\) untouched, and the support of \(A_i = a_1\) is exactly the parent instantiations \(a_1b_1, a_1b_2\), so
\begin{equation*} P\bigl(\cdot \mid A_i = a_1\bigr) = P\bigl(\cdot \mid A_iB_i = a_1b_1 \vee A_iB_i = a_1b_2 \bigr). \end{equation*}
The queries \(P(\Omega\mid D)\), \(P(\theta\mid D)\) and predictions on \(A_{N+1}, B_{N+1}\) are therefore answered for incomplete \(D\) as for complete.
Exercises 18.22–18.24
Consider a BDe score that is specified by a prior distribution \(Pr\) (defined over the base network variables) together with an equivalent sample size \(\psi > 0\), so that the Dirichlet exponent of every parameter \(\theta_{x|\mathbf{u}}\) of every candidate structure is
\begin{equation*} \psi_{x|\mathbf{u}} \;=\; \psi \cdot Pr(x, \mathbf{u}), \end{equation*}
which is Equation 18.25. Let \(G\) be a complete network structure, that is, a DAG to which no further edge can be added without creating a directed cycle, and let \(\mathbf{d}\) be a complete case, that is, an instantiation of all network variables. Show that \(Pr(\mathbf{d}) = P(\mathbf{d}|G)\), where \(P\) is the corresponding meta-distribution (the distribution induced by the meta-network of Definition 18.2 built from structure \(G\) together with the Dirichlet priors above).
Note: This exercise provides additional semantics for the prior distribution of a BDe score. Assume \(Pr\) is strictly positive, so that every exponent \(\psi_{x|\mathbf{u}}\) is positive and every Dirichlet prior is well defined.
The prior expectations are the prior’s conditionals, and completeness turns their product into the chain rule. Write \(X_1,\dots,X_n\) for the variables, \(\mathbf{U}_i\) for the parents of \(X_i\) in \(G\), and \(x_i, \mathbf{u}_i\) for the values \(\mathbf{d}\) fixes.
(i) Prior expectations. Summing Equation 18.25 gives \(\psi_{X|\mathbf{u}} = \psi \cdot Pr(\mathbf{u})\), nonzero since \(Pr\) is strictly positive, so by the Dirichlet mean (18.10),
\begin{equation*} \mathrm{Ex}(\theta_{x|\mathbf{u}}) \;=\; \frac{\psi_{x|\mathbf{u}}}{\psi_{X|\mathbf{u}}} \;=\; \frac{\psi \cdot Pr(x,\mathbf{u})}{\psi \cdot Pr(\mathbf{u})} \;=\; Pr(x \mid \mathbf{u}). \end{equation*}
(ii) One case under the meta-distribution. Conditioned on a full parametrization the instance is distributed as the base network, so \(P(\mathbf{d}\mid\theta,G) = \prod_{i} \theta_{x_i\mid\mathbf{u}_i}\) by Equation 18.20 with \(N = 1\). Marginalize against the prior factorization (18.18), valid because the parameter sets are roots and hence independent: the \(n\) sets \(\theta_{X_i|\mathbf{u}_i}\) are pairwise distinct (distinct variables), so none contributes two factors, while every other set appears only in its own density, which integrates to \(1\). The remaining \(n\) integrals separate into first moments, so with (i),
\begin{equation*} P(\mathbf{d}\mid G) \;=\; \prod_{i=1}^{n} \int \theta_{x_i\mid\mathbf{u}_i}\, \rho(\theta_{X_i\mid\mathbf{u}_i})\,d\theta_{X_i\mid\mathbf{u}_i} \;=\; \prod_{i=1}^{n} Pr(x_i \mid \mathbf{u}_i), \end{equation*}
for any \(G\).
(iii) Completeness gives the chain rule. Relabel so that \(X_1,\dots,X_n\) is a topological order of \(G\). For \(i < j\) there must already be an edge between \(X_i\) and \(X_j\), since \(X_i \to X_j\) respects the order and so could otherwise be added without a cycle; and any such edge runs \(X_i \to X_j\), again by the order. Hence \(\mathbf{U}_j = \{X_1,\dots,X_{j-1}\}\) and the instantiation \(\mathbf{u}_j\) selected by the complete case \(\mathbf{d}\) is \(x_1 \dots x_{j-1}\), so
\begin{equation*} P(\mathbf{d}\mid G) = \prod_{j=1}^{n} Pr(x_j \mid x_1 \dots x_{j-1}) = Pr(x_1, \dots, x_n) \;=\; Pr(\mathbf{d}), \end{equation*}
by the chain rule for \(Pr\) and because \(\mathbf{d} = x_1 \dots x_n\).
Consider the BDe score over two binary variables \(A\) and \(B\), an equivalent sample size of \(\psi = 12\), and the prior distribution
| A | B | Pr(.) |
|---|---|---|
| \(a_1\) | \(b_1\) | 1/4 |
| \(a_1\) | \(b_2\) | 1/6 |
| \(a_2\) | \(b_1\) | 1/4 |
| \(a_2\) | \(b_2\) | 1/3 |
Recall that the BDe score fixes the Dirichlet exponent of every parameter \(\theta_{x|\mathbf{u}}\) by Equation 18.25, \(\psi_{x|\mathbf{u}} = \psi \cdot Pr(x,\mathbf{u})\).
Consider also the data set \(d_1 = a_1 b_1\), \(d_2 = a_1 b_2\) and the structures \(G_1 : A \to B\) (a single edge from \(A\) to \(B\)) and \(G_2 : A,\, B\) (the empty structure, with \(A\) and \(B\) both roots and no edge between them). Compute the likelihood of each structure using Equation 18.21,
\begin{equation*} P(D) \;=\; \prod_{X\mathbf{U}}\prod_{\mathbf{u}} \frac{\Gamma(\psi_{X|\mathbf{u}})}{\Gamma(\psi_{X|\mathbf{u}} + D\#(\mathbf{u}))} \prod_{x} \frac{\Gamma(\psi_{x|\mathbf{u}} + D\#(x\mathbf{u}))}{\Gamma(\psi_{x|\mathbf{u}})}, \end{equation*}
where \(D\#(\alpha)\) is the number of cases in \(D\) that satisfy \(\alpha\) and \(\top\) is the trivial instantiation, so \(D\#(\top)\) is the size of the data set.
\(P(D\mid G_1) = 1/26\) and \(P(D\mid G_2) = 15/338\), so the empty structure is favoured. With \(D\#(\top) = 2\) the counts are
| event | count |
|---|---|
| \(a_1\) | 2 |
| \(a_2\) | 0 |
| \(b_1\) | 1 |
| \(b_2\) | 1 |
| \(a_1 b_1\) | 1 |
| \(a_1 b_2\) | 1 |
| \(a_2 b_1\) | 0 |
| \(a_2 b_2\) | 0 |
The prior marginals are
\begin{equation*} \begin{aligned} Pr(a_1) &= \tfrac{1}{4} + \tfrac{1}{6} = \tfrac{5}{12}, & Pr(a_2) &= \tfrac{1}{4} + \tfrac{1}{3} = \tfrac{7}{12}, \\ Pr(b_1) &= \tfrac{1}{4} + \tfrac{1}{4} = \tfrac{1}{2}, & Pr(b_2) &= \tfrac{1}{6} + \tfrac{1}{3} = \tfrac{1}{2}. \end{aligned} \end{equation*}
Likelihood of \(G_1 : A \to B\). The families are \(A\) (empty parent set) and \(BA\), and Equation 18.25 with \(\psi = 12\) gives the exponents
| parameter | exponent |
|---|---|
| \(\theta_{a_1}\) | \(12 \cdot \tfrac{5}{12} = 5\) |
| \(\theta_{a_2}\) | \(12 \cdot \tfrac{7}{12} = 7\) |
| \(\theta_{b_1 \vert a_1}\) | \(12 \cdot \tfrac{1}{4} = 3\) |
| \(\theta_{b_2 \vert a_1}\) | \(12 \cdot \tfrac{1}{6} = 2\) |
| \(\theta_{b_1 \vert a_2}\) | \(12 \cdot \tfrac{1}{4} = 3\) |
| \(\theta_{b_2 \vert a_2}\) | \(12 \cdot \tfrac{1}{3} = 4\) |
with equivalent sample sizes \(\psi_A = 12\), \(\psi_{B|a_1} = 5\) and \(\psi_{B|a_2} = 7\). Equation 18.21 reads
\begin{equation*} \begin{aligned} P(D \mid G_1) =\;& \frac{\Gamma(12)}{\Gamma(12+2)} \frac{\Gamma(5+2)}{\Gamma(5)}\frac{\Gamma(7+0)}{\Gamma(7)} \\ &\cdot \frac{\Gamma(5)}{\Gamma(5+2)} \frac{\Gamma(3+1)}{\Gamma(3)}\frac{\Gamma(2+1)}{\Gamma(2)} \\ &\cdot \frac{\Gamma(7)}{\Gamma(7+0)} \frac{\Gamma(3+0)}{\Gamma(3)}\frac{\Gamma(4+0)}{\Gamma(4)}. \end{aligned} \end{equation*}
Using \(\Gamma(k+m)/\Gamma(k) = k(k+1)\cdots(k+m-1)\) for integers, the three lines evaluate to
\begin{equation*} \begin{aligned} \text{line 1} &= \frac{1}{12\cdot 13}\cdot(5\cdot 6)\cdot 1 = \frac{30}{156} = \frac{5}{26}, \\ \text{line 2} &= \frac{1}{5\cdot 6}\cdot 3 \cdot 2 = \frac{6}{30} = \frac{1}{5}, \\ \text{line 3} &= 1 \cdot 1 \cdot 1 = 1, \end{aligned} \end{equation*}
so that
\begin{equation*} P(D \mid G_1) \;=\; \frac{5}{26}\cdot\frac{1}{5} \;=\; \frac{1}{26} \;\approx\; 0.03846 , \end{equation*}
the worked example of Section 18.5.2.
Likelihood of \(G_2 : A,\, B\). Both families are singletons with empty parent set:
| parameter | exponent |
|---|---|
| \(\theta_{a_1}\) | \(12 \cdot \tfrac{5}{12} = 5\) |
| \(\theta_{a_2}\) | \(12 \cdot \tfrac{7}{12} = 7\) |
| \(\theta_{b_1}\) | \(12 \cdot \tfrac{1}{2} = 6\) |
| \(\theta_{b_2}\) | \(12 \cdot \tfrac{1}{2} = 6\) |
with \(\psi_A = \psi_B = 12\), the \(A\) factor shared with \(G_1\) by parameter modularity. Equation 18.21 gives
\begin{equation*} \begin{aligned} P(D \mid G_2) =\;& \frac{\Gamma(12)}{\Gamma(12+2)} \frac{\Gamma(5+2)}{\Gamma(5)}\frac{\Gamma(7+0)}{\Gamma(7)} \\ &\cdot \frac{\Gamma(12)}{\Gamma(12+2)} \frac{\Gamma(6+1)}{\Gamma(6)}\frac{\Gamma(6+1)}{\Gamma(6)} . \end{aligned} \end{equation*}
The first line is again \(30/156 = 5/26\) and the second is \(\tfrac{1}{12\cdot 13}\cdot 6\cdot 6 = \tfrac{36}{156} = \tfrac{3}{13}\), so
\begin{equation*} P(D \mid G_2) \;=\; \frac{5}{26}\cdot\frac{3}{13} \;=\; \frac{15}{338} \;\approx\; 0.04438 . \end{equation*}
Consider the BDe score over two binary variables \(A\) and \(B\), an equivalent sample size of \(\psi = 12\), and the prior distribution
| A | B | Pr(.) |
|---|---|---|
| \(a_1\) | \(b_1\) | 1/4 |
| \(a_1\) | \(b_2\) | 1/6 |
| \(a_2\) | \(b_1\) | 1/4 |
| \(a_2\) | \(b_2\) | 1/3 |
so that the Dirichlet exponents are given by Equation 18.25, \(\psi_{x|\mathbf{u}} = \psi \cdot Pr(x,\mathbf{u})\).
Consider also the data set \(d_1 = a_1 b_1\), \(d_2 = a_1 b_2\) and the structure \(G : A \to B\) (a single edge from \(A\) to \(B\)). Compute the probabilities \(P(d_1|G)\), \(P(d_2|d_1,G)\) and \(P(d_1,d_2|G)\). Compute the same quantities for the structure \(G^{\prime} : B \to A\) (a single edge from \(B\) to \(A\)) as well.
All six numbers are \(P(d_1) = 1/4\), \(P(d_2\mid d_1) = 2/13\), \(P(d_1,d_2) = 1/26\), the same under both structures. Each \(P(\cdot\mid G)\) is a marginal likelihood from Equation 18.21, and \(P(d_2\mid d_1,G) = P(d_1,d_2\mid G)/P(d_1\mid G)\) by the chain rule. The prior marginals are
\begin{equation*} \begin{aligned} Pr(a_1) &= \tfrac{1}{4}+\tfrac{1}{6} = \tfrac{5}{12}, & Pr(a_2) &= \tfrac{1}{4}+\tfrac{1}{3} = \tfrac{7}{12}, \\ Pr(b_1) &= \tfrac{1}{4}+\tfrac{1}{4} = \tfrac{1}{2}, & Pr(b_2) &= \tfrac{1}{6}+\tfrac{1}{3} = \tfrac{1}{2}. \end{aligned} \end{equation*}
Part 1: \(G : A \to B\). The exponents, from \(\psi_{x|\mathbf{u}} = 12\,Pr(x,\mathbf{u})\), are \(\psi_{a_1} = 5\), \(\psi_{a_2} = 7\) (so \(\psi_A = 12\)); \(\psi_{b_1 \vert a_1} = 3\), \(\psi_{b_2 \vert a_1} = 2\) (so \(\psi_{B|a_1} = 5\)); and \(\psi_{b_1 \vert a_2} = 3\), \(\psi_{b_2 \vert a_2} = 4\) (so \(\psi_{B|a_2} = 7\)).
For \(D = \{d_1\} = \{a_1 b_1\}\) the counts are \(D\#(\top) = 1\), \(D\#(a_1) = 1\), \(D\#(a_2) = 0\), \(D\#(a_1 b_1) = 1\), and all remaining family counts are \(0\). Equation 18.21 gives
\begin{equation*} \begin{aligned} P(d_1 \mid G) =\;& \frac{\Gamma(12)}{\Gamma(13)} \frac{\Gamma(5+1)}{\Gamma(5)}\frac{\Gamma(7)}{\Gamma(7)} \\ &\cdot \frac{\Gamma(5)}{\Gamma(6)} \frac{\Gamma(3+1)}{\Gamma(3)}\frac{\Gamma(2)}{\Gamma(2)} \cdot \frac{\Gamma(7)}{\Gamma(7)}\cdot 1 \cdot 1 \\ =\;& \frac{5}{12}\cdot\frac{3}{5} \;=\; \frac{1}{4}, \end{aligned} \end{equation*}
which is \(Pr(a_1b_1)\), as Exercise 18.22 requires of a complete DAG on a complete case. For \(D = \{d_1, d_2\}\) the counts become \(D\#(\top) = 2\), \(D\#(a_1) = 2\), \(D\#(a_1 b_1) = D\#(a_1 b_2) = 1\) with the rest \(0\), and Equation 18.21 gives \(P(d_1, d_2 \mid G) = \tfrac{30}{156}\cdot\tfrac{6}{30} = \tfrac{1}{26}\), the computation of Exercise 18.23. Therefore
\begin{equation*} P(d_2 \mid d_1, G) \;=\; \frac{1/26}{1/4} \;=\; \frac{4}{26} \;=\; \frac{2}{13} \;\approx\; 0.1538 . \end{equation*}
Part 2: \(G^{\prime} : B \to A\). The families are \(B\) (root) and \(A B\), so Equation 18.25 with the same \(Pr\) and \(\psi = 12\) gives exponents \(\psi_{b_1} = 12 \cdot \tfrac12 = 6\), \(\psi_{b_2} = 6\) (so \(\psi_B = 12\)); \(\psi_{a_1 \vert b_1} = 12 \cdot \tfrac14 = 3\), \(\psi_{a_2 \vert b_1} = 12 \cdot \tfrac14 = 3\) (so \(\psi_{A|b_1} = 6\)); and \(\psi_{a_1 \vert b_2} = 12 \cdot \tfrac16 = 2\), \(\psi_{a_2 \vert b_2} = 12 \cdot \tfrac13 = 4\) (so \(\psi_{A|b_2} = 6\)).
For \(D = \{d_1\} = \{a_1 b_1\}\): \(D\#(\top) = 1\), \(D\#(b_1) = 1\), \(D\#(b_2) = 0\), \(D\#(a_1 b_1) = 1\), all others \(0\). Then
\begin{equation*} \begin{aligned} P(d_1 \mid G^{\prime}) =\;& \frac{\Gamma(12)}{\Gamma(13)} \frac{\Gamma(6+1)}{\Gamma(6)}\frac{\Gamma(6)}{\Gamma(6)} \\ &\cdot \frac{\Gamma(6)}{\Gamma(7)} \frac{\Gamma(3+1)}{\Gamma(3)}\frac{\Gamma(3)}{\Gamma(3)} \cdot 1 \\ =\;& \frac{6}{12}\cdot\frac{3}{6} \;=\; \frac{1}{4}, \end{aligned} \end{equation*}
again \(Pr(a_1b_1)\), since \(B \to A\) is also a complete DAG. For \(D = \{d_1, d_2\}\): \(D\#(\top) = 2\), \(D\#(b_1) = 1\), \(D\#(b_2) = 1\), \(D\#(a_1 b_1) = 1\), \(D\#(a_2 b_1) = 0\), \(D\#(a_1 b_2) = 1\), \(D\#(a_2 b_2) = 0\). Equation 18.21 gives
\begin{equation*} \begin{aligned} P(d_1, d_2 \mid G^{\prime}) =\;& \frac{\Gamma(12)}{\Gamma(14)} \frac{\Gamma(6+1)}{\Gamma(6)}\frac{\Gamma(6+1)}{\Gamma(6)} \\ &\cdot \frac{\Gamma(6)}{\Gamma(7)} \frac{\Gamma(3+1)}{\Gamma(3)}\frac{\Gamma(3+0)}{\Gamma(3)} \\ &\cdot \frac{\Gamma(6)}{\Gamma(7)} \frac{\Gamma(2+1)}{\Gamma(2)}\frac{\Gamma(4+0)}{\Gamma(4)} . \end{aligned} \end{equation*}
The three lines evaluate to
\begin{equation*} \begin{aligned} \text{line 1} &= \frac{1}{12\cdot 13}\cdot 6 \cdot 6 = \frac{36}{156} = \frac{3}{13}, \\ \text{line 2} &= \frac{1}{6}\cdot 3 \cdot 1 = \frac{1}{2}, \\ \text{line 3} &= \frac{1}{6}\cdot 2 \cdot 1 = \frac{1}{3}, \end{aligned} \end{equation*}
so that
\begin{equation*} P(d_1, d_2 \mid G^{\prime}) \;=\; \frac{3}{13}\cdot\frac{1}{2}\cdot\frac{1}{3} \;=\; \frac{1}{26}, \end{equation*}
and consequently
\begin{equation*} P(d_2 \mid d_1, G^{\prime}) \;=\; \frac{1/26}{1/4} \;=\; \frac{2}{13}. \end{equation*}
Summary.
| quantity | \(G : A \to B\) | \(G^{\prime} : B \to A\) |
|---|---|---|
| \(P(d_1)\) | \(1/4\) | \(1/4\) |
| \(P(d_2 \mid d_1)\) | \(2/13\) | \(2/13\) |
| \(P(d_1, d_2)\) | \(1/26\) | \(1/26\) |
The agreement is the likelihood equivalence that names the BDe score: \(A \to B\) and \(B \to A\) are Markov equivalent complete DAGs over \(\{A,B\}\), so the BDe assumptions force equal marginal likelihoods on every complete data set, and the conditionals agree as ratios of those.
Backlinks (2)
1. Modeling and Reasoning with Bayesian Networks /words/library/books/modeling_and_reasoning_with_bayesian_networks/
Adnan Darwiche’s Modeling and Reasoning with Bayesian Networks (Cambridge University Press, 2009). The COMP9418 reference text: representation (propositional logic, probability calculus, Bayesian networks), exact inference (variable elimination, factor elimination, conditioning, jointrees), advanced inference (compilation, local structure), approximate inference (belief propagation, sampling), and learning (maximum likelihood and Bayesian).
Worked solutions to all 342 exercises live at Solutions to Darwiche’s Modeling and Reasoning with Bayesian Networks.
2. Books /words/library/books/
Here are the books that I have taken the time to create metadata and/or notes for.
Comments