Midterm 2: CS 188 Summer 2019 Introduction To Artificial Intelligence
Midterm 2: CS 188 Summer 2019 Introduction To Artificial Intelligence
• Mark your answers ON THE EXAM ITSELF. If you are not sure of your answer you may wish to provide a
brief explanation. All short answer sections can be successfully answered in a few sentences AT MOST.
• For multiple choice questions,
– means mark all options that apply
– # means mark a single choice
– When selecting an answer, please fill in the bubble or square completely ( and )
First name
Last name
SID
1
THIS PAGE IS INTENTIONALLY LEFT BLANK
2
SID:
(ii) [1 pt] What is the minimum number of parameters needed to fully specify the distribution P (A, B|C, d, E)
(iii) [1 pt] What is the minimum number of parameters needed to fully specify the distribution P (a, E|B, C)
(b) Given the same set of random variables as defined in part (a). Write each of the following expressions in its
simplest form, i.e., a single term. Make no independence assumptions unless otherwise stated.
Write “Not possible” if it is not possible to simplify the expression without making further independence
assumptions.
(i) [2 pts]
X
P (a0 | B, E)P (c | a0 , B, E)
a0
(ii) [3 pts]
0 0
P
0 P (B | a , C)P (a | C)P (C)
Pa 0 0 0
d0 ,e0 P (d | e , C)P (e | C)P (C)
3
Q2. [25 pts] Bayes Net Inference
A C
(a) (i) [4 pts] Select all conditional independences that are enforced by this Bayes net graph.
A⊥
⊥B A⊥
⊥C | B D ⊥⊥ C | A, B D ⊥⊥ C
A⊥
⊥C A⊥
⊥C | D A ⊥⊥ C | B, D D ⊥⊥ C | B
(ii) [3 pts] Because of these conditional independences, there are some distributions that cannot be represented
by this Bayes net. What is the minimum set of edges that would need to be added such that the resulting
Bayes net could represent any distribution?
A→C C→A C→D D→C
D→A D→B B→C B→A
(b) [6 pts] For the rest of this Q2, we use the original, unmodified Bayes net depicted at the beginning of the
problem statement. Here are some partially-filled conditional probability tables on A, B, C, and D. Note that
these are not necessarily factors of the Bayes net. Fill in the six blank entries such that this distribution can
be represented by the Bayes net.
A B D P (D | A, B) A B C P (C | A, B)
+a +b +d 0.60 +a +b +c 0.50
A C P (C | A) +a +b −d 0.40 +a +b −c 0.50
+a +c 0.8 +a −b +d 0.10 +a −b +c 0.20
+a −c 0.2 +a −b −d 0.90 +a −b −c 0.80
−a +c 0.8 −a +b +d 0.20 −a +b +c 0.90
−a −c 0.2 −a +b −d 0.80 −a +b −c 0.10
−a −b +d 0.50 −a −b +c 0.40
−a −b −d 0.50 −a −b −c 0.60
A B C D P (D, C | A, B)
+a +b +c +d (iii)
C P (C)
+a +b −c −d (iv)
+c (i)
+a −b +c +d (v)
−c (ii)
+a −b −c −d (vi)
.. .. .. .. ..
. . . . .
4
SID:
The original Bayes net is depicted again for convenience:
A C
(c) [3 pts] What is the minimal set of edges that needs to be removed from the above graph, such that it is possible
to construct a Markov random field (i.e. an undirected graphical model) that is I-equivalent to the resulting
graph? If no edges need to be removed, select ‘None’.
A→B C→B A→D B→D B→D # None
(ii) [4 pts] Let’s say we’re trying to approximate P (A | − b) using Gibbs sampling. Suppose the most recent
sample is (+a, −b, +c, +d) If we choose D to resample, what is the probability of resampling +d and −d
respectively?
+d: −d:
5
Q3. [20 pts] HMMs: Help Your House Help You
Imagine you have a smart house that wants to track your location within itself so it can turn on the lights in the
room you are in and make you food in your kitchen. Your house has 4 rooms (A, B, C, D) in the floorplan below (A
is connected to B and D, B is connected to A and C, C is connected to B and D, and D is connected to A and C):
A
B D
C
At the beginning of the day (t = 0), your probabilities of being in each room are pA , pB , pC , and pD for rooms A,
B, C, and D, respectively, and at each time t your position (following a Markovian process) is given by Xt . At each
time, your probability of staying in the same room is q0 , your probability of moving clockwise to the next room is
q1 , and your probability of moving counterclockwise to the next room is q−1 = 1 − q0 − q1 .
(a) [3 pts] Initially, assume your house has no way of sensing where you are. What is the probability that you will
be in room D at time t = 1?
Now assume your house contains a sensor M A that detects motion (+m) or no motion (-m) in room A. However, the
sensor is a bit noisy and can be tricked by movement in adjacent rooms, resulting in the conditional distributions
for the sensor given in the table below. The prior distribution for the sensor’s output is also given.
MA P (M A | X = A) P (M A | X = B) P (M A | X = C) P (M A | X = D) MA P (M A )
+mA 1 − 2γ γ 0.0 γ +mA 0.5
A A
−m 2γ 1−γ 1.0 1−γ −m 0.5
(b) [3 pts] You decide to help your house to track your movements using a particle filter with three particles. At
time t = T , the particles are at X 0 = A, X 1 = B, X 2 = D. What is the probability that the particles will be
resampled as X 0 = X 1 = X 2 = A after time elapse? Select all terms in the product.
(c) [3 pts] Assume that the particles are actually resampled after time elapse as X 0 = D, X 1 = B, X 2 = C, and
the sensor observes M A = −mA . What are the particle weights given the observation?
Particle Weight
Now, assume your house also contains sensors M B and M D in rooms B and D, respectively, with the conditional
distributions of the sensors given below and the prior equivalent to that of sensor M A .
6
SID:
MB P (M B | X = A) P (M B | X = B) P (M B | X = C) P (M B | X = D)
+mB γ 1 − 2γ γ 0.0
−mB 1−γ 2γ 1−γ 1.0
MD P (M D | X = A) P (M D | X = B) P (M D | X = C) P (M D | X = D)
+mD γ 0.0 γ 1 − 2γ
−mD 1−γ 1.0 1−γ 2γ
(d) [6 pts] Again, assume that the particles are actually resampled after time elapse as X 0 = D, X 1 = B, X 2 = C.
The sensor readings are now M A = −mA , M B = −mB , M D = +mD . What are the particle weights given the
observations?
Particle Weight
# γ 2 − 2γ 3 # 3 − 2γ # 0.0 # γ − γ2 + γ3
0
X =D
# 1 − 3γ + 2γ 2 # 2−γ # 1 − 2γ + γ 2 # None of these
# γ 2 − 2γ 3 # 3 − 2γ # 0.0 # γ − γ2 + γ3
1
X =B
# 1 − 3γ + 2γ 2 # 2−γ # 1 − 2γ + γ 2 # None of these
# γ 2 − 2γ 3 # 3 − 2γ # 0.0 # γ − γ2 + γ3
X2 = C
# 1 − 3γ + 2γ 2 # 2−γ # 1 − 2γ + γ 2 # None of these
The sequence of observations from each sensor are expressed as the following: mA A A A
0:t are all measurements m0 , m1 , . . . , mt
A B B B B B D
from sensor M , m0:t are all measurements m0 , m1 , . . . , mt from sensor M , and m0:t are all measurements
mD D D D
0 , m1 , . . . , mt from sensor M . Your house can get an accurate estimate of where you are at a given time t using
the forward algorithm. The forward algorithm update step is shown here:
P (Xt | mA B D A B D
0:t , m0:t , m0:t ) ∝ P (Xt , m0:t , m0:t , m0:t ) (1)
X
= P (Xt , xt−1 , mA B D A B D
t , mt , mt , m0:t−1 , m0:t−1 , m0:t−1 ) (2)
xt−1
X
= P (Xt | xt−1 )P (xt−1 , mA B D
0:t−1 , m0:t−1 , m0:t−1 ) (3)
xt−1
(e) [5 pts] Which of the following expression(s) correctly complete the missing expression in line (3) above (regard-
less of whether they are available to the algorithm during execution)? Fill in all that apply.
P (mA B D
t , mt , mt | Xt , xt−1 ) P (mA B D
t , mt , mt | xt−1 ) P (mA B D
t | xt−1 )P (mt | xt−1 )P (mt | xt−1 )
P (mA A B B D D
t | m0:t−1 )P (mt | m0:t−1 )P (mt | m0:t−1 ) P (mA B D A B D
t , mt , mt | Xt , xt−1 , m0:t−1 , m0:t−1 , m0:t−1 )
P (mA B D
t | Xt )P (mt | Xt )P (mt | Xt ) P (mA B D
t , mt , mt | Xt ) # None of these
7
Q4. [12 pts] Variable Elimination
Consider the following Bayes Net:
B C
D E F G H I
(a) [4 pts] Given the following domain sizes for the variables:
Variable Domain Size
A 22
B 23
C 28
D 25
E 26
F 27
G 28
H 29
I 210
What is the size of the biggest factor generated when we perform variable elimination with an alphabetical
elimination order for the query P (G = g | I = i) for some g ∈ dom(G) and i ∈ dom(I)?
(b) [3 pts] Which is the variable whose elimination generates the biggest factor if we perform variable elimination
in alphabetical order for the query P (G = g | I = i) for some g ∈ dom(G) and i ∈ dom(I)?
# A # B # C # D # E # F # G # H # I
# None of the above
(c) [5 pts] Now, suppose the variables are all boolean variables, give an elimination ordering that generates the
smallest largest factor for the query P (A = a | I = i) for some a ∈ dom(A) and i ∈ dom(I).
Leave the extra boxes blank. For example, if your elimination ordering is X, Y, Z, you should only fill in the
first 3 boxes.
8
SID:
(a) [3 pts] We want to represent this decision network as an expectimax game tree. Fill in the nodes of the tree
below, with the top node representing her maximizing choice.
(c) [3 pts] Valerie can now smell the cookie to judge whether it has raisins before she eats it. However, since she
dislikes raisins she does not have much experience with them and cannot recognize their smell well. As a result
she will incorrectly identify raisins when there are no raisins with probability 0.2 and will incorrectly identify
no raisins when there are raisins with probability 0.3. This decision network can be represented by the diagram
below where E is her choice to eat, U is her utility earned, R is whether the cookie contains raisins, and S is
her attempt at smelling.
U R S
Valerie has just smelled the cookie and she thinks it doesn’t have raisins. Write the probability, X, that the
cookie has raisins given that she smelled no raisins as a simplest form fraction or decimal.
X=
(d) [3 pts] What is her maximum expected utility, Y given that she smelled no raisins? You can answer in terms
of X or as a simplest form fraction or decimal.
Y =
(e) [3 pts] What is the Value of Perfect Information (VPI) of smelling the cookie? You can answer in terms of X
and Y or as a simplest form fraction or decimal.
9
V PI =
(f ) [8 pts] Valerie is unsatisfied with the previous model and wants to incorporate more variables into her decision
network. First, she realizes that the air quality (A) can affect her smelling accuracy. Second, she realizes that
she can question (Q) the people around to see if they know where the cookie came from. These additions are
reflected in the decision network below.
E Q
U R S A
10
SID:
A A A
B C B C B C
# G4 # G5 # G6 # None of the above.
(b) [5 pts] For the pair of Bayes Net (BN) models below, indicate if the New BN model is guaranteed to be able
to represent any joint distribution that the Old BN Model can represent. If the New BN model is guaranteed
to be able to represent any joint distribution that the Old BN Model can represent, select ”None.” Otherwise,
fill in the squares corresponding to the minimal number of edges that must be added such that the modified
New BN can represent any joint distribution that the Old BN Model can represent. Select ”Not Possible” if
no combination of added edges can result in the modified New BN representing any joint distribution that the
Old BN Model can represent.
A A
B C B C
F D F D
E E
11