CSCI 5512: Artificial Intelligence II (Spring 2022)
Homework 1
(Due Thu, Feb 10, 11:59 pm central)
1. (5 points) Consider a 3-valued random variable X such that P(X = 1) = 0.4, P(X = 0) = 0.4, and P (X = −1) = 0.2. Assume you have access to a program A that generates a number in [0,1] uniformly at random. Describe how you can use A to draw random samples of X.
Copyright By PowCoder代写 加微信 powcoder
2. (5 points) An urn has 3 red balls, 4 blue balls, and 5 green balls. Alice draws a ball from the urn, and then Bob draws a ball. What is the probability that Bob drew a green ball?
3. (15 points) Consider the Car-Starting network in Figure 1 and let B = Battery, F = Fuel, G = Gauge, T = Turn Over, and S = Start. The conditional probabilities are then given by:
P(B = bad) = 0.02
P(G = empty|B = good;F = not empty) = 0.04 P(G = empty|B = bad;F = not empty) = 0.10 P(T = false|B = good) = 0.03
P(S = false|T = true;F = not empty) = 0.01 P(S = false|T = false;F = not empty) = 1.00
P(F = empty) = 0.05 P(G = empty|B = good;F = empty) = 0.97 P(G = empty|B = bad;F = empty) = 0.99 P(T = false|B = bad) = 0.98 P(S = false|T = true;F = empty) = 0.92 P(S = false|T = false;F = empty) = 0.99
Figure 1: The Car-Starting network.
Calculate P (F = empty |S = false), the probability of the fuel tank being empty conditioned on the observation that the car does not start. (Note, you must show your work to receive full credit.)
4. (35 points) In your local nuclear power station, there is an alarm that senses when a tem- perature gauge exceeds a give threshold. The gauge measures the temperature of the core. Consider the Boolean variables A (alarm sounds), FA (alarm is faulty), and FG (gauge is faulty), and the multi-valued nodes G (gauge reading) and T (actual core temperature).
(a) (11 points) Draw a Bayesian network for this domain, given that the gauge is more likely to fail when the core temperature gets too high.
(b) (8 points) Suppose there are just two possible actual and measured temperatures, normal and high; the probability that the gauge gives the correct temperature is x when it is working, but y when it is faulty. Give the conditional probability table (CPT) associated with G. (Remember, each row of the CPT must sum to 1.)
(c) (8 points) Suppose the alarm works correctly unless it is faulty, in which case it never sounds. Give the conditional probability table associated with A.
(d) (8 points) Suppose the alarm and gauge are working and the alarm sounds. Calculate an expression for the probability that the temperature of the core is too high, in terms of the various conditional probabilities in the network.
5. (40 points) [Programming Problem] Consider the rain network in Figure 2. Assume that Sprinkler = true and WetGrass = true. For simplicity, we denote these two events by s and w respectively. Further, let r denote the event Rain = true.
TT TF FT FF
.99 .90 .90 .01
Figure 2: The Rain Network
(a) (15 points) A Gibbs sampler for the problem will need the following 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 2 and using the formula for conditional probability of a variable given its Markov blanket, write down the numeric values of the above conditional probabilities.
(b) (25 points) Using the above conditional probabilities, write Python code to estimate P(r|s,w) using Gibbs sampling for 100 and 10,000 steps (i.e., state transitions).
In addition to the numeric estimates in (a), you have to submit code for GibbsRain imple- menting Gibbs sampling for the rain network. The code should take one input argument: num steps, the number of steps, and output an estimate of P(r|s,w). The output should be clearly displayed on screen after running the program.
The code will be run for num steps=100 as follows : $python GibbsRain.py 100 Instructions
Code can only be written in Python 3.6+; no other programming languages will be accepted. One should be able to execute all programs from the Python command prompt or terminal. Each program must take the inputs in the order specified in the problem and display the textual output via the terminal and plots/figures should be included in the report. Please specify instructions on how to run your program in the README file.
For each part, you can submit additional files/functions as needed. You may use libraries for basic matrix computations and plotting such as numpy, pandas, and matplotlib. Put comments in your code so that one can follow the key parts and steps in your code.
Your code must be runnable on a CSE lab machine (e.g., csel-kh1260-01.cselabs.umn.edu). One option is to SSH into a machine. Learn about SSH, and other options, at these links: https:// cse.umn.edu/cseit/self-help-guides/secure-shell-ssh and https://cse.umn.edu/cseit/ self-help-guides.
Instructions
Follow the rules strictly. If we cannot run your code, you will not get any credit. Things to submit
1. hw1.pdf: A document which contains solutions to all problems. This document must be in PDF format (doc, jpg, etc. formats are not accepted). If you submit a scanned copy of a hand-written document, make sure the copy is clearly readable, otherwise no credit may be given.
2. Python code for Problem 5(b) (must include the required GibbsRain.py file).
3. README.txt: README file that contains your name, student ID, email, instructions on how to run your code, assumptions you are making, other students you discussed the homework with, and other necessary details.
4. Any other files which are necessary for your code (such as package dependencies like a requirements.txt or yml file).
Homework Policy. (1) You are encouraged to collaborate with your classmates on homework problems, but each person must write up the final solutions individually. You need to list in the README.txt which problems were a collaborative effort and with whom. (2) Regarding online resources, you should not:
Google around for solutions to homework problems,
Ask for help on online,
Look up things/post on sites like Quora, StackExchange, etc.