Skip to Content

Factorization

A Bayesian network represents a Joint Probability Distribution (JPD) as a product of probabilities, one for each node given its parents. This is the factorization of the JPD. How do we get from a Joint Probability Table to this product? We begin with two variables.

The Joint Distribution of Fever and Pneumonia

The Joint Probability Table for Fever\mathit{Fever} and Pneumonia\mathit{Pneumonia} has one row for each combination of their states. The last row gives the probability that a patient has both high fever and pneumonia.

Fever\mathit{Fever}Pneumonia\mathit{Pneumonia}Joint probability
None\mathrm{None}False\mathrm{False}P(Fever=None,Pneumonia=False)\mathrm{P}(\mathit{Fever}=\mathrm{None},\mathit{Pneumonia}=\mathrm{False})
None\mathrm{None}True\mathrm{True}P(Fever=None,Pneumonia=True)\mathrm{P}(\mathit{Fever}=\mathrm{None},\mathit{Pneumonia}=\mathrm{True})
Low\mathrm{Low}False\mathrm{False}P(Fever=Low,Pneumonia=False)\mathrm{P}(\mathit{Fever}=\mathrm{Low},\mathit{Pneumonia}=\mathrm{False})
Low\mathrm{Low}True\mathrm{True}P(Fever=Low,Pneumonia=True)\mathrm{P}(\mathit{Fever}=\mathrm{Low},\mathit{Pneumonia}=\mathrm{True})
High\mathrm{High}False\mathrm{False}P(Fever=High,Pneumonia=False)\mathrm{P}(\mathit{Fever}=\mathrm{High},\mathit{Pneumonia}=\mathrm{False})
High\mathrm{High}True\mathrm{True}P(Fever=High,Pneumonia=True)\mathrm{P}(\mathit{Fever}=\mathrm{High},\mathit{Pneumonia}=\mathrm{True})

Marginalization. What is the probability that a patient has pneumonia? Three rows have Pneumonia\mathit{Pneumonia} equal to True\mathrm{True}, one for each possible state of Fever\mathit{Fever}. Adding those entries gives the marginal probability of pneumonia.

P(Pneumonia=True)=P(Fever=None,Pneumonia=True)+P(Fever=Low,Pneumonia=True)+P(Fever=High,Pneumonia=True).\begin{aligned} &\mathrm{P}(\mathit{Pneumonia}=\mathrm{True})\\ &=\mathrm{P}(\mathit{Fever}=\mathrm{None},\mathit{Pneumonia}=\mathrm{True})\\ &\quad{}+\mathrm{P}(\mathit{Fever}=\mathrm{Low},\mathit{Pneumonia}=\mathrm{True})\\ &\quad{}+\mathrm{P}(\mathit{Fever}=\mathrm{High},\mathit{Pneumonia}=\mathrm{True}). \end{aligned}

Conditioning. Suppose we know that a patient has high fever. Only the last two rows apply. Their sum is P(Fever=High)\mathrm{P}(\mathit{Fever}=\mathrm{High}). The last row is the part of that sum for which Pneumonia\mathit{Pneumonia} is True\mathrm{True}. Dividing that entry by the sum gives the conditional probability of pneumonia given high fever.

P(Pneumonia=True∣Fever=High)=P(Fever=High,Pneumonia=True)P(Fever=High).\begin{aligned} &\mathrm{P}(\mathit{Pneumonia}=\mathrm{True}\mid \mathit{Fever}=\mathrm{High})\\ &=\frac{\mathrm{P}(\mathit{Fever}=\mathrm{High},\mathit{Pneumonia}=\mathrm{True})} {\mathrm{P}(\mathit{Fever}=\mathrm{High})}. \end{aligned}

The Product Rule

Multiplying both sides of the conditioning equation by P(Fever=High)\mathrm{P}(\mathit{Fever}=\mathrm{High}) gives the probability that both events occur. This is the product rule.

P(Fever=High,Pneumonia=True)=P(Pneumonia=True∣Fever=High)×P(Fever=High).\begin{aligned} &\mathrm{P}(\mathit{Fever}=\mathrm{High},\mathit{Pneumonia}=\mathrm{True})\\ &=\mathrm{P}(\mathit{Pneumonia}=\mathrm{True}\mid \mathit{Fever}=\mathrm{High})\\ &\quad{}\times \mathrm{P}(\mathit{Fever}=\mathrm{High}). \end{aligned}

The same table entry can be obtained by conditioning on pneumonia first. In that order the product is

P(Fever=High,Pneumonia=True)=P(Fever=High∣Pneumonia=True)×P(Pneumonia=True).\begin{aligned} &\mathrm{P}(\mathit{Fever}=\mathrm{High},\mathit{Pneumonia}=\mathrm{True})\\ &=\mathrm{P}(\mathit{Fever}=\mathrm{High}\mid \mathit{Pneumonia}=\mathrm{True})\\ &\quad{}\times \mathrm{P}(\mathit{Pneumonia}=\mathrm{True}). \end{aligned}

