Professional Documents
Culture Documents
' $
• Introduction
• Representing uncertain knowledge: logic and probability (a
reminder!)
• Probabilistic inference using the joint probability distribution
• Bayesian networks (theory and algorithms)
• Other approaches to uncertainty
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Sources of Uncertainty
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Question
How can an agent capture the fact that he is not certain that
John has a cavity?
& %
AI II Reasoning under Uncertainty
' $
First Answer
Use logic:
I have no knowledge regarding whether John has a cavity
or not.
The formulas Cavity and ¬Cavity do not follow from my KB.
& %
AI II Reasoning under Uncertainty
' $
Use probabilities:
The probability that patient John has a cavity is 0.8.
We might know this from statistical data or some general dental
knowledge.
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Probability
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
P (A ∪ B) = P (A) + P (B)
& %
AI II Reasoning under Uncertainty
' $
Example - Question
& %
AI II Reasoning under Uncertainty
' $
Example - Answer
P (T otal = 11) = P ((5, 6)) + P ((6, 5)) = 1/36 + 1/36 = 2/36 = 1/18
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
• P (¬a) = 1 − P (a)
• P (a ∨ b) = P (a) + P (b) − P (a ∧ b)
• ...
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Conditional Probability
P (a ∧ b) = P (a|b) P (b)
& %
AI II Reasoning under Uncertainty
' $
Example
1/36
= 1/6
1/6
& %
AI II Reasoning under Uncertainty
' $
Random Variables
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Notation
⟨P (X = x1 ), . . . , P (X = xn )⟩.
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Probabilistic Inference
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Example
Equivalently as a vector:
& %
AI II Reasoning under Uncertainty
' $
Example (cont’d)
Equivalently as a table:
P (·)
W eather = sunny 0.6
W eather = rainny 0.1
W eather = cloudy 0.29
W eather = snowy 0.01
& %
AI II Reasoning under Uncertainty
' $
If we have more than one random variable and we are considering problems
that involve two or more of these variables at the same time, then the joint
probability distribution specifies degrees of belief in the values that
these functions take jointly.
The joint probability distribution P(X), where X is a vector of random
variables, is usually specified graphically by a n-dimensional table (where n
is the dimension of X).
toothache ¬toothache
cavity 0.04 0.06
¬cavity 0.01 0.89
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Example I
toothache ¬toothache
cavity 0.04 0.06
¬cavity 0.01 0.89
& %
AI II Reasoning under Uncertainty
' $
Example I (cont’d)
toothache ¬toothache
cavity 0.04 0.06
¬cavity 0.01 0.89
P (cavity ∧ toothache)
P (cavity | toothache) = =
P (toothache)
0.04
= 0.80
0.04 + 0.01
& %
AI II Reasoning under Uncertainty
' $
Example II
toothache ¬toothache
catch ¬catch catch ¬catch
cavity 0.108 0.012 0.072 0.008
¬cavity 0.016 0.064 0.144 0.576
& %
AI II Reasoning under Uncertainty
' $
We can use the full joint probability to extract the distribution over
some subset of variables or a single variable.
Example:
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Example II (cont’d)
P (cavity ∧ toothache)
P (cavity | toothache) = =
P (toothache)
0.108 + 0.012
= 0.6
0.108 + 0.012 + 0.016 + 0.064
P (¬cavity ∧ toothache)
P (¬cavity | toothache) = =
P (toothache)
0.016 + 0.064
= 0.4
0.108 + 0.012 + 0.016 + 0.064
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Difficulties
• Using the full joint probability distribution table works fine but
it needs O(2n ) space.
• Specifying probabilities for all combinations of propositional
variables might be unnatural, and might require a huge amount
of statistical data.
• So this is not a practical tool for probabilistic inference. We
will see better reasoning tools in the rest of the presentation.
& %
AI II Reasoning under Uncertainty
' $
Independence
& %
AI II Reasoning under Uncertainty
' $
Example
& %
AI II Reasoning under Uncertainty
' $
Examples
Cavity
Toothache Catch
Weather
decomposes
into
Cavity
Toothache Catch Weather
& %
AI II Reasoning under Uncertainty
' $
Examples (cont’d)
Coin1 Coinn
decomposes
into
Coin1 Coinn
& %
AI II Reasoning under Uncertainty
' $
Difficulties
& %
AI II Reasoning under Uncertainty
' $
Bayes’ Rule
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Comments:
• P (ef f ect | cause) quantifies the relationship between cause
and ef f ect in a causal way.
• P (cause | ef f ect) does the same thing in a diagnostic way.
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
There has been much work in using Bayesian networks for medical
diagnosis.
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Conditional Independence
& %
AI II Reasoning under Uncertainty
' $
Formally:
P(toothache ∧ catch | Cavity) =
P(toothache | Cavity) P(catch | Cavity)
& %
AI II Reasoning under Uncertainty
' $
P(X | Y, Z) = P(X | Z)
P(Y | X, Z) = P(Y | Z)
& %
AI II Reasoning under Uncertainty
' $
Example (cont’d)
& %
AI II Reasoning under Uncertainty
' $
Bayesian Networks
& %
AI II Reasoning under Uncertainty
' $
Example
Weather Cavity
Toothache Catch
& %
AI II Reasoning under Uncertainty
' $
Bayesian Networks
& %
AI II Reasoning under Uncertainty
' $
Example
P(B) P(E)
Burglary Earthquake
.001 .002
B E P(A)
t t .95
Alarm t f .94
f t .29
f f .001
A P(J) A P(M)
JohnCalls t .90 MaryCalls t .70
f .05 f .01
& %
AI II Reasoning under Uncertainty
' $
Comments
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Now compare the formula we just computed with the one that
gives us the semantics of Bayesian networks:
∏
n
P (x1 , . . . , xn ) = P (xi | xi−1 , . . . , x1 )
i=1
∏
n
P (x1 , . . . , xn ) = P (xi | parents(Xi ))
i=1
& %
AI II Reasoning under Uncertainty
' $
provided that
P arents(Xi ) ⊆ {Xi−1 , . . . , X1 }
then the Bayesian network is indeed a correct representation of
the joint probability distribution.
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
is satisfied.
• For each parent, insert a link from the parent to Xi .
• Write down the CPT specifying P (Xi | P arents(Xi )).
& %
AI II Reasoning under Uncertainty
' $
Example
P(B) P(E)
Burglary Earthquake
.001 .002
B E P(A)
t t .95
Alarm t f .94
f t .29
f f .001
A P(J) A P(M)
JohnCalls t .90 MaryCalls t .70
f .05 f .01
& %
AI II Reasoning under Uncertainty
' $
Example (cont’d)
How did we construct the previous network given our knowledge of the
domain?
The difficulty is in Step 2 where we should specify the parents of a node Xi
i.e., all the nodes that directly influence Xi .
Suppose we have completed the previous network except for the choice of
parents for M aryCalls. The important thing to notice that Burglary or
Earthquake influence M aryCalls but not directly. Only Alarm
influences M aryCalls directly. Similarly, JohnCalls has no influence on
M aryCalls.
Formally:
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Example
P(B) P(E)
Burglary Earthquake
.001 .002
B E P(A)
t t .95
Alarm t f .94
f t .29
f f .001
A P(J) A P(M)
JohnCalls t .90 MaryCalls t .70
f .05 f .01
& %
AI II Reasoning under Uncertainty
' $
Example (cont’d)
& %
AI II Reasoning under Uncertainty
' $
Example (cont’d)
& %
AI II
' Reasoning under Uncertainty $
Example (cont’d)
P(b)
.001
P(e) P(¬e)
.002 .998
Example (cont’d)
Finally:
P (b | j, m) = α × 0.00059224 ≈ 0.284
The chance of a burglary given calls from both John and Mary is
about 28%.
& %
AI II Reasoning under Uncertainty
' $
The variables in the list bn.Vars are given in the order Y, E, {X}.
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Idea
& %
AI II Reasoning under Uncertainty
' $
Variable Elimination
& %
AI II Reasoning under Uncertainty
' $
Factors
∑ ∑
P(B | j, m) = α P(B) P (e) P(a | B, e) P (j | a) P (m | a)
| {z } e
| {z } a
| {z } | {z } | {z }
f1 (B) f2 (E) f3 (A,B,E) f4 (A) f5 (A)
& %
AI II Reasoning under Uncertainty
' $
Factors (cont’d)
∑ ∑
P(B | j, m) = α P(B) P (e) P(a | B, e) P (j | a) P (m | a)
| {z } e
| {z } a
| {z } | {z } | {z }
f1 (B) f2 (E) f3 (A,B,E) f4 (A) f5 (A)
& %
AI II Reasoning under Uncertainty
' $
Factors (cont’d)
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Example
∑ ∑
P(B | j, m) = α f1 (B) × f2 (E) × f3 (A, B, E) × f4 (A) × f5 (A)
e a
& %
AI II Reasoning under Uncertainty
' $
Example (cont’d)
Pointwise Product
f(X1 , . . . , Xj , Y1 , . . . , Yk , Z1 , . . . , Zl ) =
f1 (X1 , . . . , Xj , Y1 , . . . , Yk ) f2 (Y1 , . . . , Yk , Z1 , . . . , Zl )
If all the variables are Boolean, then f1 and f2 have 2j+k and 2k+l
entries respectively, and the pointwise product f has 2j+k+l entries.
& %
AI II Reasoning under Uncertainty
' $
Example (cont’d)
A B f1 (A, B)
T T .3
T F .7
F T .9
F F .1
B C f2 (B, C)
T T .2
T F .8
F T .6
F F .4
& %
AI II Reasoning under Uncertainty
' $
Example (cont’d)
A B C f3 (A, B, C)
T T T .3 × .2 = .06
T T F .3 × .8 = .24
T F T .7 × .6 = .42
T F F .7 × .4 = .28
F T T .9 × .2 = .18
F T F .9 × .8 = .72
F F T .1 × .6 = .06
F F F .1 × .4 = .04
& %
AI II Reasoning under Uncertainty
' $
Complexity Issues
& %
AI II Reasoning under Uncertainty
' $
Example:
∑
f(B, C) = f3 (A, B, C) = f3 (a, B, C) + f3 (¬a, B, C) =
a
.06 .24 .18 .72 .24 .96
+ =
.42 .28 .06 .04 .48 .32
& %
AI II Reasoning under Uncertainty
' $
Any factor that does not depend on the variable to be summed out
can be moved outside the summation. For example:
∑
f2 (E) × f3 (A, B, E) × f4 (A) × f5 (A) =
e
∑
f4 (A) × f5 (A) × f2 (E) × f3 (A, B, E)
e
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
∑ ∏k
return the factor y i=1 fi where f1 , . . . , fk are the factors of F containing
variable Y .
∏
Note: The symbol in the above algorithm denotes the pointwise product
operation for factors.
& %
AI II Reasoning under Uncertainty
' $
Correctness
∑∏
l ∏
k
( fi )( fi )
z1 i=1 i=l+1
& %
AI II Reasoning under Uncertainty
' $
Correctness (cont’d)
The first term in the above result is the factor added to list F in
the place of the factors deleted, while the second term is the
pointwise product of the factors that remained in the list.
& %
AI II Reasoning under Uncertainty
' $
Complexity Issues
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Example
P(B) P(E)
Burglary Earthquake
.001 .002
B E P(A)
t t .95
Alarm t f .94
f t .29
f f .001
A P(J) A P(M)
JohnCalls t .90 MaryCalls t .70
f .05 f .01
& %
AI II Reasoning under Uncertainty
' $
Example
∑
Notice that m P (m | a) is 1 i.e., the variable M is irrelevant to
the query.
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
P(C)=.5
Cloudy
C P(S) C P(R)
t .10 Sprinkler Rain t .80
f .50 f .20
Wet
Grass
S R P(W)
t t .99
t f .90
f t .90
f f .00
& %
AI II Reasoning under Uncertainty
' $
A Clustered Equivalent
P(C)=.5
Cloudy
P(S+R=x)
C tt tf ft ff
Spr+Rain t .08 .02 .72 .18
S+R P(W) f .10 .40 .10 .40
t t .99
Wet
t f .90 Grass
f t .90
f f .00
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
• Medicine
• Engineering (e.g., monitoring power generators).
• Networking (e.g., network tomography)
• Diagnosis-and-repair tools for Microsoft software.
Check out the tool MSBNx at http://research.microsoft.
com/en-us/um/redmond/groups/adapt/msbnx/.
• Bioinformatics
• ...
Many references are given in Chapter 14 of AIMA.
& %
AI II Reasoning under Uncertainty
' $
• Rule-based techniques
• Dempster-Shafer theory
• Fuzzy sets and fuzzy logic
& %
AI II Reasoning under Uncertainty
' $
Rule-based Techniques
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Example
& %
AI II Reasoning under Uncertainty
' $
Example (cont’d)
& %
AI II Reasoning under Uncertainty
' $
& %
AI II Reasoning under Uncertainty
' $
Readings
& %
AI II Reasoning under Uncertainty
' $
Readings (cont’d)
& %
AI II Reasoning under Uncertainty
' $
Readings (cont’d)
& %