You are a consultant for an auto insurance company. Your task is to construct a belief network that will allow the company to assess how much rish they run from various policy holders. In this domain, risk is assessed by three major variables: medical cost, property cost and intangible liability cost. Medical and property costs are incurred by all individuals involved in an accident. Auto theft or vandalism might also incur property costs. Intangible liability costs are legal penalties for things like "pain and suffering", punitive damages and other costs that a driver might incur in an accident in which he or she is at fault. Evidence variables for this doamin are: driver's age and record; whether he or she owns a car, how far they drive, vehicle's make, model and year, presence of safety equipment (e.g. air bag), where vehicle is garaged and whether it has an anti-theft device.
Consider the Sprinkler network from the lecture notes. For this problem, you should implement likelihood weighting and Gibbs sampling for this network, in the language of your choice. Note that you will need a data structure for holding the network. You will also need to keep probability tables for each node. This data structure does not have to be general, and you do not need to do fancy I/O. Just input the network as given, directly in your code.
To test your code, first compute (by hand) $P(\lnot Cloudy|WetGrass)$.