Both products give the same joint probability. Each conditional probability is defined when the event to the right of its conditioning bar has positive probability.

The Joint Probability Table for the Medical Example

We now add Age\mathit{Age}, TB Contact\mathit{TB\ Contact}, and Active TB\mathit{Active\ TB} to the example.

The Joint Probability Table (JPT) has one row for every combination of the following states.

Short nameLong namePossible states
A\mathit{A}Age\mathit{Age}<20\lt 20, 20–6020\text{–}60, >60\gt 60
C\mathit{C}TB Contact\mathit{TB\ Contact}True\mathrm{True}, False\mathrm{False}
P\mathit{P}Pneumonia\mathit{Pneumonia}True\mathrm{True}, False\mathrm{False}
T\mathit{T}Active TB\mathit{Active\ TB}True\mathrm{True}, False\mathrm{False}
F\mathit{F}Fever\mathit{Fever}None\mathrm{None}, Low\mathrm{Low}, High\mathrm{High}

Joint Probability Table

Each row represents a possible patient profile. The ellipsis marks the joint probability still to be supplied.

A\mathit{A} = Age\mathit{Age}C\mathit{C} = TB Contact\mathit{TB\ Contact}P\mathit{P} = Pneumonia\mathit{Pneumonia}T\mathit{T} = Active TB\mathit{Active\ TB}F\mathit{F} = Fever\mathit{Fever}
A\mathit{A}Age\mathit{Age}C\mathit{C}TB Contact\mathit{TB\ Contact}P\mathit{P}Pneumonia\mathit{Pneumonia}T\mathit{T}Active TB\mathit{Active\ TB}F\mathit{F}Fever\mathit{Fever}Probability
<20FalseFalseFalseNone…
<20FalseFalseFalseLow…
<20FalseFalseFalseHigh…
<20FalseFalseTrueNone…
<20FalseFalseTrueLow…
<20FalseFalseTrueHigh…
<20FalseTrueFalseNone…
<20FalseTrueFalseLow…
<20FalseTrueFalseHigh…
<20FalseTrueTrueNone…
<20FalseTrueTrueLow…
<20FalseTrueTrueHigh…
<20TrueFalseFalseNone…
<20TrueFalseFalseLow…
<20TrueFalseFalseHigh…
<20TrueFalseTrueNone…
<20TrueFalseTrueLow…
<20TrueFalseTrueHigh…
<20TrueTrueFalseNone…
<20TrueTrueFalseLow…
<20TrueTrueFalseHigh…
<20TrueTrueTrueNone…
<20TrueTrueTrueLow…
<20TrueTrueTrueHigh…
20–60FalseFalseFalseNone…
20–60FalseFalseFalseLow…
20–60FalseFalseFalseHigh…
20–60FalseFalseTrueNone…
20–60FalseFalseTrueLow…
20–60FalseFalseTrueHigh…
20–60FalseTrueFalseNone…
20–60FalseTrueFalseLow…
20–60FalseTrueFalseHigh…
20–60FalseTrueTrueNone…
20–60FalseTrueTrueLow…
20–60FalseTrueTrueHigh…
20–60TrueFalseFalseNone…
20–60TrueFalseFalseLow…
20–60TrueFalseFalseHigh…
20–60TrueFalseTrueNone…
20–60TrueFalseTrueLow…
20–60TrueFalseTrueHigh…
20–60TrueTrueFalseNone…
20–60TrueTrueFalseLow…
20–60TrueTrueFalseHigh…
20–60TrueTrueTrueNone…
20–60TrueTrueTrueLow…
20–60TrueTrueTrueHigh…
>60FalseFalseFalseNone…
>60FalseFalseFalseLow…
>60FalseFalseFalseHigh…
>60FalseFalseTrueNone…
>60FalseFalseTrueLow…
>60FalseFalseTrueHigh…
>60FalseTrueFalseNone…
>60FalseTrueFalseLow…
>60FalseTrueFalseHigh…
>60FalseTrueTrueNone…
>60FalseTrueTrueLow…
>60FalseTrueTrueHigh…
>60TrueFalseFalseNone…
>60TrueFalseFalseLow…
>60TrueFalseFalseHigh…
>60TrueFalseTrueNone…
>60TrueFalseTrueLow…
>60TrueFalseTrueHigh…
>60TrueTrueFalseNone…
>60TrueTrueFalseLow…
>60TrueTrueFalseHigh…
>60TrueTrueTrueNone…
>60TrueTrueTrueLow…
>60TrueTrueTrueHigh…

Joint Probability Calculator

