Skip to content

Directed Graphical Models

Page 806 established that a probabilistic model is its joint distribution. That settled what the object is and left a problem: the book’s own words, “the joint distribution by itself can be quite complicated, and it does not tell us anything about structural properties of the probabilistic model. For example, the joint distribution p(a,b,c)p(a, b, c) does not tell us anything about independence relations.”

This page is the notation that fixes that. You draw the model, and then you read facts off the drawing that would otherwise require algebra. Measured: all four of Example 8.9’s conditional-independence claims come out correct on four million samples, and the factorization they encode replaces 1.27×10301.27\times10^{30} free parameters with 395395.

  • The two rules that turn a factorization into a graph, and Equation 8.31 that turns it back.
  • Why the compression matters: 3131 parameters become 1010 on five binary variables, and 1.27×10301.27\times10^{30} become 395395 on a hundred.
  • Plate notation, and why a plate is literally a product.
  • d-separation: the three-case rule for reading conditional independence off a picture.
  • All four of Example 8.9’s claims, measured: 0.000320-0.000320, 0.000079-0.000079, 0.2721720.272172, 0.146064-0.146064.
  • The one rule that runs backwards — conditioning on a collider creates a dependence. Measured: corr(a,c)\mathrm{corr}(a, c) goes from 0.000079-0.000079 to 0.237939-0.237939 with no change to the model at all.
  • Why the book cautions that “the graph layout depends on the choice of factorization” — the same joint admits graphs pointing opposite ways.

Most diagrams in a paper are illustrations. This one is not. It is a lossless encoding of a factorization, and every property you can see in it is a property the distribution provably has.

Two things make it worth learning:

It compresses. A joint over 100100 binary variables has 210012^{100} - 1 free numbers — more than there are atoms in a galaxy. Assert that each variable depends on at most two others and it becomes 395395. That is not an approximation; it is a statement about which dependencies exist, and the graph is how you write that statement down.

It answers questions without algebra. Is aa independent of cc once I know bb? You could integrate. Or you could trace paths in a picture and apply three rules. The picture is the book’s “simple language for describing complex interdependence”.

The one trap: the third rule runs the opposite way from the other two. Observing something can make two variables dependent that were independent before — and the page measures exactly how much.

diagram What a graph is for mermaid

Nodes are random variables. Directed links (arrows) between two nodes indicate conditional probabilities. The arrow aba \to b carries p(ba)p(b \mid a).

From a factorization to a graph — Example 8.7

Section titled “From a factorization to a graph — Example 8.7”

Given

p(a,b,c)=p(ca,b)p(ba)p(a)p(a, b, c) = p(c \mid a, b)\,p(b \mid a)\,p(a)

the factorization already says everything: cc depends directly on aa and bb; bb depends directly on aa; aa depends neither on bb nor on cc.” That is Figure 8.9(a).

The general construction is two rules:

  1. Create a node for all random variables.
  2. For each conditional distribution, add a directed link to the graph from the nodes corresponding to the variables on which the distribution is conditioned.

From a graph to a factorization — Example 8.8

Section titled “From a graph to a factorization — Example 8.8”

Run it backwards on Figure 8.9(b), using two properties:

  • the joint is “the product of a set of conditionals, one for each node in the graph” — five nodes, five conditionals;
  • “each conditional depends only on the parents of the corresponding node.”
p(x1,x2,x3,x4,x5)=p(x1)p(x5)p(x2x5)p(x3x1,x2)p(x4x2)p(x_1, x_2, x_3, x_4, x_5) = p(x_1)\,p(x_5)\,p(x_2 \mid x_5)\,p(x_3 \mid x_1, x_2)\,p(x_4 \mid x_2)

and in general, Equation 8.31:

p(x)=k=1Kp(xkPak)p(\mathbf{x}) = \prod_{k=1}^{K} p(x_k \mid \mathrm{Pa}_k)

where Pak\mathrm{Pa}_k means “the parent nodes of xkx_k — the nodes with arrows pointing into xkx_k.

