Title: Reasoning Under Uncertainty: Variable elimination
1Reasoning Under Uncertainty Variable
elimination Computer Science cpsc322, Lecture
30 (Textbook Chpt 10.4) March, 28, 2008
2Lecture Overview
- Recap Intro Variable Elimination
- Variable Elimination
- Simplifications
- Example
- Independence
- Where are we?
3Last Lecture Summary
Computing P(Z Y1v1 ? ? Yjvj ) can be
reduced to computing P(Z ? Y1v1 ? ? Yjvj )
The computation of P(Z ? Y1v1 ? ? Yjvj )
can be expressed in terms of factors and the
three basic operations between factors
- Bnet inference as variable elimination
(preliminary) - Construct a factor for each conditional
probability of the Bnet. - In each factor assign the observed variables to
their observed values. - Multiply the factors and for each of the other
variables Zi ? Z1, , Zk , sum out Zi
4Variable Elimination Intro
- Using the chain rule and the definition of a
belief network, we can write P(X1, , Xn) as - Thus
Consider each CPT as a factor Inference in
belief networks thus reduces to computing the
sums of products.
5Lecture Overview
- Recap Intro Variable Elimination
- Variable Elimination
- Simplifications
- Example
- Independence
- Where are we?
6How to simplify the Computation?
- Assume we have turned the CPTs into factors and
performed the assignments
- Lets focus on the basic case.
7How to simplify basic case
- Lets focus on the basic case.
- How can we compute efficiently?
Factor out those terms that don't involve Z1 !
8General case Summing out variables efficiently
- Now to sum out a variable Z2 from a product f1
fi f of factors, again partition the factors
into - those that don't contain Z2
- those that contain Z2
9Analogy with Computing sums of products
- This simplification is similar to what you can do
in basic algebra with and x - It takes 14 multiplications or additions to
evaluate the expression - a b a c a d a e h a f h a g h.
- How can this expression be evaluated more
efficiently?
10Variable elimination algorithm Summary
- To compute P(Q Y1v1 , ,Yjvj )
- Construct a factor for each conditional
probability. - Set the observed variables to their observed
values. - For each of the other variables Zi ? Z1, , Zk
, sum out Zi - Multiply the remaining factors.
- Normalize by dividing the resulting factor f(Q)
by ?Q f(Q) .
11Lecture Overview
- Recap Intro Variable Elimination
- Variable Elimination
- Simplifications
- Example
- Independence
- Where are we?
12Variable elimination example
- Compute P(G Hh1 ).
- P(G,H) ?A,B,C,D,E,F,I P(A,B,C,D,E,F,G,H,I)
13Variable elimination example
- Compute P(G Hh1 ).
- P(G,H) ?A,B,C,D,E,F,I P(A,B,C,D,E,F,G,H,I)
- Chain Rule
- P(G,H) ?A,B,C,D,E,F,I P(A)P(BA)P(C)P(DB,C)P(E
C)P(FD)P(GF,E)P(HG)P(IG)
14Variable elimination example
- Compute P(G Hh1 ).
- P(G,H) ?A,B,C,D,E,F,I P(A)P(BA)P(C)P(DB,C)P(E
C)P(FD)P(GF,E)P(HG)P(IG) - Factorized Representation
- P(G,H) ?A,B,C,D,E,F,I f0(A) f1(B,A) f2(C)
f3(D,B,C) f4(E,C) f5(F, D) f6(G,F,E) f7(H,G)
f8(I,G)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
15Variable elimination example
- Compute P(G Hh1 ).
- Previous state
- P(G,H) ?A,B,C,D,E,F,I f0(A) f1(B,A) f2(C)
f3(D,B,C) f4(E,C) f5(F, D) f6(G,F,E) f7(H,G)
f8(I,G) - Observe H
- P(G,Hh1) ?A,B,C,D,E,F,I f0(A) f1(B,A) f2(C)
f3(D,B,C) f4(E,C) f5(F, D) f6(G,F,E) f9(G)
f8(I,G)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
16Variable elimination example
- Compute P(G Hh1 ).
- Previous state
- P(G,H) ?A,B,C,D,E,F,I f0(A) f1(B,A) f2(C)
f3(D,B,C) f4(E,C) f5(F, D) f6(G,F,E) f9(G)
f8(I,G) - Elimination ordering A, C, E, I, B, D, F
- P(G,Hh1) f9(G) ?F ?D f5(F, D) ?B ?I f8(I,G)
?E f6(G,F,E) ?C f2(C) f3(D,B,C) f4(E,C) ?A f0(A)
f1(B,A)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
17Variable elimination example
- Compute P(G Hh1 ). Elimination ordering A, C,
E, I, B, D, F. - Previous state
- P(G,Hh1) f9(G) ?F ?D f5(F, D) ?B ?I f8(I,G)
?E f6(G,F,E) ?C f2(C) f3(D,B,C) f4(E,C) ?A f0(A)
f1(B,A) - Eliminate A
- P(G,Hh1) f9(G) ?F ?D f5(F, D) ?B f10(B) ?I
f8(I,G) ?E f6(G,F,E) ?C f2(C) f3(D,B,C) f4(E,C)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
18Variable elimination example
- Compute P(G Hh1 ). Elimination ordering A, C,
E, I, B, D, F. - Previous state
- P(G,Hh1) f9(G) ?F ?D f5(F, D) ?B f10(B) ?I
f8(I,G) ?E f6(G,F,E) ?C f2(C) f3(D,B,C) f4(E,C) - Eliminate C
- P(G,Hh1) f9(G) ?F ?D f5(F, D) ?B f10(B) ?I
f8(I,G) ?E f6(G,F,E) f12(B,D,E)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
19Variable elimination example
- Compute P(G Hh1 ). Elimination ordering A, C,
E, I, B, D, F. - Previous state
- P(G,Hh1) f9(G) ?F ?D f5(F, D) ?B f10(B) ?I
f8(I,G) ?E f6(G,F,E) f12(B,D,E) - Eliminate E
- P(G,Hh1) f9(G) ?F ?D f5(F, D) ?B f10(B)
f13(B,D,F,G) ?I f8(I,G)
- f9(G)
- f10(B)
- f12(B,D,E)
- f13(B,D,F,G)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
20Variable elimination example
- Compute P(G Hh1 ). Elimination ordering A, C,
E, I, B, D, F. - Previous state P(G,Hh1) f9(G) ?F ?D f5(F, D)
?B f10(B) f13(B,D,F,G) ?I f8(I,G) - Eliminate I
- P(G,Hh1) f9(G) f14(G) ?F ?D f5(F, D) ?B f10(B)
f13(B,D,F,G)
- f9(G)
- f10(B)
- f12(B,D,E)
- f13(B,D,F,G)
- f14(G)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
21Variable elimination example
- Compute P(G Hh1 ). Elimination ordering A, C,
E, I, B, D, F. - Previous state P(G,Hh1) f9(G) f14(G) ?F ?D
f5(F, D) ?B f10(B) f13(B,D,F,G) - Eliminate B
- P(G,Hh1) f9(G) f14(G) ?F ?D f5(F, D)
f15(D,F,G)
- f9(G)
- f10(B)
- f12(B,D,E)
- f13(B,D,F,G)
- f14(G)
- f15(D,F,G)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
22Variable elimination example
- Compute P(G Hh1 ). Elimination ordering A, C,
E, I, B, D, F. - Previous state P(G,Hh1) f9(G) f14(G) ?F ?D
f5(F, D) f15(D,F,G) - Eliminate D
- P(G,Hh1) f9(G) f14(G) ?F f16(F, G)
- f9(G)
- f10(B)
- f12(B,D,E)
- f13(B,D,F,G)
- f14(G)
- f15(D,F,G)
- f16(F, G)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
23Variable elimination example
- Compute P(G Hh1 ). Elimination ordering A, C,
E, I, B, D, F. - Previous state P(G,Hh1) f9(G) f14(G) ?F
f16(F, G) - Eliminate F
- P(G,Hh1) f9(G) f14(G) f17(G)
- f9(G)
- f10(B)
- f12(B,D,E)
- f13(B,D,F,G)
- f14(G)
- f15(D,F,G)
- f16(F, G)
- f17(G)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
24Variable elimination example
- Compute P(G Hh1 ). Elimination ordering A, C,
E, I, B, D, F. - Previous state P(G,Hh1) f9(G) f14(G) f17(G)
- Multiply remaining factors
- P(G,Hh1) f18(G)
- f9(G)
- f10(B)
- f12(B,D,E)
- f13(B,D,F,G)
- f14(G)
- f15(D,F,G)
- f16(F, G)
- f17(G)
- f18(G)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
25Variable elimination example
- Compute P(G Hh1 ). Elimination ordering A, C,
E, I, B, D, F. - Previous state
- P(G,Hh1) f18(G)
- Normalize
- P(G Hh1) f18(G) / ?g ? dom(G) f18(G)
- f9(G)
- f10(B)
- f12(B,D,E)
- f13(B,D,F,G)
- f14(G)
- f15(D,F,G)
- f16(F, G)
- f17(G)
- f18(G)
- f0(A)
- f1(B,A)
- f2(C)
- f3(D,B,C)
- f4(E,C)
- f5(F, D)
- f6(G,F,E)
- f7(H,G)
- f8(I,G)
26Lecture Overview
- Recap Intro Variable Elimination
- Variable Elimination
- Simplifications
- Example
- Independence
- Where are we?
27Variable elimination and conditional independence
- Variable Elimination looks incredibly painful for
large graphs? - Did we use conditional independence?
- Can we use it to make variable elimination
simpler?
- Yes, all the variables from which the query is
conditional independent given the observations
can be pruned from the Bnet
28VE and conditional independence Example
- All the variables from which the query is
conditional independent given the observations
can be pruned from the Bnet
- e.g., P(G Hh1, F f1 , Cc1).
- One last trick (no intuitive justification?) we
can repeatedly eliminate all leaf nodes that are
neither observed nor queried, until we reach a
fixed point
29Lecture Overview
- Recap Intro Variable Elimination
- Variable Elimination
- Simplifications
- Example
- Independence
- Where are we?
30Course Big picture
Environment
Stochastic
Deterministic
Search
Single Action
Constraint Satisfaction (CSPs)
Decision
Logics
Search
Sequence of Actions
Constraint Satisfaction (CSPs)
Planning
31Assignment 4
- It was posted a week ago - due Wed April 9
- Now you can work on all the questions except for
the last one (on decision networks). - If you have not done it yet, start working on it
ASAP!