VariableSelected stateProbability
0.20
0.10
0.95
0.02
0.50

Joint probability0.20 × 0.10 × 0.95 × 0.02 × 0.50 = 0.00019 (0.019%)

With five variables and 72 rows, the JPT looks like a manageable way to represent the distribution. Yet adding a single yes-or-no variable would double the number of rows to 144. Even adding a state to an existing variable matters. A fourth state of Fever\mathit{Fever} would take the original table from 72 rows to 96. For nn binary variables, the JPT has 2n2^n rows.

Consider the Quick Medical Reference diagnostic model, which related about 600 diseases to about 4,000 possible findings. Conditioning on a patient’s findings restricts the calculation to the rows consistent with those observations. To obtain a probability for one disease, we still have to marginalize over the others. With 600 diseases, each either present or absent, there are 26002^{600} combinations of disease states alone. Summing the relevant rows directly is infeasible. In their 1999 study, Jaakkola and Jordan found that even a specialized exact algorithm was practical for only four of the 48 cases they examined. Jaakkola and Jordan, “Variational Probabilistic Inference and the QMR-DT Network” 

How can we represent the same Joint Probability Distribution more compactly? When we know that certain variables are independent given others, we can reuse the same conditional probabilities across many rows of the JPT. A Bayesian network records these independences in a graph. Its local tables can be much smaller, and we can use them to compute marginal and conditional probabilities. To see where these tables come from, we return to the product rule. Barber, “Belief Networks,” §3.1 

The Chain Rule

The product rule also applies when one of its arguments is a group of variables. For X\mathit{X}, Y\mathit{Y}, and Z\mathit{Z}, the first application treats (Y,Z)(\mathit{Y},\mathit{Z}) as a group. The second application expands P(Y,Z)\mathrm{P}(\mathit{Y},\mathit{Z}).

P(X,Y,Z)=P(X∣Y,Z) P(Y,Z)=P(X∣Y,Z) P(Y∣Z) P(Z).\begin{aligned} &\mathrm{P}(\mathit{X},\mathit{Y},\mathit{Z})\\ &\quad=\mathrm{P}(\mathit{X}\mid \mathit{Y},\mathit{Z})\,\mathrm{P}(\mathit{Y},\mathit{Z})\\ &\quad=\mathrm{P}(\mathit{X}\mid \mathit{Y},\mathit{Z})\,\mathrm{P}(\mathit{Y}\mid \mathit{Z})\,\mathrm{P}(\mathit{Z}). \end{aligned}

This repeated application of the product rule is the chain rule. For any chosen order, each successive term conditions one variable on all the variables still in the joint probability. The last term is a marginal probability. For an arbitrary number of variables,

P(X1,…,Xn)=P(X1∣X2,…,Xn)×P(X2∣X3,…,Xn)×⋯×P(Xn−1∣Xn) P(Xn).\begin{aligned} &\mathrm{P}(\mathit{X}_1,\ldots,\mathit{X}_n)\\ &\quad=\mathrm{P}(\mathit{X}_1\mid \mathit{X}_2,\ldots,\mathit{X}_n)\\ &\qquad{}\times \mathrm{P}(\mathit{X}_2\mid \mathit{X}_3,\ldots,\mathit{X}_n)\\ &\qquad{}\times\cdots\times \mathrm{P}(\mathit{X}_{n-1}\mid \mathit{X}_n)\,\mathrm{P}(\mathit{X}_n). \end{aligned}

Applying the Chain Rule to the Joint Probability Distribution

The JPT lists the five-variable distribution one row at a time. The chain rule gives a product for that same distribution. We choose the order Fever\mathit{Fever}, Pneumonia\mathit{Pneumonia}, Active TB\mathit{Active\ TB}, Age\mathit{Age}, and TB Contact\mathit{TB\ Contact}, and write the distribution as P(F,P,T,A,C)\mathrm{P}(\mathit{F},\mathit{P},\mathit{T},\mathit{A},\mathit{C}).

Each line below equals the one above it. The underline marks the joint probability that is expanded on the next line.

P(F,P,T,A,C)\mathrm{P}(\mathit{F},\mathit{P},\mathit{T},\mathit{A},\mathit{C})
=P(F∣P,T,A,C)=\mathrm{P}(\mathit{F}\mid \mathit{P},\mathit{T},\mathit{A},\mathit{C}) ×\times P(P,T,A,C)\mathrm{P}(\mathit{P},\mathit{T},\mathit{A},\mathit{C})
=P(F∣P,T,A,C)=\mathrm{P}(\mathit{F}\mid \mathit{P},\mathit{T},\mathit{A},\mathit{C}) ×P(P∣T,A,C)\times \mathrm{P}(\mathit{P}\mid \mathit{T},\mathit{A},\mathit{C}) ×\times P(T,A,C)\mathrm{P}(\mathit{T},\mathit{A},\mathit{C})
=P(F∣P,T,A,C)=\mathrm{P}(\mathit{F}\mid \mathit{P},\mathit{T},\mathit{A},\mathit{C}) ×P(P∣T,A,C)\times \mathrm{P}(\mathit{P}\mid \mathit{T},\mathit{A},\mathit{C}) ×P(T∣A,C)\times \mathrm{P}(\mathit{T}\mid \mathit{A},\mathit{C}) ×\times P(A,C)\mathrm{P}(\mathit{A},\mathit{C})
=P(F∣P,T,A,C)=\mathrm{P}(\mathit{F}\mid \mathit{P},\mathit{T},\mathit{A},\mathit{C}) ×P(P∣T,A,C)\times \mathrm{P}(\mathit{P}\mid \mathit{T},\mathit{A},\mathit{C}) ×P(T∣A,C)\times \mathrm{P}(\mathit{T}\mid \mathit{A},\mathit{C}) ×P(A∣C)\times \mathrm{P}(\mathit{A}\mid \mathit{C}) ×P(C)\times \mathrm{P}(\mathit{C})

The first equality separates P(F∣P,T,A,C)\mathrm{P}(\mathit{F}\mid \mathit{P},\mathit{T},\mathit{A},\mathit{C}) from the joint probability of the remaining variables, P(P,T,A,C)\mathrm{P}(\mathit{P},\mathit{T},\mathit{A},\mathit{C}). Expanding that remainder gives P(P∣T,A,C)\mathrm{P}(\mathit{P}\mid \mathit{T},\mathit{A},\mathit{C}) and a new remainder of P(T,A,C)\mathrm{P}(\mathit{T},\mathit{A},\mathit{C}). The same step yields P(T∣A,C)\mathrm{P}(\mathit{T}\mid \mathit{A},\mathit{C}) and finally P(A∣C)P(C)\mathrm{P}(\mathit{A}\mid \mathit{C})\mathrm{P}(\mathit{C}).

The final product has five terms. We will use each term in turn to construct its graphical equivalent.

P(F∣P,T,A,C) ×\mathrm{P}(\mathit{F}\mid {\color{#72329d}{\mathit{P},\mathit{T},\mathit{A},\mathit{C}}})\,\times
P(P∣T,A,C) ×\mathrm{P}(\mathit{P}\mid {\color{#007539}{\mathit{T},\mathit{A},\mathit{C}}})\,\times
P(T∣A,C) ×\mathrm{P}(\mathit{T}\mid {\color{#0068ac}{\mathit{A},\mathit{C}}})\,\times
P(A∣C) ×\mathrm{P}(\mathit{A}\mid {\color{#b92331}{\mathit{C}}})\,\times
P(C)\mathrm{P}(\mathit{C})

The Chain Rule as a Graph

We now write the product as a directed graph. We begin with a node for each of the five variables. For each term in the product, we add an arc from every variable on the right of the conditioning bar to the variable on its left.

The first term, P(F∣P,T,A,C)\mathrm{P}(\mathit{F}\mid \mathit{P},\mathit{T},\mathit{A},\mathit{C}), gives the probability of Fever (F)\mathit{Fever\ (F)} given Pneumonia (P)\mathit{Pneumonia\ (P)}, Active TB (T)\mathit{Active\ TB\ (T)}, Age (A)\mathit{Age\ (A)}, and TB Contact (C)\mathit{TB\ Contact\ (C)}. To express this term in the graph, we add four purple arcs, one from each conditioning variable into Fever\mathit{Fever}.

P(F∣P,T,A,C) ×\mathrm{P}(\mathit{F}\mid {\color{#72329d}{\mathit{P},\mathit{T},\mathit{A},\mathit{C}}})\,\times
…
Age (A)TB Contact (C)Pneumonia (P)Active TB (T)Fever (F)

The next term is P(P∣T,A,C)\mathrm{P}(\mathit{P}\mid \mathit{T},\mathit{A},\mathit{C}). We add three green arcs into Pneumonia\mathit{Pneumonia}, one each from Active TB\mathit{Active\ TB}, Age\mathit{Age}, and TB Contact\mathit{TB\ Contact}.

P(F∣P,T,A,C) ×\mathrm{P}(\mathit{F}\mid {\color{#72329d}{\mathit{P},\mathit{T},\mathit{A},\mathit{C}}})\,\times
P(P∣T,A,C) ×\mathrm{P}(\mathit{P}\mid {\color{#007539}{\mathit{T},\mathit{A},\mathit{C}}})\,\times
…
Age (A)TB Contact (C)Pneumonia (P)Active TB (T)Fever (F)

The term P(T∣A,C)\mathrm{P}(\mathit{T}\mid \mathit{A},\mathit{C}) adds two blue arcs into Active TB\mathit{Active\ TB}, one from Age\mathit{Age} and one from TB Contact\mathit{TB\ Contact}.

P(F∣P,T,A,C) ×\mathrm{P}(\mathit{F}\mid {\color{#72329d}{\mathit{P},\mathit{T},\mathit{A},\mathit{C}}})\,\times
P(P∣T,A,C) ×\mathrm{P}(\mathit{P}\mid {\color{#007539}{\mathit{T},\mathit{A},\mathit{C}}})\,\times
P(T∣A,C) ×\mathrm{P}(\mathit{T}\mid {\color{#0068ac}{\mathit{A},\mathit{C}}})\,\times
…
Age (A)TB Contact (C)Pneumonia (P)Active TB (T)Fever (F)

The term P(A∣C)\mathrm{P}(\mathit{A}\mid \mathit{C}) adds a red arc from TB Contact\mathit{TB\ Contact} to Age\mathit{Age}. Its direction follows the chosen order in the chain rule.

P(F∣P,T,A,C) ×\mathrm{P}(\mathit{F}\mid {\color{#72329d}{\mathit{P},\mathit{T},\mathit{A},\mathit{C}}})\,\times
P(P∣T,A,C) ×\mathrm{P}(\mathit{P}\mid {\color{#007539}{\mathit{T},\mathit{A},\mathit{C}}})\,\times
P(T∣A,C) ×\mathrm{P}(\mathit{T}\mid {\color{#0068ac}{\mathit{A},\mathit{C}}})\,\times
P(A∣C) ×\mathrm{P}(\mathit{A}\mid {\color{#b92331}{\mathit{C}}})\,\times
…
Age (A)TB Contact (C)Pneumonia (P)Active TB (T)Fever (F)

The last term, P(C)\mathrm{P}(\mathit{C}), is a marginal probability. There is no conditioning variable in this term, so TB Contact\mathit{TB\ Contact} receives no incoming arc. This completes the graph.

P(F∣P,T,A,C) ×\mathrm{P}(\mathit{F}\mid {\color{#72329d}{\mathit{P},\mathit{T},\mathit{A},\mathit{C}}})\,\times
P(P∣T,A,C) ×\mathrm{P}(\mathit{P}\mid {\color{#007539}{\mathit{T},\mathit{A},\mathit{C}}})\,\times
P(T∣A,C) ×\mathrm{P}(\mathit{T}\mid {\color{#0068ac}{\mathit{A},\mathit{C}}})\,\times
P(A∣C) ×\mathrm{P}(\mathit{A}\mid {\color{#b92331}{\mathit{C}}})\,\times
P(C)\mathrm{P}(\mathit{C})
Age (A)TB Contact (C)Pneumonia (P)Active TB (T)Fever (F)

The graph is fully connected. Each of the five nodes is joined to each of the other four, giving ten arcs in total. Any ordering of these five variables produces the same ten connected pairs. The order determines the direction of each arc. For example, interchanging Age\mathit{Age} and TB Contact\mathit{TB\ Contact} in the chain rule reverses the red arc between them.

So far we have used probability calculus alone. Each arc represents a possible dependence allowed by the chain rule. The fully connected graph can therefore represent any joint distribution over these five variables.

Encoding Independence Assumptions

Which of these possible dependencies do we need in practice? We now turn to a domain expert, a doctor. Looking at the fully connected graph, the doctor judges that some variables are independent, either outright or once certain other variables are known. The doctor expresses that knowledge in three assumptions.

  • Age\mathit{Age} and TB Contact\mathit{TB\ Contact} are independent.
  • Given Age\mathit{Age}, Pneumonia\mathit{Pneumonia} is independent of the pair Active TB\mathit{Active\ TB} and TB Contact\mathit{TB\ Contact}.
  • Given Pneumonia\mathit{Pneumonia} and Active TB\mathit{Active\ TB}, Fever\mathit{Fever} is independent of the pair Age\mathit{Age} and TB Contact\mathit{TB\ Contact}.

Arcs removed by the doctor’s assumptions. The first assumption removes the arc from TB Contact\mathit{TB\ Contact} to Age\mathit{Age}. The second removes the arcs from Active TB\mathit{Active\ TB} and TB Contact\mathit{TB\ Contact} to Pneumonia\mathit{Pneumonia}. The third removes the arcs from Age\mathit{Age} and TB Contact\mathit{TB\ Contact} to Fever\mathit{Fever}. Together, the three assumptions remove five of the ten arcs. Each dashed arc corresponds to a crossed-out conditioning variable in the product.

P(F∣P,T,A,C) ×\mathrm{P}(\mathit{F}\mid {\color{#72329d}{\mathit{P},\mathit{T},\sout{\mathit{A},\mathit{C}}}})\,\times
P(P∣T,A,C) ×\mathrm{P}(\mathit{P}\mid {\color{#007539}{\sout{\mathit{T},}\mathit{A}\sout{,\mathit{C}}}})\,\times
P(T∣A,C) ×\mathrm{P}(\mathit{T}\mid {\color{#0068ac}{\mathit{A},\mathit{C}}})\,\times
P(A∣C) ×\mathrm{P}(\mathit{A}{\color{#b92331}{\sout{\mid \mathit{C}}}})\,\times
P(C)\mathrm{P}(\mathit{C})
Age (A)TB Contact (C)Pneumonia (P)Active TB (T)Fever (F)

The simplified chain rule. With those arcs removed, P(A∣C)\mathrm{P}(\mathit{A}\mid \mathit{C}) becomes P(A)\mathrm{P}(\mathit{A}), P(P∣T,A,C)\mathrm{P}(\mathit{P}\mid \mathit{T},\mathit{A},\mathit{C}) becomes P(P∣A)\mathrm{P}(\mathit{P}\mid \mathit{A}), and P(F∣P,T,A,C)\mathrm{P}(\mathit{F}\mid \mathit{P},\mathit{T},\mathit{A},\mathit{C}) becomes P(F∣P,T)\mathrm{P}(\mathit{F}\mid \mathit{P},\mathit{T}). The parents of Active TB\mathit{Active\ TB} are still Age\mathit{Age} and TB Contact\mathit{TB\ Contact}.

P(F∣P,T) ×\mathrm{P}(\mathit{F}\mid {\color{#72329d}{\mathit{P},\mathit{T}}})\,\times
P(P∣A) ×\mathrm{P}(\mathit{P}\mid {\color{#007539}{\mathit{A}}})\,\times
P(T∣A,C) ×\mathrm{P}(\mathit{T}\mid {\color{#0068ac}{\mathit{A},\mathit{C}}})\,\times
P(A) ×\mathrm{P}(\mathit{A})\,\times
P(C)\mathrm{P}(\mathit{C})
Age (A)TB Contact (C)Pneumonia (P)Active TB (T)Fever (F)

The Qualitative Structure

The graph we obtain by removing those five arcs is the qualitative structure of a Bayesian network.

P(F,P,T,A,C)=P(F∣P,T) P(P∣A)×P(T∣A,C) P(A) P(C).\begin{aligned} &\mathrm{P}(\mathit{F},\mathit{P},\mathit{T},\mathit{A},\mathit{C})\\ &\quad=\mathrm{P}(\mathit{F}\mid \mathit{P},\mathit{T})\,\mathrm{P}(\mathit{P}\mid \mathit{A})\\ &\qquad{}\times \mathrm{P}(\mathit{T}\mid \mathit{A},\mathit{C})\,\mathrm{P}(\mathit{A})\,\mathrm{P}(\mathit{C}). \end{aligned}
Loading SVG...
P(A)\mathrm{P}(\mathit{A})P(C)\mathrm{P}(\mathit{C})P(P∣A)\mathrm{P}(\mathit{P}\mid \mathit{A})P(T∣A,C)\mathrm{P}(\mathit{T}\mid \mathit{A},\mathit{C})P(F∣P,T)\mathrm{P}(\mathit{F}\mid \mathit{P},\mathit{T})

Quantitative Structure

With the qualitative structure in place, we can now supply the quantitative part of the network by specifying the probabilities in each node’s table. The figure uses illustrative values. The doctor might estimate these probabilities from his patient database, or we could look them up in medical textbooks.

Loading SVG...
Age (3 probability cells)
<2020–60>60
50%30%20%
TB Contact (2 probability cells)
FalseTrue
90%10%
Pneumonia given Age (6 probability cells)
AgeFalseTrue
<2099%1%
20–6098%2%
>6095%5%
Active TB given Age and TB Contact (12 probability cells)
AgeTB ContactFalseTrue
<20False99.8%0.2%
<20True98.2%1.8%
20–60False99.9%0.1%
20–60True99%1%
>60False99.7%0.3%
>60True98%2%
Fever given Pneumonia and Active TB (12 probability cells)
PneumoniaActive TBNoneLowHigh
FalseFalse80%15%5%
FalseTrue45%50%5%
TrueFalse45%5%50%
TrueTrue5%45%50%

With these probability estimates, the Bayesian network is fully specified. We can now use it for inference.

How Large Are the Tables?

Consider the Conditional Probability Table (CPT) for Fever\mathit{Fever}. The states of Pneumonia\mathit{Pneumonia} and Active TB\mathit{Active\ TB} give four parent rows. Each row contains the probabilities of None\mathrm{None}, Low\mathrm{Low}, and High\mathrm{High}, giving 4 × 3 = 12 probability cells.

Together the node tables contain 3 + 2 + 6 + 12 + 12 = 35 probability cells. They specify all 3 × 2 × 2 × 2 × 3 = 72 entries of the JPT. With the doctor’s independence assumptions, we can represent the entire joint distribution using just under half as many probability cells.

The Populated Joint Probability Table

The probability in each row of the JPT is the product of one entry from each node table. The joint probability calculator shows this calculation for any combination of states.

Joint Probability Table

Each probability is the product of one entry from each of the five local tables.

A\mathit{A} = Age\mathit{Age}C\mathit{C} = TB Contact\mathit{TB\ Contact}P\mathit{P} = Pneumonia\mathit{Pneumonia}T\mathit{T} = Active TB\mathit{Active\ TB}F\mathit{F} = Fever\mathit{Fever}
A\mathit{A}Age\mathit{Age}C\mathit{C}TB Contact\mathit{TB\ Contact}P\mathit{P}Pneumonia\mathit{Pneumonia}T\mathit{T}Active TB\mathit{Active\ TB}F\mathit{F}Fever\mathit{Fever}Probability
<20FalseFalseFalseNone35.56872%
<20FalseFalseFalseLow6.669135%
<20FalseFalseFalseHigh2.223045%
<20FalseFalseTrueNone0.040095%
<20FalseFalseTrueLow0.04455%
<20FalseFalseTrueHigh0.004455%
<20FalseTrueFalseNone0.202095%
<20FalseTrueFalseLow0.022455%
<20FalseTrueFalseHigh0.22455%
<20FalseTrueTrueNone0.000045%
<20FalseTrueTrueLow0.000405%
<20FalseTrueTrueHigh0.00045%
<20TrueFalseFalseNone3.88872%
<20TrueFalseFalseLow0.729135%
<20TrueFalseFalseHigh0.243045%
<20TrueFalseTrueNone0.040095%
<20TrueFalseTrueLow0.04455%
<20TrueFalseTrueHigh0.004455%
<20TrueTrueFalseNone0.022095%
<20TrueTrueFalseLow0.002455%
<20TrueTrueFalseHigh0.02455%
<20TrueTrueTrueNone0.000045%
<20TrueTrueTrueLow0.000405%
<20TrueTrueTrueHigh0.00045%
20–60FalseFalseFalseNone21.146832%
20–60FalseFalseFalseLow3.965031%
20–60FalseFalseFalseHigh1.321677%
20–60FalseFalseTrueNone0.011907%
20–60FalseFalseTrueLow0.01323%
20–60FalseFalseTrueHigh0.001323%
20–60FalseTrueFalseNone0.242757%
20–60FalseTrueFalseLow0.026973%
20–60FalseTrueFalseHigh0.26973%
20–60FalseTrueTrueNone0.000027%
20–60FalseTrueTrueLow0.000243%
20–60FalseTrueTrueHigh0.00027%
20–60TrueFalseFalseNone2.32848%
20–60TrueFalseFalseLow0.43659%
20–60TrueFalseFalseHigh0.14553%
20–60TrueFalseTrueNone0.01323%
20–60TrueFalseTrueLow0.0147%
20–60TrueFalseTrueHigh0.00147%
20–60TrueTrueFalseNone0.02673%
20–60TrueTrueFalseLow0.00297%
20–60TrueTrueFalseHigh0.0297%
20–60TrueTrueTrueNone0.00003%
20–60TrueTrueTrueLow0.00027%
20–60TrueTrueTrueHigh0.0003%
>60FalseFalseFalseNone13.63896%
>60FalseFalseFalseLow2.557305%
>60FalseFalseFalseHigh0.852435%
>60FalseFalseTrueNone0.023085%
>60FalseFalseTrueLow0.02565%
>60FalseFalseTrueHigh0.002565%
>60FalseTrueFalseNone0.403785%
>60FalseTrueFalseLow0.044865%
>60FalseTrueFalseHigh0.44865%
>60FalseTrueTrueNone0.000135%
>60FalseTrueTrueLow0.001215%
>60FalseTrueTrueHigh0.00135%
>60TrueFalseFalseNone1.4896%
>60TrueFalseFalseLow0.2793%
>60TrueFalseFalseHigh0.0931%
>60TrueFalseTrueNone0.0171%
>60TrueFalseTrueLow0.019%
>60TrueFalseTrueHigh0.0019%
>60TrueTrueFalseNone0.0441%
>60TrueTrueFalseLow0.0049%
>60TrueTrueFalseHigh0.049%
>60TrueTrueTrueNone0.0001%
>60TrueTrueTrueLow0.0009%
>60TrueTrueTrueHigh0.001%

Download the five-node network for BayesiaLab (.xbl) 

Factorization in Larger Networks

How much larger can the saving be? The network below includes the original five variables in a graph of thirteen. In the smaller graph, Age\mathit{Age} was the only parent of Pneumonia\mathit{Pneumonia}. Here Smoker\mathit{Smoker} is also a parent. Each of the three age groups now has a row for each of the two smoking states. With two states of Pneumonia\mathit{Pneumonia}, its table contains 3 × 2 × 2 = 12 probability cells.

Loading SVG...
Season (4 probability cells)
SpringSummerFallWinter
25%25%25%25%
Smoker given Age (A) (6 probability cells)
Age (A)FalseTrue
<2080%20%
20–6050%50%
>6070%30%
Age (A) (3 probability cells)
<2020–60>60
50%30%20%
TB Contact (C) (2 probability cells)
FalseTrue
50%50%
Bronchitis given Season and Smoker (16 probability cells)
SeasonSmokerFalseTrue
SpringFalse95%5%
SpringTrue75%25%
SummerFalse95%5%
SummerTrue75%25%
FallFalse95%5%
FallTrue75%25%
WinterFalse90%10%
WinterTrue50%50%
Lung Cancer given Smoker and Age (A) (12 probability cells)
SmokerAge (A)FalseTrue
False<2099.995%0.005%
False20–6099.99%0.01%
False>6099.9%0.1%
True<2099.99%0.01%
True20–6099%1%
True>6090%10%
Pneumonia (P) given Smoker and Age (A) (12 probability cells)
SmokerAge (A)FalseTrue
False<2099%1%
False20–6098%2%
False>6095%5%
True<2095%5%
True20–6090%10%
True>6085%15%
Active TB (T) given TB Contact (C) and Age (A) (12 probability cells)
TB Contact (C)Age (A)FalseTrue
False<2099%1%
False20–6099.5%0.5%
False>6099.5%0.5%
True<2095%5%
True20–6097.5%2.5%
True>6097.5%2.5%
Airway Constriction/Obstruction given Bronchitis and Lung Cancer and Pneumonia (P) (16 probability cells)
BronchitisLung CancerPneumonia (P)FalseTrue
FalseFalseFalse100%0%
FalseFalseTrue0%100%
FalseTrueFalse0%100%
FalseTrueTrue0%100%
TrueFalseFalse0%100%
TrueFalseTrue0%100%
TrueTrueFalse0%100%
TrueTrueTrue0%100%
Lung Lesions given Pneumonia (P) and Lung Cancer and Active TB (T) (16 probability cells)
Pneumonia (P)Lung CancerActive TB (T)FalseTrue
FalseFalseFalse100%0%
FalseFalseTrue0%100%
FalseTrueFalse0%100%
FalseTrueTrue0%100%
TrueFalseFalse0%100%
TrueFalseTrue0%100%
TrueTrueFalse0%100%
TrueTrueTrue0%100%
Dyspnea given Airway Constriction/Obstruction (4 probability cells)
Airway Constriction/ObstructionFalseTrue
False85%15%
True10%90%
Fever (F) given Pneumonia (P) and Active TB (T) (12 probability cells)
Pneumonia (P)Active TB (T)NoneLowHigh
FalseFalse80%15%5%
FalseTrue45%50%5%
TrueFalse45%5%50%
TrueTrue0%50%50%
X-Ray Abnormalities given Lung Lesions (4 probability cells)
Lung LesionsFalseTrue
False80%20%
True20%80%

Season\mathit{Season} has four states, Age\mathit{Age} and Fever\mathit{Fever} have three each, and the other ten nodes are binary. The full JPT therefore has 4 × 3 × 3 × 1,024 = 36,864 entries. The thirteen tables shown on the graph contain 119 probability cells altogether. The full JPT requires about 310 times as many cells.

Download the thirteen-node network for BayesiaLab (.xbl) 

When each node has few parents, the local tables can remain small even as the JPT grows exponentially. If Pai\mathrm{Pa}_i denotes the parents of node Xi\mathit{X}_i, the factorization is

P(X1,…,Xn)=∏i=1nP(Xi∣Pai).\mathrm{P}(\mathit{X}_1,\ldots,\mathit{X}_n)=\prod_{i=1}^{n}\mathrm{P}(\mathit{X}_i\mid\mathrm{Pa}_i).

In the five-node example, we began with probability calculus and removed arcs as the doctor supplied independence assumptions. In practice, a domain expert can specify each node’s parents directly. The resulting graph gives us the terms in the same product, and the tables supply their probabilities.

Further Reading

David Barber develops the argument for representing large distributions with local tables in Chapter 3 of Bayesian Reasoning and Machine Learning. David Poole and Alan Mackworth give the formal derivation from the chain rule and conditional independence in Artificial Intelligence: Foundations of Computational Agents. Barber, “Belief Networks”  · Poole and Mackworth, “Belief Networks”