For a Bernoulli experiment p(xμ)=Ber(μ)p(x \mid \mu) = \mathrm{Ber}(\mu) repeated NN times,

p(x1,,xNμ)=n=1Np(xnμ)p(x_1, \ldots, x_N \mid \mu) = \prod_{n=1}^{N} p(x_n \mid \mu)

which is a product “because the experiments are independent” — and the book connects that straight back to §6.4.5: statistical independence means that the distribution factorizes.

Drawing this needs one new convention: “we make the distinction between unobserved/latent variables and observed variables. Graphically, observed variables are denoted by shaded nodes.” Figure 8.10(a) draws μ\mu once with an arrow to every xnx_n“the single parameter μ\mu is the same for all xnx_n as the outcomes xnx_n are identically distributed.”

Figure 8.10(b) replaces the repetition with a plate: “the plate (box) repeats everything inside (in this case, the observations xnx_n) NN times. Therefore, both graphical models are equivalent, but the plate notation is more compact.”

Figure 8.10(c) then adds a hyperprior“a second layer of prior distributions on the parameters of the first layer of priors” — a Beta(α,β)\mathrm{Beta}(\alpha, \beta) on μ\mu. And a convention worth remembering: “if we treat α\alpha and β\beta as deterministic parameters, i.e., not random variables, we omit the circle around it.”

§8.5.2 Conditional independence and d-separation

Section titled “§8.5.2 Conditional independence and d-separation”

Directed graphical models “allow us to find conditional independence relationship properties of the joint distribution only by looking at the graph.” The concept is d-separation (Pearl, 1988).

For arbitrary nonintersecting sets of nodes AA, BB, CC, we want to know whether

A ⁣ ⁣ ⁣BCA \perp\!\!\!\perp B \mid C

is implied by the graph. The procedure: consider all possible trails“paths that ignore the direction of the arrows” — from any node in AA to any node in BB. A trail is blocked if it contains a node where either holds:

The arrows on the path meet either head to tail or tail to tail at the node, and the node is in the set CC.

The arrows meet head to head at the node, and neither the node nor any of its descendants is in the set CC.

“If all paths are blocked, then AA is said to be d-separated from BB by CC, and the joint distribution over all of the variables in the graph will satisfy A ⁣ ⁣ ⁣BCA \perp\!\!\!\perp B \mid C.”

meetingshapeblocked whenthe plain reading
head to tailunvu \to n \to vnCn \in Ca relay; observing the middle cuts the wire
tail to tailunvu \leftarrow n \to vnCn \in Ca common cause; observing it explains the shared part
head to headunvu \to n \leftarrow vnCn \notin C and no descendant of nn is in CCa collider; observing it opens the wire

Two of the three rules say conditioning blocks. The third says conditioning opens. Every mistake with this notation lives in that third row.

Figure 8.11’s edge structure is not in the PDF’s text layer. I recovered it from the vector layer — the line segments and arrowheads themselves — and got

ab,ad,bc,cd,dea \to b, \qquad a \to d, \qquad b \to c, \qquad c \to d, \qquad d \to e

That reconstruction is independently confirmed by the book’s own four claims: all four are correct for this DAG and at least one fails for every other edge set I considered. The book states them with a single sentence of justification — “Visual inspection gives us” — so here they are, checked on four million samples of a linear-Gaussian model on that DAG, where a zero partial correlation is exactly conditional independence:

8.36 and 8.38 differ by one variable in the conditioning set. Nothing about the model changes:

The book closes the section with the payoff and a forward pointer: this representation “allows us to factorize the respective probabilistic models into expressions that are easier to optimize”, and the picture “allows us to visually see the impact of design choices we have made on the structure of the model” — choices which “affect the prediction performance, but cannot be selected directly using the approaches we have seen so far”. Choosing structure is §8.6.

Three main families, all shown in Figure 8.12:

