CS 151: Artificial Intelligence
Homework 4
Due date: 10/29/13 by 11:59 pm



Written questions [25 points]

Your answers to the following questions should be typed and submitted as a pdf (e.g. you can type your answers using Word and print to pdf, or use LaTeX, or write your answers by hand and then scan your paper).

  1. [5 points] AIMA 13.8
  2. [5 points] AIMA 13.15
  3. [5 points] AIMA 14.4a
  4. [10 points] Consider the WetGrass Bayesian network shown in Figure 14.12a in AIMA. Assume we observe WetGrass=false.
    1. Compute the exact posterior probabilities p(Cloudy|WetGrass=false), p(Sprinkler|WetGrass=false), and p(Rain|WetGrass=false).
    2. Show how to generate a sample using direct sampling.
    3. Generate 10 samples using direct sampling. How many samples do you get where WetGrass=false and how many do you have to reject? Estimate posterior probabilities for Cloudy, Sprinkler, and Rain based on those 10 samples. To generate a random double between [0,1] in Python use the commands: "import random" and "random.uniform(0,1)"
Programming project [75 points]

In this programming project, you will hunt ghosts! At one point in time, pacmen did not run from ghosts. Ghosts ran from pacmen. In this assignment, you will use the exact and approximate inference algorithms we learned about (for both Bayesian networks and Dynamic Bayesian networks) to locate ghosts. These are challenging lab assignments so make sure you're starting early enough to complete the assignment on time

  • You may work in pairs for this assignment! If you choose to work with someone else, submit only one directory. Put both of your names at the top of the bustersAgents.py and inference.py files. You can also put both of your written assignment pdfs inside this directory.

  • So that we're all working with the same version of the code, download the zipped directory here. If you're ready, click here to begin.

  • Just in case the Berkeley website goes down, a copy of the assignment can be found here

Ungraded optional problems (Solutions to these problems are already posted)
  1. A probability distribution over some set of random variables (X1,...,XN) assigns a real-valued number to each possible assignment of the random variables. These real-valued numbers are called "probabilities". What are the constraints to have a valid probability distribution?
  2. How many probabilities must you specify for the joint distribution of n binary random variables? For the joint distribution of n random variables with domain size d?
  3. Mathematically define: marginalization, conditional distribution, product rule, chain rule, Bayes' rule.
  4. Derive Bayes' rule using the definition of the conditional distribution and the product rule
  5. Explain (in a mathematically precise way) what is meant by the statement: "The conditional distribution and the joint distribution are proportional"
  6. AIMA 13.12
  7. AIMA 13.17 (Note there is a typo: B should be Y)
  8. AIMA 13.22 - Naive Bayes model

  9. Define "Bayesian network". Why are Bayesian networks useful?
  10. Suppose that the joint probability distribution of four variables {X, Y, Z, W} can be factorized as: p(x,y,z,w) = p(x)p(y|x)p(z|x)p(w|y,z). Draw the Bayesian network that corresponds to this factoring of the joint distribution. Determine whether or not each of the following independencies holds:
    1. X is independent of W given Y
    2. X is independent of W given Z
    3. X is independent of W given {Y, Z}
    4. Y is independent of Z given {X, W}
    Assume X, Y, Z, and W are binary random variables. How many probabilities must be specified for the conditional distributions of the Bayesian network?

Submission Instructions

You'll be turning in the "tracking" directory which should contain your modified bustersAgents.py file and inference.py file. Add the pdf of your answers to the written questions to the "tracking" directory. Give the pdf an intuitive name, e.g. "hw4_written_questions.pdf". Zip (compress) the "tracking" directory and upload it using this URL.




Last modified: Wed Oct 9 14:46:16 PDT 2013