Your task is to perform exact inference on a PGM and also manually conduct approximate
inference and compare the results. 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 are as below.
There is no need to code, but you will need to work through the algorithm(s) manually on
paper. The network below shows the conditional probability relationships between variables
S (Sick), P (Pub), H (Headache), L (Lecture) and D(Doctor) which capture conditional
probabilities relating whether or not a student has a Headache to whether they are Sick,
whether they went to the Pub last night, whether they go to the 9am Lecture or not and
whether they visit a Doctor.
Figure 1: A Bayes Net representing the conditional relationships between illness, lecture
attendance, pub and doctor visits.
The queries you must solve are:
You must produce exact results for the first two, and both exact and approximate results (by
sampling) for the third and fourth queries.
You will need to conduct manual sampling by any
method you choose to generate the approximate results. For the exact results: Undergrads
can choose any exact inference method; Postgrads will be eligible for full marks only if the
exact results are generated using variable elimination.
To “implement” your manual sampling procedure you will need generate a set of samples.
For example, for the first query you will need to generate 3 random values (to decide the
true/false of Sick, Headache and Pub) for each sample1
. If you decide to generate 20 samples,
you’ll need 60 random values (3 per sample).
You can do this by using a random value
generator. Please set the range of random valuesto 0 to 1 and write down the random values
and samples when performing inference.
Submission and Assessment
You should submit a pdf report of maximum 2-3 pages via MyUni (Assigments). The report
should briefly describe the algorithm you have chosen to implement, provide your exact
working for each query and a table showing the results for each (hand-written equations and
tables will not be marked).
I recommend you tabulate results for 10 samples and for 20
samples and compare these to the exact results. Marks will be allocated according to the
Exact results and corresponding working: 30 marks
Approximate inference results (with working): 40 marks
Report coherence including description of approximate inference algorithm used: 30
As noted above, Postgraduates are expected to use variable elimination to generate their
If a postgrad chooses not to use variable elimination they can achieve up to
15/30 on that component.
Full marks will be awarded for complete and correct results, and a
coherent description of the sampling method used. If you present results in your report that
are inconsistent with the sampling method you have attempted, and you do not acknowledge
this in your report, you will automatically be given zero marks for the Assignment and referred
for academic dishonesty.
Due date and late submission policy
This assignment is due 11.59pm on Monday 8th June 2020. If your submission is late the
maximum mark you can obtain will be reduced by 25% per day (or part thereof) past the due
date or any extension you are granted.
If you choose rejection sampling you’ll need to generate random values for all five random variables, and
then reject any sample that does not match Lecture=false and Doctor=true