familyalso callededges
directed graphical modelsBayesian networksdirected
undirected graphical modelsMarkov random fieldsundirected
factor graphsbipartite, factors and variables

Bishop (2006, chapter 8) introduces them; Koller and Friedman (2009) give the extensive treatment. The practical payoff the book names is “graph-based algorithms for inference and learning, e.g., via local message passing”, with applications “from ranking in online games and computer vision (image segmentation, semantic labeling, image denoising, image restoration) to coding theory, solving linear equation systems, and iterative Bayesian state estimation in signal processing.”

Two topics flagged as important and out of scope: structured prediction (Bakir et al., 2007), for “predictions that are structured, for example sequences, trees, and graphs”, and the “renewed interest in graphical models due to their applications to causal inference (Pearl, 2009; Peters et al., 2017).

Take Figure 8.11 and answer a question the graph makes easy and the algebra makes tedious: is bb independent of ee given dd?

Step 1: write the factorization from the graph. Equation 8.31, one factor per node, each conditioned on its parents:

p(a,b,c,d,e)=p(a)p(ba)p(cb)p(da,c)p(ed)p(a,b,c,d,e) = p(a)\,p(b \mid a)\,p(c \mid b)\,p(d \mid a, c)\,p(e \mid d)

Step 2: enumerate the trails from bb to ee. Ignoring arrow direction, every path:

trailnodes it passes through
badeb \leftarrow a \to d \to eaa, dd
bcdeb \to c \to d \to ecc, dd

Step 3: apply the rules with C={d}C = \{d\}.

trailmeeting at the node in CCblocked?
badeb \leftarrow a \to d \to eat dd: adea \to d \to e is head to tail, and dCd \in C✅ blocked
bcdeb \to c \to d \to eat dd: cdec \to d \to e is head to tail, and dCd \in C✅ blocked

Step 4: conclude. Every trail is blocked, so b ⁣ ⁣ ⁣edb \perp\!\!\!\perp e \mid d.

Step 5: sanity-check it against the structure. ee’s only parent is dd, so once you know dd, nothing upstream can add information about eeee is a noisy copy of dd and nothing else. Any node is independent of the whole graph given its parents and children’s parents, and this is the simplest instance.

Step 6: notice what changes if you drop dd. With C=C = \emptyset the first trail meets tail to tail at aa with aCa \notin C — open. So b⊥̸ ⁣ ⁣ ⁣eb \not\perp\!\!\!\perp e unconditionally. Knowing bb tells you about aa, which tells you about dd, which tells you about ee. The conditioning set is not a detail; it is half the question.

sketch Trace the trails yourself p5.js
Figure 8.11 as an interactive graph. Click a node to put it in the conditioning set. The trails between the two query nodes light up green when blocked and red when open, and the verdict updates. The three rules are applied live at each node on each trail.
graphical_models.py
import itertools
import numpy as np
 
# --- Equation 8.31 on Figure 8.9(b) --------------------------------------
# p(x1..x5) = p(x1) p(x5) p(x2|x5) p(x3|x1,x2) p(x4|x2)
p1 = np.array([0.3, 0.7])
p5 = np.array([0.6, 0.4])
p2_5 = np.array([[0.8, 0.2], [0.35, 0.65]])
p4_2 = np.array([[0.25, 0.75], [0.9, 0.1]])
p3_12 = np.array([[[0.5, 0.5], [0.1, 0.9]],
                  [[0.85, 0.15], [0.4, 0.6]]])
 
joint = np.zeros((2,) * 5)
for a, b, c, d, e in itertools.product(range(2), repeat=5):
    joint[a, b, c, d, e] = (p1[a] * p5[e] * p2_5[e, b]
                            * p3_12[a, b, c] * p4_2[b, d])
print("=== 1. Equation 8.31 rebuilds the joint from the picture ===")
print(f"the factorized joint sums to {joint.sum():.12f}")
 
