COMP316A: Artificial Intelligence Techniques and Applications

- Assignment 5: Approximate Inference in Bayesian Networks -

This assignment is marked out of 40. Marks are distributed as specified below.

BayesNet.java, which is linked to from the main page for the course, is a simple, incomplete implementation of a Bayesian network. The constructor of this class constructs the alarm network that was discussed in class. (Note that, to keep things simple and efficient, there is an almost complete absence of OO design in this class.)

Your job is to complete this code so that approximate inference for the alarm network can be performed based on the methods specified in the class. You can add as much to the code as you like, but please use the code provided as the basis for your implementation and only change the methods' bodies in the existing code (i.e. don't change the methods' signatures, return types, or access modifiers). Check the comments in the code for additional information.

There are some example queries in the main method that illustrate how the methods are designed to be used. You should be able to get the same results using all three different approximate inference methods that you have to implement. Obviously, the results won't be exactly identical and you might need a different number of samples for each method to get reliable estimates.

  1. Provide code for the body of the priorSample() method in this class so that it generates network states that are distributed according to the joint distribution specified by the network. (5 marks)

  2. Use your implementation of priorSample() to implement the rejection sampling method in rejectionSampling(). (10 marks)

  3. Fill in the body of the weightedSample() method so that it samples values for the non-evidence variables and returns a weight based on the values of the evidence variables (as specified in the WEIGHTED-SAMPLE method from the textbook/slides). (10 marks)

  4. Use weightedSample() to implement likelihood weighting in the method called likelihoodWeighting(). (5 marks)

  5. Implement Markov chain Monte Carlo inference in the MCMCask() method. To this end you may want to add a method that computes the conditional probability of a node's value based on the node's Markov blanket (which is given on one of the slides provided). (10 marks)

Make sure ALL the code you submit, excluding the code that is provided, is your own code. Also, make sure your code is well-documented with lots of comments.

Other Information

Value: 11% of the final grade
Due date: Wednesday, 28 May, midday

No extensions will be granted except for sound, documented, medical reasons.