There are two options available for this assignment, either:
Option 1 Implement code in Java/C/C++/Python to perform approximate inference using
one of the methods described in lectures (i.e. one from: rejection sampling; likelihood
weighted sampling; or Gibbs sampling). If you choose Option 1, you will need to use
the files provided that describe two Bayes Networks and a set of probabilistic queries
to solve. Your program must read/parse these files, create the Bayes network, and
compute values for each of the queries. You should submit your code and a 2-3 page
report of your findings.
Option 2 Perform exact inference on a PGM and also manually conduct approximate inference and compare the results. If you choose Option 2 you only need to deal with one
(small) network, but you will need to compute the exact inference and also compute
approximate inference manually (i.e. generate random numbers, use these to generate
samples, count the samples, etc). You should submit a 2-3 page report of your working
and findings.
More details about each option appear below.
Option 1
You will need to parse an input text file that encodes the graph and the conditional probability
distributions for each variab
below. Your program must be able to parse any file of this format to create and populate
an internal data structure of the PGM. Two networks have been defined in this format and
can be downloaded from the Assignment 3 page in the MyUni course pages.
Your program must then prompt the user via the console (or read from redirected standard input) for a single variable query, parse the query correctly and evaluate the conditional
probability distribution of the query variable, given the evidence. The result must be written as two decimal values (corresponding to the values of P(QueryVar=true|…) and
P(QueryVar=false|…)) onto the standard output stream. For example:
0.872 0.128
Write your program in Java, C/C++ or Python. You may not use other source code for
this assignment, but you can make use of any libraries you like for reading and writing the
files and parsing the input. The sampling and inference procedure must be your own code.
Submission and Assessment for Option 1
For this Option you should submit your code and a pdf report of maximum 2-3 pages via
MyUni. The report should briefly describe the algorithm you have chosen to implement,
then provide a section with results. For each query, indicate the results obtained (i.e. the
conditional probability values for the query) using number of samples N, where N will take
values 10, 20, 50 and 100, set out in your report as in the table below.
n=10 n=20 n=50 n=100
Query 1
Query 2
. . .
Query M
Marks will be allocated according to the following rubric:
• Code accuracy: 30 marks
• Report coherence: 30 marks
• Results: 40 marks
There are no marks for coding style per se, but if you code is poorly set out and/or unintelligible (so that its accuracy of implementation is hard to assess) expect to be penalized.
Full marks will be awarded for clear, intelligible code, and the completeness and correctness
2
of the results as reported in the final submission. If you present results in your report that
have been generated in some way other than directly from your code, you must acknowledge
this and in the report set out clearly how you generated the results (e.g. exact inference).
If we determine that you have submitted results that cannot be produced using your code,
and you have not stated how you generated the results otherwise, you will automatically be
given zero marks and referred for academic dishonesty

Sample Solution

This question has been answered.

Get Answer