S = 4_000_000
rng = np.random.default_rng(5)
x1 = (rng.random(S) < p1[1]).astype(int)
x5 = (rng.random(S) < p5[1]).astype(int)
x2 = (rng.random(S) < p2_5[x5, 1]).astype(int)
x3 = (rng.random(S) < p3_12[x1, x2, 1]).astype(int)
x4 = (rng.random(S) < p4_2[x2, 1]).astype(int)
emp = np.zeros((2,) * 5)
np.add.at(emp, (x1, x2, x3, x4, x5), 1.0)
emp /= S
print(f"max |empirical - factorized| over 32 cells: "
      f"{np.abs(emp - joint).max():.6f}  ({S:,} samples)")
 
print("\nfree parameters:")
print(f"  full joint over 5 binary variables : {2 ** 5 - 1}")
print(f"  the Figure 8.9(b) factorization    : {1 + 1 + 2 + 4 + 2}")
print("  p(x1):1  p(x5):1  p(x2|x5):2  p(x3|x1,x2):4  p(x4|x2):2")
print(f"\n{'K binary vars':>14} {'full joint':>13} {'2 parents each':>16} "
      f"{'ratio':>12}")
for K in (5, 10, 20, 50, 100):
    f_, c_ = 2.0 ** K - 1, 1 + 2 + 4 * (K - 2)
    print(f"{K:>14} {f_:>13.4g} {c_:>16} {f_ / c_:>12.4g}")
print("this is the entire reason graphical models exist.")
 
# --- the layout depends on the factorization -----------------------------
print("\n=== 2. one joint, two legal graphs ===")
pab = np.array([[0.12, 0.28], [0.33, 0.27]])
pa, pb = pab.sum(1), pab.sum(0)
fwd = pa[:, None] * (pab / pa[:, None])      # p(a) p(b | a)
bwd = pb[None, :] * (pab / pb[None, :])      # p(b) p(a | b)
print("p(a, b) =")
for row in np.round(pab, 6):
    print("   ", row.tolist())
print(f"a -> b, as p(a)p(b|a): max error {np.abs(fwd - pab).max():.2e}")
print(f"b -> a, as p(b)p(a|b): max error {np.abs(bwd - pab).max():.2e}")
print("both graphs are correct and they point opposite ways.")
 
# --- d-separation on Figure 8.11 -----------------------------------------
print("\n=== 3. Example 8.9's four claims, measured ===")
print("Figure 8.11:  a -> b,  a -> d,  b -> c,  c -> d,  d -> e")
N = 4_000_000
r = np.random.default_rng(2024)
a = r.standard_normal(N)
b = 0.9 * a + r.standard_normal(N)
c = 0.8 * b + r.standard_normal(N)
d = 0.7 * a + 0.6 * c + r.standard_normal(N)
e = 1.1 * d + r.standard_normal(N)
V = {"a": a, "b": b, "c": c, "d": d, "e": e}
 
def partial_corr(u, v, given):
    """Zero iff u and v are conditionally independent, for Gaussians."""
    U, W = V[u].copy(), V[v].copy()
    if given:
        Z = np.column_stack([V[g] for g in given] + [np.ones(N)])
        U -= Z @ np.linalg.lstsq(Z, U, rcond=None)[0]
        W -= Z @ np.linalg.lstsq(Z, W, rcond=None)[0]
    else:
        U -= U.mean(); W -= W.mean()
    return float(U @ W / np.sqrt((U @ U) * (W @ W)))
 
claims = (("8.35", "b", "d", ["a", "c"], True),
          ("8.36", "a", "c", ["b"], True),
          ("8.37", "b", "d", ["c"], False),
          ("8.38", "a", "c", ["b", "e"], False))
print(f"\n{'eq':>6} {'claim':>20} {'book says':>12} {'partial corr':>14} "
      f"{'measured':>12} {'':>9}")
for eq, u, v, g, indep in claims:
    pc = partial_corr(u, v, g)
    got = "independent" if abs(pc) < 0.002 else "dependent"
    want = "independent" if indep else "dependent"
    print(f"{eq:>6} {u + ' vs ' + v + ' | ' + ','.join(g):>20} {want:>12} "
          f"{pc:>14.6f} {got:>12} {'ok' if got == want else 'MISMATCH':>9}")
 
