Module 4 - Probability Reasoning and Uncertainty
Module 4 - Probability Reasoning and Uncertainty
and uncertainty
P(a|b) = 0.8
P(b) = 1/30000
P(a)= .02
From a standard deck of playing cards, a single card is drawn. The probability
that the card is king is 4/52, then calculate posterior probability P(King|Face),
which means the drawn face card is a king card
=0.5*0.1*0.8*0.99 = 0.0396
Bayesian Belief Network
Bayesian Belief Network
Bayesian Belief Network
Step 1: Select the Step 2: Sum out H to get joint Step 3: Normalize
entries consistent of Query and evidence
with the evidence
Inference by Enumeration
• A method to calculate the probability of a specific event or variable
given evidence in the network.
• It's based on systematically considering all possible combinations of
values for the variables in the network that are not observed (i.e., not
provided as evidence) and summing or multiplying probabilities
accordingly.
1.Identify the Query: Determine the variable/s you want to make inferences
about.
2.Identify Evidence: Identify any evidence or observed values in the network.
3.Initialize: Start with the joint probability distribution of all variables in the
network.
4.Enumeration: Enumerate over all possible values of the remaining variables,
and for each combination of values
1.Multiply the probabilities associated with observed evidence
2.Sum or multiply probabilities for unobserved variables according to the network structure
and conditional probability tables
|W | P(W) | |W |T |P(T|W)|
|----------|------|
| Sunny | 0.7 |
Inference by Enumeration |---------|---------|--------|
| Sunny | Light | 0.9 |
| Rainy | 0.3 | | Sunny | Heavy | 0.1 |
Weather (W) --> Traffic (T) --> Late for work (L) | Rainy | Light | 0.3 |
| Rainy | Heavy | 0.7 |
Infer the probability of being late for work (L) given that it's rainy (W = rainy)
1.Identify the Query: P(L|W = rainy). |T |L |
P(L|T) |
2.Identify Evidence: (W = rainy). |--------|-----------|-------|
| Light | Late | 0.2
3.Initialize: P(L = late, W = rainy) |
| Light | Not late | 0.8
4.Enumeration: |
| Heavy | Late | 0.8
P(L = late, W = rainy) =σ𝑡 P(W = rainy) ∗ P(t|W = rainy)
| * P(L|t)
| Heavy | Not late | 0.2
|
|W | P(W) | |W |T |P(T|W)|
|----------|------|
| Sunny | 0.7 |
Inference by Enumeration |---------|---------|--------|
| Sunny | Light | 0.9 |
| Rainy | 0.3 | | Sunny | Heavy | 0.1 |
Weather (W) --> Traffic (T) --> Late for work (L) | Rainy | Light | 0.3 |
| Rainy | Heavy | 0.7 |
Infer the probability of being late for work (L) given that it's rainy (W = rainy)
|T |L |
1.Identify the Query: P(L|W = rainy). P(L|T) |
2.Identify Evidence: (W = rainy). |--------|-----------|-------|
| Light | Late | 0.2
3.Initialize: P(L = late, W = rainy) |
4. Enumeration: | Light | Not late | 0.8
|
P(L = late, W = rainy) = P(W = rainy) * Σ P(T|W = rainy) * P(L|T) | Heavy | Late | 0.8
= 0.3 * ((0.7 * 0.8) + (0.3 * 0.2)) |
= 0.3 * (0.56 + 0.06) | Heavy | Not late | 0.2
= 0.3 * 0.62 |
= 0.186
5. Normalize:
P(L = late | W = rainy) = 0.186 / (0.186 + P(L = not late | W = rainy))
Inference by Enumeration in Bayes’ Net
• Given unlimited time, inference in BNs is easy
B E
• Reminder of inference by enumeration by example:
J M
B E A P(A|B,E)
• Family of conditionals:
P(X |Y) T W P
• Multiple conditionals hot sun 0.8
• Entries P(x | y) for all x, y
hot rain 0.2
• Sums to |Y|
cold sun 0.4
cold rain 0.6
Factor III
• Specified family: P( y | X )
• Entries P(y | x) for fixed y,
but for all x
• Sums need not to 1
T W P
hot rain 0.2
cold rain 0.6
Factor Summary
In general, when we write P(Y1 … YN | X1 … XM)
It is a “factor,” a multi-dimensional array
+t +l 0.3
+t -l 0.7
-t +l 0.1
-t -l 0.9
Inference by Enumeration: Procedural Outline
• Initial factors are local CPTs (one per node)
• Example: Join on R
R
+r 0.1 +r +t 0.8 +r +t 0.08
-r 0.9 +r -t 0.2 +r -t 0.02 R,T
-r +t 0.1 -r +t 0.09
T -r -t 0.9 -r -t 0.81
+r 0.1
R -r 0.9 Join R
+r +t 0.08
Join T
R, T, L
+r -t 0.02
T +r +t 0.8 -r +t 0.09
+r -t 0.2 -r -t 0.81 R, T
-r +t 0.1 +r +t +l 0.024
-r -t 0.9 +r +t -l 0.056
L
L +r -t +l 0.002
+r -t -l 0.018
+t +l 0.3 +t +l 0.3 -r +t +l 0.027
+t -l 0.7 +t -l 0.7 -r +t -l 0.063
-t +l 0.1 -t +l 0.1 -r -t +l 0.081
-t -l 0.9 -t -l 0.9 -r -t -l 0.729
Operation 2: Eliminate
• Second basic operation: marginalization
• Take a factor and sum out a variable
• Shrinks a factor to a smaller one
• A projection operation
• Example:
+r +t 0.08
+r -t 0.02 +t 0.17
-r +t 0.09 -t 0.83
-r -t 0.81
Multiple Elimination
R, T, L T, L L
+r +t +l 0.024
+r +t -l 0.056 Sum Sum
+r -t +l 0.002 out R out T
+r -t -l 0.018 +t +l 0.051
-r +t +l 0.027 +t -l 0.119 +l 0.134
-r +t -l 0.063 -t +l 0.083 -l 0.886
-r -t +l 0.081 -t -l 0.747
-r -t -l 0.729
Marginalizing
Join R
Early! (aka VE) Sum out T
Sum out R Join T
+r +t 0.08
+r 0.1 +r -t 0.02
-r 0.9 +t 0.17
-r +t 0.09
-t 0.83
-r -t 0.81
R R, T T T, L L
+r +t 0.8
+r -t 0.2
-r +t 0.1
T -r -t 0.9 L
L +t +l 0.051
+t -l 0.119 +l 0.134
-t +l 0.083 -l 0.866
L +t +l 0.3 +t +l 0.3 -t -l 0.747
+t +l 0.3
+t -l 0.7 +t -l 0.7
+t -l 0.7
-t +l 0.1 -t +l 0.1
-t +l 0.1
-t -l 0.9 -t -l 0.9
-t -l 0.9
Evidence
• If evidence, start with factors that select that evidence
Normalize
+r +l 0.026 +l 0.26
+r -l 0.074 -l 0.74
• That ’s it!
Traffic Domain
R
L
Join on r Join on r
Join on t Eliminate r
Eliminate r Join on t
Eliminate t Eliminate t
Example
Choose A
Example
Choose E
Finish with B
Normalize
Same Example in Equations
use x*(y+z) = xy + xz
use x*(y+z) = xy + xz
All we are doing is exploiting uwy + uwz + uxy + uxz + vwy + vwz + vxy +vxz = (u+v)(w+x)(y+z) to improve computational efficiency!
Another Variable Elimination Example
• The elimination ordering can greatly affect the size of the largest factor.
• E.g., previous slide’s example 2n vs. 2
• Does there always exist an ordering that only results in small factors?
• No!
Worst Case Complexity?
• CSP:
• If we can answer P(z) equal to zero or not, we answered whether the 3-SAT problem has a solution.
• Hence inference in Bayes’ nets is NP-hard. No known efficient probabilistic inference in general.