Written HW 7: CS 188 Fall 2018 Introduction To Artificial Intelligence
Written HW 7: CS 188 Fall 2018 Introduction To Artificial Intelligence
Written HW 7: CS 188 Fall 2018 Introduction To Artificial Intelligence
First name
Last name
SID
Collaborators
1
Q1. Variable Elimination
(a) For the Bayes’ net below, we are given the query P (A, E | +c). All variables have binary domains. Assume we
run variable elimination to compute the answer to this query, with the following variable elimination ordering:
B, D, G, F .
2
When eliminating F we generate a new factor f4 as follows:
Self assessment If correct, write “correct” in the box. Otherwise, write and explain the correct answer.
(b) Write a formula to compute P (A, E | +c) from the remaining factors.
Self assessment If correct, write “correct” in the box. Otherwise, write and explain the correct answer.
3
(c) Among f1 , f2 , f3 , f4 , which is the largest factor generated, and how large is it? Assume all variables have binary
domains and measure the size of each factor by the number of rows in the table that would represent the factor.
Self assessment If correct, write “correct” in the box. Otherwise, write and explain the correct answer.
(d) Find a variable elimination ordering for the same query, i.e., for P (A, E | +c), for which the maximum size
factor generated along the way is smallest. Hint: the maximum size factor generated in your solution should
have only 2 variables, for a size of 22 = 4 table. Fill in the variable elimination ordering and the factors
generated into the table below.
For example, in the naive ordering we used earlier, the first row in this table would have had the following two
entries: B, f1 (A, +c, D).
Self assessment If correct, write “correct” in the box. Otherwise, write and explain the correct answer.
4
Q2. Bayes Nets: Sampling
Consider the following Bayes Net, where we have observed that B = +b and D = +d.
P (D|A, C)
+a +c +d 0.6
P (B|A) P (C|B) +a +c −d 0.4
P (A) +a +b 0.8 +b +c 0.1 +a −c +d 0.1
A B C D +a 0.5 +a −b 0.2 +b −c 0.9 +a −c −d 0.9
−a 0.5 −a +b 0.4 −b +c 0.7 −a +c +d 0.2
−a −b 0.6 −b −c 0.3 −a +c −d 0.8
−a −c +d 0.5
−a −c −d 0.5
(a) Consider doing Gibbs sampling for this example. Assume that we have initialized all variables to the values
+a, +b, +c, +d. We then unassign the variable C, such that we have A = +a, B = +b, C = ?, D = +d.
Calculate the probabilities for new values of C at this stage of the Gibbs sampling procedure.
Self assessment If correct, write “correct” in the box. Otherwise, write and explain the correct answer.
(b) Consider a sampling scheme that is a hybrid of rejection sampling and likelihood-weighted sampling. Under
this scheme, we first perform rejection sampling for the variables A and B. We then take the sampled values for
A and B and extend the sample to include values for variables C and D, using likelihood-weighted sampling.
(i) Below is a list of candidate samples. Mark the samples that would be rejected by the rejection sampling
portion of the hybrid scheme.
2 −a −b
2 +a +b
2 +a −b
2 −a +b
Self assessment If correct, write “correct” in the box. Otherwise, write and explain the correct answer.
5
(ii) To decouple from part (i), you now receive a new set of samples shown below. Fill in the weights for these
samples under our hybrid scheme.
Weight
−a +b −c +d
+a +b −c +d
+a +b −c +d
−a +b +c +d
+a +b +c +d
Self assessment If correct, write “correct” in the box. Otherwise, write and explain the correct answer.
(iii) Use the weighted samples from part (ii) to calculate an estimate for P (+a| + b, +d).
(c) We now attempt to design an alternative hybrid sampling scheme that combines elements of likelihood-weighted
and rejection sampling. For each proposed scheme, indicate whether it is valid, i.e. whether the weighted samples
it produces correctly approximate the distribution P (A, C| + b, +d).
(i) First collect a likelihood-weighted sample for the variables A and B. Then switch to rejection sampling for
the variables C and D. In case of rejection, the values of A and B and the sample weight are thrown
away. Sampling then restarts from node A.
# Valid # Invalid
(ii) First collect a likelihood-weighted sample for the variables A and B. Then switch to rejection sampling for
the variables C and D. In case of rejection, the values of A and B and the sample weight are retained.
Sampling then restarts from node C.
# Valid # Invalid
Self assessment If correct, write “correct” in the box. Otherwise, write and explain the correct answer.