# --- the collider, isolated ----------------------------------------------
print("\n=== 4. conditioning on a collider CREATES dependence ===")
print(f"{'conditioning set':>20} {'corr(a, c)':>13}  what it is")
for g, note in ((["b"], "independent, Equation 8.36"),
                (["b", "d"], "d is the collider itself"),
                (["b", "e"], "e is only a DESCENDANT of d")):
    print(f"{','.join(g):>20} {partial_corr('a', 'c', g):>13.6f}  {note}")
print("nothing about a or c changed. Only what we looked at changed.")
 
# --- Equation 8.33: the plate is a factorization -------------------------
print("\n=== 5. Equation 8.33: a plate IS a product ===")
mu, Nf, T = 0.3, 6, 4_000_000
r2 = np.random.default_rng(8)
flips = (r2.random((T, Nf)) < mu).astype(int)
codes = flips @ (2 ** np.arange(Nf))
counts = np.bincount(codes, minlength=2 ** Nf) / T
pred = np.array([np.prod([mu if (k >> i) & 1 else 1 - mu for i in range(Nf)])
                 for k in range(2 ** Nf)])
print(f"mu = {mu}, all {2 ** Nf} sequences of {Nf} flips, {T:,} samples")
print(f"{'sequence':>10} {'measured':>12} {'product of Ber':>16} {'rel err':>10}")
for k in (0, 1, 21, 42, 63):
    seq = "".join(str((k >> i) & 1) for i in range(Nf))
    print(f"{seq:>10} {counts[k]:>12.6f} {pred[k]:>16.6f} "
          f"{abs(counts[k] - pred[k]) / pred[k]:>9.3%}")
print(f"max absolute error over all {2 ** Nf} sequences: "
      f"{np.abs(counts - pred).max():.6f}")
print(f"the predicted probabilities sum to {pred.sum():.10f}")
print("the plate says 'repeat N times'; Equation 8.33 says the joint is a")
print("product of Bernoullis. They are the same statement.")
text
=== 1. Equation 8.31 rebuilds the joint from the picture ===
the factorized joint sums to 1.000000000000
max |empirical - factorized| over 32 cells: 0.000124  (4,000,000 samples)
 
free parameters:
  full joint over 5 binary variables : 31
  the Figure 8.9(b) factorization    : 10
  p(x1):1  p(x5):1  p(x2|x5):2  p(x3|x1,x2):4  p(x4|x2):2
 
 K binary vars    full joint   2 parents each        ratio
             5            31               15        2.067
            10          1023               35        29.23
            20     1.049e+06               75    1.398e+04
            50     1.126e+15              195    5.774e+12
           100     1.268e+30              395    3.209e+27
this is the entire reason graphical models exist.
 
=== 2. one joint, two legal graphs ===
p(a, b) =
    [0.12, 0.28]
    [0.33, 0.27]
a -> b, as p(a)p(b|a): max error 0.00e+00
b -> a, as p(b)p(a|b): max error 5.55e-17
both graphs are correct and they point opposite ways.
 
=== 3. Example 8.9's four claims, measured ===
Figure 8.11:  a -> b,  a -> d,  b -> c,  c -> d,  d -> e
 
    eq                claim    book says   partial corr     measured
  8.35         b vs d | a,c  independent      -0.000320  independent        ok
  8.36           a vs c | b  independent      -0.000079  independent        ok
  8.37           b vs d | c    dependent       0.272172    dependent        ok
  8.38         a vs c | b,e    dependent      -0.146064    dependent        ok
 
=== 4. conditioning on a collider CREATES dependence ===
    conditioning set    corr(a, c)  what it is
                   b     -0.000079  independent, Equation 8.36
                 b,d     -0.237939  d is the collider itself
                 b,e     -0.146064  e is only a DESCENDANT of d
