CSCI 5512:
Artifcial Intelligence II
(Spring’10)
Homework 2 (Due Mar 17 by11:59 PM)
2. (30 points) [Programming Assignment] Consider the rain network in Figure 1.
(a)
(10 points) A Gibbs sampler ±or the problem will need the ±ollowing conditional prob-
abilities:
P(c|r,w,s), P(c|¬r,w,s), P(r|c,w,s), and P(r|¬c,w,s), as well as their com-
plements:
P(¬c|r,w,s),
P(¬c|¬r,w,s),
P(¬r|c,w,s),
and
P(¬r|¬c,w,s).
Using
the
numeric values given in Figure 1 and using the ±ormula ±or conditional probability o± a
variable given its Markov blanket, compute the numeric values o± the above conditional
probabilities.
(b)
(15
points)
Using
the
above
conditional
probabilities,
estimate
P(r|s,w)
using
Gibbs
sampling ±or 100 and 10,000 steps.
Condition on both possible values o± Sprinkler.
In addition to the numeric estimates,
you have to submit code ±or GibbsRain implementing
Gibbs sampling ±or the rain network.
The code should take one input argument:
numSteps,
the number o± steps, and output an estimate o± P(r|s,w).
For language specifc and general coding instructions, please see detailed instructions at the
end
o±
the
homework.
Please
±ollow
these
instructions
care±ully.
Code
submitted
without
adhering to these instructions will not receive any credit.
1. (20 points) Consider the Rain network in Figure 1. Assume that WetGrass = true.
For
simplicity,
we
denote
the events
by
c, s, r and w ±or Cloudy=true, Sprinkler=true, Rain=true and WetGrass=true respectively.
Each o± the 4 variables in the network is