Bayesian Networks and the Joint Distribution
A directed acyclic graph with a conditional probability table at each node, the product that defines what it means, and the conditional independences that make it compact.
The full joint distribution answers every probabilistic question, and it is useless in practice: over Boolean variables it has entries, nobody can supply them, and nobody could store them. A Bayesian network keeps the power of the joint while paying for only the dependences that actually exist.
What a network is
A Bayesian network is a directed acyclic graph in which
- each node is a random variable,
- an arrow from to says that is a parent of , so has a direct influence on , and
- each node carries a conditional probability table (CPT) giving , one row per combination of parent values.
Each CPT row must sum to one, so for a Boolean variable only the probability of true is written and the other follows. A Boolean node with Boolean parents therefore needs numbers, and a root node needs exactly one.
The burglary network
The example that carries this whole path is Judea Pearl's burglar alarm, the one Russell and Norvig use to introduce Bayesian networks. You are at work. A burglar alarm at home responds fairly reliably to burglary and, being an earthquake detector of sorts, occasionally to minor earthquakes. Two neighbours, John and Mary, have promised to call when they hear it. John nearly always calls when he hears the alarm but sometimes mistakes the telephone for it; Mary likes loud music and often misses the alarm altogether.
The graph has arrows , , , , and nothing else. That is a set of claims: John and Mary do not perceive burglaries directly, they do not notice minor earthquakes, and they do not confer before calling. Everything that could make the alarm fail - a dead battery, a cut wire - or make a neighbour fail to report it is folded into the numbers rather than modelled. That is not sloppiness; it is how a small agent copes with a large world.
What a network means
The semantics is a single equation. For any complete assignment to all the variables,
where denotes the values of 's parents inside the assignment. The network is the joint distribution, written as a product of its CPT entries.
Worked example: one full event
The alarm has sounded, neither a burglary nor an earthquake has happened, and both neighbours call. Reading one entry from each table:
Runs in your browser. The first run downloads the Python runtime (~10 MB), then it is cached.
Because every one of the 32 joint entries can be produced this way, anything the full joint could answer, the network can answer too - by summing the relevant entries. The next lesson is about doing that without producing all 32.
Why the network is so much smaller
Count the numbers. Burglary and Earthquake need one each, Alarm has two parents and needs four, and each call has one parent and needs two:
against independent entries in the full joint table. The gap widens explosively: with 30 Boolean variables, each with at most five parents, the network needs at most numbers where the joint needs over a billion. The saving is locality: each variable is influenced directly by only a few others.
The network below is this one, and every number in it is exact - the posteriors come from summing all 32 assignments, not from sampling. Click a node to say what you know. Start with both neighbours calling: a burglary goes to 28.4%, which is already worth sitting with, since the calls are excellent evidence about the alarm and the alarm is a poor witness to burglary. Then add the earthquake. It makes the calls more likely, and it sends the burglary back towards nothing.
Interactive: say what you know, watch what follows
Click a node to cycle it: unknown, happened, did not happen.
- P(burglary)
- 0.1%
- P(earthquake)
- 0.2%
- P(alarm)
- 0.3%
- P(evidence)
- 1.000000
Nothing is known yet, so every node sits at its prior: a burglary at 0.1%, an earthquake at 0.2%. Click a neighbour and watch the influence travel up the arrows to the alarm and then down to the other neighbour, even though no arrow joins the two neighbours at all.
The independences the graph asserts
Apply the chain rule to any ordering of the variables:
Comparing with the semantics above, the network is a correct representation exactly when, for every variable,
for some ordering in which every node comes after its parents. In words: each variable is conditionally independent of its other predecessors given its parents. Two further consequences follow from the graph alone.
- A node is conditionally independent of its non-descendants given its parents. In the burglary network, is independent of , and once is known.
- A node is conditionally independent of every other node given its Markov blanket: its parents, its children, and its children's other parents. 's blanket is , so given the alarm state and the earthquake state, the two phone calls tell you nothing further about a burglary.
Ordering matters when you build one. Add the nodes in the order and you are forced to draw , then both calls into , then , then and : two more links and three more numbers than the causal network, some of them describing relationships that are genuinely hard to assess. Putting causes before effects is what keeps the network small.
Before the quiz
Be able to write down the product that defines the joint, evaluate it for a complete event, count the numbers a network needs against the full table, and say what a Markov blanket is and why conditioning on it isolates a node.
References & further reading
- Stuart Russell, Peter Norvig, Artificial Intelligence: A Modern Approach, Pearson (3rd edition), 2010· Kudos AI reference library
Copyrighted works are cited for reference only and are not hosted here; please consult the publisher for access.
Unlock the full path
This first lesson is free. Enrol to take the mastery quiz, earn XP, and unlock every module, with more interactive, runnable examples throughout.