nothing about a or c changed. Only what we looked at changed.
 
=== 5. Equation 8.33: a plate IS a product ===
mu = 0.3, all 64 sequences of 6 flips, 4,000,000 samples
  sequence     measured   product of Ber    rel err
    000000     0.117807         0.117649    0.134%
    100000     0.050480         0.050421    0.118%
    101010     0.009223         0.009261    0.413%
    010101     0.009263         0.009261    0.019%
    111111     0.000735         0.000729    0.823%
max absolute error over all 64 sequences: 0.000158
the predicted probabilities sum to 1.0000000000
the plate says 'repeat N times'; Equation 8.33 says the joint is a
product of Bernoullis. They are the same statement.
figure A directed graphical model is a picture of one factorization of the joint matplotlib
Three panels. Left, a fully connected three-node graph with its factorization written beneath. Middle, Figure 8.9(b)'s five-node graph with its five-factor product. Right, a log-scale plot of free parameter count against number of binary variables, with the full joint curve rising to ten to the thirty and the two-parent curve staying near four hundred. Three panels. Left, a fully connected three-node graph with its factorization written beneath. Middle, Figure 8.9(b)'s five-node graph with its five-factor product. Right, a log-scale plot of free parameter count against number of binary variables, with the full joint curve rising to ten to the thirty and the two-parent curve staying near four hundred.
Two rules build the graph from the factorization; Equation 8.31 reads it back. Checked against four million samples, the maximum discrepancy over all thirty-two cells is 0.000124. The compression is the point: at a hundred binary variables, 1.268e30 free parameters become 395.
figure d-separation reads conditional independence off the picture, and it is right four times out of four matplotlib
Left, Figure 8.11's five-node directed graph with the collider node d and its descendant e annotated. Right, a horizontal bar chart of four measured partial correlations: two indistinguishable from zero in green, and two clearly nonzero in red. Left, Figure 8.11's five-node directed graph with the collider node d and its descendant e annotated. Right, a horizontal bar chart of four measured partial correlations: two indistinguishable from zero in green, and two clearly nonzero in red.
The graph's edges were recovered from the PDF's vector layer, and the recovery is confirmed by the book's own four claims. Measured on four million samples: -0.000320 and -0.000079 where the book says independent, 0.272172 and -0.146064 where it says dependent.
figure Conditioning on a collider creates a dependence that was not there matplotlib
Three scatter plots of a against c after removing the conditioning set. The first is a circular cloud with a flat fitted line; the second and third are visibly tilted ellipses with sloping fitted lines. Three scatter plots of a against c after removing the conditioning set. The first is a circular cloud with a flat fitted line; the second and third are visibly tilted ellipses with sloping fitted lines.
The same four million samples from the same model in all three panels. Given b alone the correlation is -0.000079. Add the collider d and it becomes -0.237939; add only its descendant e and it becomes -0.146064. This is the one d-separation rule where conditioning opens a path instead of blocking it.

The first figure is the notation and its justification side by side. The two left panels are Figure 8.9’s graphs with their factorizations printed underneath, and the mapping is mechanical in both directions: an arrow into a node is a variable in that node’s conditioning bar, and Equation 8.31 turns the picture back into a product. Checked against four million samples, the empirical joint matches the factorized one to 0.0001240.000124 across all thirty-two cells.

The right panel is why anyone bothers. The full joint over KK binary variables has 2K12^K - 1 free numbers. At K=20K = 20 that is already a million; at K=100K = 100 it is 1.268×10301.268\times10^{30}. Assert that each variable has at most two parents and the count becomes 395395 — a ratio of 3.209×10273.209\times10^{27}.

This is not compression in the lossy sense. The factorized model is exactly correct if the independence assertions hold. The graph is how you write down which ones you are asserting, and the parameter count is the measure of how much they buy. Figure 8.9(b)‘s own numbers — 3131 down to 1010 — are modest because five variables is a toy. Past about K=30K = 30 the unfactorized joint cannot be stored at all, so the graph stops being a convenience and becomes the only representation there is.

