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.
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)priorSample()
to implement the rejection sampling method in rejectionSampling()
. (10 marks)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)weightedSample()
to implement likelihood weighting in the method called likelihoodWeighting()
. (5 marks)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) Value: 11% of the final grade
Due date: Wednesday, 28 May, midday
No extensions will be granted except for sound, documented, medical reasons.