The Junction Tree Algorithm: Example
Edwin V. Bonilla
Last update: Tuesday 19th May, 2015 at 13:51
The belief network (BN) shown below is a greatly simplified version of a network used for medical diagnosis
in an intensive care unit. The diagnostic variables are the hypovolemia (H), the left ventricular failure (L)
and the anaphylaxis (A). The intermediate variables are the left ventricular endiastolic volume (V), the stroke
volume (S) and the total peripheral resistance (T). The measurement variables are the central venous pressure
(C), the cardiac output (O) and the blood pressure (B). H, L and A take on the values true and false; V, S and
T take on the values low and high; and C, O and B take on the values low, medium and high.
H
L
A
V
S
T
O
C
B
Figure 1: Belief network for the medical diagnosis example.
The BN is fully specified by its CPTs. We have:
P (H = true) = 0.2
P (L = true) = 0.05 P (A = true) = 0.01
P (V = low|H = f alse, L = f alse) = 0.05 P (S = low|H = f alse, L = f alse) = 0.05
P (V = low|H = f alse, L = true) = 0.01 P (S = low|H = f alse, L = true) = 0.95
P (V = low|H = true, L = f alse) = 0.98 P (S = low|H = true, L = f alse) = 0.5
P (V = low|H = true, L = true) = 0.95 P (S = low|H = true, L = true) = 0.98
P (T = low|A = f alse) = 0.3 P (T = low|A = true) = 0.98
P (C = low|V = low) = 0.95 P (C = medium|V = low) = 0.04
P (C = low|V = high) = 0.01 P (C = medium|V = high) = 0.29
P (O = low|V = low, S = low) = 0.98 P (O = medium|V = low, S = low) = 0.01
P (O = low|V = low, S = high) = 0.3 P (O = medium|V = low, S = high) = 0.69
P (O = low|V = high, S = low) = 0.8 P (O = medium|V = high, S = low) = 0.19
P (O = low|V = high, S = high) = 0.01 P (O = medium|V = high, S = high) = 0.01
P (B = low|O = low, T = low) = 0.98 P (B = medium|O = low, T = low) = 0.01
P (B = low|O = low, T = high) = 0.3 P (B = medium|O = low, T = high) = 0.6
P (B = low|O = medium, T = low) = 0.98 P (B = medium|O = medium, T = low) = 0.01
P (B = low|O = medium, T = high) = 0.05 P (B = medium|O = medium, T = high) = 0.4
P (B = low|O = high, T = low) = 0.9 P (B = medium|O = high, T = low) = 0.09
P (B = low|O = high, T = high) = 0.01 P (B = medium|O = high, T = high) = 0.09
1
1
Moralisation and Triangulation via the Elimination Algorithm
A judicious application of the elimination algorithm to the given belief network using for example the order A,
T , B, O, C, V , H, L, S (note that other variable orders are possible) leads us through the following process:
1. Moralise the graph (marry parents) and drop directions of the links. Here, we link H—L,V —S and O—T
2. Eliminate A and record {A, T }
3. Eliminate T and record {O, T, B}
4. Eliminate B, the clique {O, B} is a subset of {O, T, B}
5. Eliminate O and record {V, S, O}
6. Eliminate C and record {C, V }
7. Eliminate V and record {V, H, L, S}
8. Eliminate H, L, S, the cliques produced are proper subsets of {V, H, L, S}
In general, two important steps must be carefully applied: i) moralising the graph and ii) linking neighbours
of the node to be eliminated. In the exercise given, there is no need to link neighbours as the graph is already
triangulated.
2
Creation of the Junction Tree
We now link the cliques created above so that we construct a tree that satisfies the running intersection property
(RIP). An example of such a tree is shown below. We note that every variable appearing in two different nodes
VHLS%
VS%
VSO%
O%
OTB%
T%
TA%
V%
CV%
Figure 2: Junction Tree for the medical diagnosis example. Separator nodes {V }, {V S}, {O}, {T } are the
intersection of the clique nodes.
in the tree in Figure 2 always appears in the nodes along the path (RIP).
3
Calculation of P (O|H = true, L = true, A = true) using the JTA
With the junction tree provided we want to compute the probability required given the following assignment of
potentials:
ψ(CV ) = P (C|V )
ψ(V SO) = P (O|V, S)
ψ(V HLS) = P (V |H, L)P (S|H, L)P (H)P (L)
ψ(OT B) = P (B|O, T )
ψ(T A) = P (T |A)P (A)
The potential in the separators are initialised to φ(V ) = φ(V S) = φ(O) = φ(T ) = 1.
An appropriate choice of the root node is {V, S, O} although other nodes may be suitable as long as they
contain the query variables. We will perform the following steps:
2
(i) Update the potential φ∗ (O)
(ii) Update the potential φ∗ (V S)
(iii) Update the potential ψ ∗ (V SO)
(i) Absorption from {T, A} to {O}
P
ψ(T A)δ(A = true)
∗
ψ (OT B) = A
ψ(OT B) = P (T |A = true)P (A = true)P (B|O, T ),
φ(T )
note that we don’t sum out over A as it is evidential.
φ∗ (O) =
X
=
X
ψ ∗ (OT B)
BT
P (T |A = true)P (A = true)P (B|O, T )
BT
= P (A = true)
X
P (T |A = true)
T
X
P (B|O, T )
B
|
|
{z
1
{z
1
}
}
= P (A = true)
(ii) Absorption from {C, V } to {V, S}
P
∗
X
ψ(CV )
ψ(V HLS) = ψ(V HLS)
P (C|V )
φ(V )
C
|
{z
}
C
ψ (V HLS) =
1
= ψ(V HLS)
X
φ (V S) =
ψ ∗ (V HLS)δ(H = true, L = true)
∗
HL
= P (V |H = true, L = true)P (S|H = true, L = true)P (H = true)P (L = true)
(iii) Update of {V, S, O}
ψ ∗ (V SO)
φ∗ (O)φ∗ (V S)
ψ(V SO)
φ(O)φ(V S)
= P (A = true)P (V |H = true, L = true)P (S|H = true, L = true)P (H = true)P (L = true)P (O|V, S)
=
We have collected so far all the evidence to the node {V, S, O}. The distribution of the evidence is not
necessary as this node will not be further updated and it contains the required probability. More specifically:
ψ ∗ (V SO) = P (V, S, O, H = true, L = true, A = true)
Therefore, we can calculate the marginal required as follows:
P (O, H = true, L = true, A = true)
P (H = true, L = true, A = true)
P
ψ ∗ (V SO)
= P VS ∗
OV S ψ (V SO)
P (O|H = true, L = true, A = true) =
For simplicity in the notation let us refer to the evidential variables H = true, L = true, A = true as H̃, L̃ and
Ã. Thus we have that:
P
P (Ã)P (H̃)P (L̃) V S P (V |H̃, L̃)P (S|H̃, L̃)P (O|V, S)
P (O|H = true, L = true, A = true) =
(1)
P
P
P (Ã)P (H̃)P (L̃) V S P (V |H̃, L̃)P (S|H̃, L̃) O P (O|V, S)
P
P (V |H̃, L̃)P (S|H̃, L̃)P (O|V, S)
(2)
= P VS
P
V S P (V |H̃, L̃)P (S|H̃, L̃)
O P (O|V, S)
3
For the denominator of the above equation we note that:
X
X
X
X
P (V |H̃, L̃)P (S|H̃, L̃)
P (O|V, S) =
P (V |H̃, L̃)
P (S|H̃, L̃) = 1.
VS
O
V
S
Therefore:
P (O|H = true, L = true, A = true) =
X
P (V |H = true, L = true)P (S|H = true, L = true)P (O|V, S).
VS
Thus,
P (O|H = true, L = true, A = true)
= P (V = low|H = true, L = true)P (S = low|H = true, L = true)P (O|V = low, S = low)
+ P (V = low|H = true, L = true)P (S = high|H = true, L = true)P (O|V = low, S = high)
+ P (V = high|H = true, L = true)P (S = low|H = true, L = true)P (O|V = high, S = low)
+ P (V = high|H = true, L = true)P (S = high|H = true, L = true)P (O|V = high, S = high).
Using the CPTS given we have that:
P (O = low|H = true, L = true, A = true)
P (O = medium|H = true, L = true, A = true)
P (O = high|H = true, L = true, A = true)
=
(0.95)(0.98)(0.98) + (0.95)(0.02)(0.3)
+
(0.05)(0.98)(0.8) + (0.05)(0.02)(0.01)
=
(0.931)(0.98) + (0.019)(0.3) + (0.049)(0.8) + (0.001)(0.01)
=
0.95729,
=
(0.931)(0.01) + (0.019)(0.69) + (0.049)(0.19) + (0.001)(0.01)
=
0.03174,
=
1 − P (O = low|H = true, L = true, A = true)
− P (O = medium|H = true, L = true, A = true)
=
4
0.01097.
Final Remarks
Although in the previous exercise we only needed to collect evidence to the root node, it is useful to remember
that, in general, we need to run the JTA to completion, i.e. we need to compute {**} updates and use the
property that after running the JTA we have:
Q
ψc∗∗ (xc )
P (xH , xĒ ) = Qc∈C ∗∗
,
s∈S φs (xs )
where:
ψc∗∗ (xc ) = P (xc̃ , x̄E )
φ∗∗
s (xs ) = P (xs̃ , x̄E ),
where xH are the hidden variables (not given as evidence); x̄E denotes the evidence variables; C̃ denotes those
variables in C that are not in E and similarly for S̃.
4
© Copyright 2026 Paperzz