The second figure is the section’s central claim put to a test the book does not run. Figure 8.11’s edges are not in the PDF’s text layer — the text layer carries the five node labels and nothing about what connects them. Recovering them from the vector layer gives aba \to b, ada \to d, bcb \to c, cdc \to d, ded \to e, and that reconstruction is independently confirmed by Example 8.9 itself: all four claims hold for this DAG, and I could not find another edge set where they all do.

The bars are four partial correlations on four million samples of a linear-Gaussian model, where zero partial correlation is exactly conditional independence rather than a proxy for it. Two come out at 0.000320-0.000320 and 0.000079-0.000079; two come out at 0.2721720.272172 and 0.146064-0.146064. The book justifies all four with the phrase “visual inspection gives us”, and visual inspection turns out to be right.

The third figure isolates the rule that catches people out. Equations 8.36 and 8.38 differ by one symbol in the conditioning set, and the three panels are the same four million samples with three different sets removed.

Given bb alone, the cloud is circular and the correlation is 0.000079-0.000079aa and cc carry no information about each other. Add the collider dd and the cloud tilts: 0.237939-0.237939. Add only ee, which is not the collider but merely its child, and it still tilts: 0.146064-0.146064.

Nothing about aa or cc changed. The model is identical in all three panels; only what we looked at changed. The mechanism is arithmetic: dd is a weighted sum of aa and cc, so fixing dd forces the parts to trade — a high dd with a low aa implies a high cc. Observing ee instead is a blurred observation of dd, which is why 0.146064-0.146064 is the weaker of the two and why the rule has to say “nor any of its descendants” rather than just naming the node.

Every other d-separation rule says conditioning blocks a path. This one says conditioning opens one, and it is the reason a graphical model cannot be read as a simple “information flows along arrows” diagram.

head to tailtail to tailhead to head
shapeunvu \to n \to vunvu \leftarrow n \to vunvu \to n \leftarrow v
namechain / relaycommon cause / forkcollider
blocked whennCn \in CnCn \in CnCn \notin C and no descendant of nn in CC
conditioning on nnblocksblocksopens
example from §8.5abca \to b \to c in Eq. 8.36badb \leftarrow a \to d in Eq. 8.37adca \to d \leftarrow c in Eq. 8.38
measured effect0.000079-0.000079 when blocked0.2721720.272172 when open0.0000790.237939-0.000079 \to -0.237939
directedundirectedfactor graph
also calledBayesian networkMarkov random field
§8.5.3 figure8.12(a)8.12(b)8.12(c)
edges carryconditional probabilitiessymmetric compatibilitiesfactor membership
natural forgenerative processesspatial / lattice structuremaking the factorization explicit
pch.quizTag Can you read a graph?
  1. Equation 8.31 writes the joint as a product over nodes. What is each factor conditioned on?

    pch.quizShowAnswer

    B — The parents of that node — the nodes with arrows pointing into it — One factor per node, conditioned on its parents. Checked against four million samples on Figure 8.9(b), the factorized joint matches the empirical one to 0.000124 across all thirty-two cells. Run the rule backwards and it also tells you how to build the graph from a factorization.

  2. Why is the factorization worth writing down at all?

    pch.quizShowAnswer

    B — The parameter count collapses — at 100 binary variables, 1.268e30 free parameters become 395 — And it is exact, not approximate, provided the independence assertions hold. Past about K = 30 the unfactorized joint cannot be stored at all, so the graph stops being a convenience and becomes the only representation there is.

  3. Arrows meet head to head at node n on a trail. When is that trail blocked at n?

    pch.quizShowAnswer

    B — When neither n NOR any of its descendants is in the conditioning set — This is the rule that runs backwards. Measured on Figure 8.11: corr(a, c) is -0.000079 given b alone, -0.237939 once the collider d is added, and -0.146064 once only d's descendant e is added. Conditioning on a collider CREATES a dependence that was not there.

  4. Example 8.38 says a is NOT independent of c given b and e, even though e is not the collider. Why?

    pch.quizShowAnswer

    B — Because e is a descendant of the collider d, and the head-to-head rule mentions descendants — Observing e is a blurred observation of d, so it opens the head-to-head meeting partially. Measured, it gives -0.146064 against -0.237939 for conditioning on d itself — weaker, but nowhere near zero. That is exactly why the rule says 'nor any of its descendants'.

  5. The book warns that the graph layout depends on the choice of factorization. What does that imply?

    pch.quizShowAnswer

    B — The same joint distribution admits graphs whose arrows point in opposite directions, both exactly correct — Measured: p(a)p(b|a) reconstructs a joint to 0.00e+00 and p(b)p(a|b) reconstructs the same joint to 5.55e-17. One graph says a to b, the other says b to a. This is why reading causation off an arrow is an error unless you have made the additional assumptions the book mentions in its margin.

  6. What does plate notation assert about the variables inside the plate?

    pch.quizShowAnswer

    B — That the joint factorizes into a product over the repeated index — they are identically distributed given the parent — Measured on 64 sequences of six Bernoulli flips: the sequences 101010 and 010101 are predicted to be equally likely at 0.009261 and measured at 0.009223 and 0.009263. Order carries no information, which is what drawing one node instead of six asserts. Statistical independence means the distribution factorizes.

Exercise 1 – Read the joint off the picture

Section titled “Exercise 1 – Read the joint off the picture”
Section titled “Exercise 4 – One joint, two legal graphs”
  • A directed graphical model is a picture of one factorization of the joint. Nodes are random variables; an arrow from a to b carries the conditional probability of b given a.
  • Two rules build the graph: one node per random variable, and an arrow into each node from every variable its conditional is conditioned on.
  • Equation 8.31 reads it back: the joint is a product with one factor per node, each conditioned on its parents — the nodes with arrows pointing into it. Verified against four million samples to a maximum error of 0.000124 over all thirty-two cells.
  • The compression is the whole point. Five binary variables: 31 free parameters become 10. A hundred binary variables: 1.268e30 become 395. Past about thirty variables the unfactorized joint cannot be stored at all.
  • The layout depends on the factorization, not on the joint. The same joint is reconstructed exactly by p(a)p(b given a) and to 5.55e-17 by p(b)p(a given b), and those are graphs pointing opposite ways. An arrow means causation only with additional assumptions.
  • Shaded nodes are observed; unshaded are latent. A plate repeats everything inside it N times, which is exactly Equation 8.33’s product. A hyperprior is a prior on the parameters of a prior, and deterministic parameters lose their circle.
  • d-separation answers conditional independence by tracing trails — paths that ignore arrow direction — between the two sets of nodes.
  • Head to tail and tail to tail are blocked when the middle node is IN the conditioning set. A relay and a common cause both stop conducting once you observe the middle.
  • Head to head is blocked when the node is NOT in the conditioning set and neither is any of its descendants. This is the rule that runs backwards: conditioning on a collider OPENS the path.
  • All trails must be blocked. One open trail is enough for dependence — Equation 8.37 is dependent, measured at 0.272172, because of a single unblocked trail.
  • Example 8.9 verified on four million samples: -0.000320, -0.000079 where the book says independent; 0.272172, -0.146064 where it says dependent. Four for four.
  • The collider effect, isolated: corr(a, c) is -0.000079 given b, -0.237939 once the collider d is added, and -0.146064 once only d’s descendant e is added. Nothing about the model changed; only what we looked at changed.
  • A missing arrow is not marginal independence. There is no edge between a and c in Figure 8.11, and they are still dependent given b and e.
  • Three families, from Section 8.5.3: directed models (Bayesian networks), undirected models (Markov random fields), and factor graphs. Not every distribution can be represented in a given choice.

Next: the graph shows your structural choices, and now you have to pick among them. Model Selection

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading