Quiz 3 Key
Quiz 3 Key
Quiz 3 Key
This is an open notes/book quiz that is due by 11:59 pm on Friday, April 19th. All of your work is to
be completed individually. You can turn in a written copy to me or scan/submit via email. PLEASE
write your answers in space provided in the PDF (or print a copy and write it in the space provided),
as I will be grading this with Gradescope. You must show all your work to get full credit.
Problem 1 (4 pts): Consider the set of all possible five-card poker hands dealt fairly from a
standard deck of fifty-two cards.
a) How many atomic events are there in the joint probability distribution (i.e., how many five-card
hands are there)? 52
5 = 2, 598, 960
1
b) What is the probability of each atomic event? 2,598,960
c) What is the probability of being dealt a royal straight flush (A-K-Q-K-10 all of the same suit)? 4
4
potential ways to form this hand, so, 2,598,960
d) What is the probability of being dealt four of a kind? 13 ways to have 4 of a kind, plus any of the
13×48 1
remaining (52-4 = 48) cards as the fifth card. Thus, 2,598,960 = 4165
1
Problem 2 (20 pts): Consider two medical tests, A and B, for a virus. Test A is 95% effective at
recognizing the virus when it is present, but has a 10% false positive rate (indicating that the virus
is present, when it is in fact not present). Test B is 90% effective at recognizing the virus when it is
present, but has a 5% false positive rate. The two tests use independent methods to identify the
virus. The virus exists in 1% of the population.
b) If we get a positive result from TestB, is TestA independent? Briefly explain (at most 2 sentences).
No, because the results of TestB change our belief about virus. Knowing something about virus
changes our belief in TestA (and thus, they are not independent).
c) Say that a person is tested for the virus using only one of the tests, and that test comes back
positive. Which test returning positive is more indicative of someone actually having the virus?
Justify your answer.
We need to calculate out the probabilities of having the virus for both tests. Let V indicate the
have the virus, T 1 represent that test1 indicates we have the virus, and T 2 represent that test2
indicates we have the virus. Thus, we want to compute P (v|t1) and P (v|t2).
P (v|t1) = P (t2|v)P (v)
P (t2)
P (t1) = P (t1|v) + P (t1|¬v) = .95 × 0.01 + .10 × 0.99 = 0.1085
P (t1|v)P (v)
P (t1) = 0.95×0.01
0.1085 ≈ 0.876
2
Problem 3 (25 pts): A belief network with conditional probabilities is given in the following figure.
P(C)=.5
Cloudy
C P(S) C P(R)
t .10 Sprinkler Rain t .80
f .50 f .20
Wet
Grass
S R P(W)
t t .99
t f .90
f t .90
f f .00
The letters C, R, S, and W stand for Cloudy, Rain, Sprinkler, and Wet Grass, respectively. Compute
the probabilities of P (W ) and P (S|W ). Notice that these are capital letters. Hint: This will require
summingPoutPoverP a few variables.
P (w) = Pc s P P (r|c)P (W |s, r)
r P (c)P (s|c)P
P (w) = c P (c) s P (s|c) r P (r|c)P (W |s, r)
3
P (S, W ) = P (S|W )P (W ) (via the product rule)
P (S|W ) = PP(S,W
(W )
)
1
P (S|W ) = αP (S, W ) s.t. α = P (W )
This tell us that if we want to know P (S|W ), we can find an answer that is proportional to this value
by solving P(S,W), which is easier. To solve P(S,W) , we will vary S and W to all combinations (4)
and sum out over the other variables.
P P
P (s|w) = α c P (c)P (s|c) r P (r|c)P (w|r, s)
= α{P (c)P (s|c) [P (r|c)P (w|s, r) + P (¬r|c)P (w|s, ¬r) ]+
P (¬c)P (s|¬c) [P (r|¬c)P (w|s, r) + P (¬r|¬c)P (w|¬r, s) ] }
= α{[0.5 ∗ .1[.8 ∗ 0.99 + 0.2 ∗ 0.9) ] + [0.5 ∗ 0.5(0.2 ∗ 0.99 + 0.8 ∗ 0.9) ] }
= α{[0.5 ∗ .1 ∗ 0.972. + 0.5 ∗ 0.5 ∗ 0.918 ] }
= α{0.0486 + 0.2295} = α0.2781
P P
P (¬s|w) = α c P (c)P (¬s|c) r P (r|c)P (w|r, ¬s)
= α{P (c)P (¬s|c) [P (r|c)P (w|¬s, r) + P (¬r|c)P (w|¬s, ¬r) ]+
P (¬c)P (¬s|¬c)[P (r|¬c)P (w|¬s, r) + P (¬r|¬c)P (w|¬r, ¬s) ]}
= α{0.5 ∗ .9[.8 ∗ 0.9 + 0.2 ∗ 0.0 ] + 0.5 ∗ 0.5[0.2 ∗ 0.90 + 0.8 ∗ 0.0 ] }
= α{0.5 ∗ 0.9 ∗ 0.72 + 0.5 ∗ 0.5 ∗ 0.18 ] }
= α {0.324 + 0.045 } = α0.369
P (s|w) + P (¬s|w) = 1
α0.2781 + α0.369 = 1
α(0.2781 + 0.369) = 1
1
α = 0.2781+0.369
1
α = 0.6471
α = 1.545356205
4
P P
P (s|¬w) = α c P (c)P (s|c) r P (r|c)P (¬w|r, s)
= α{P (c)P (s|c) [ P (r|c)P (¬w|s, r) + P (¬r|c)P (¬w|s, ¬r) ]+
P (¬c)P (s|¬c)[P (r|¬c)P (¬w|s, r) + P (¬r|¬c)P (¬w|¬r, s) ] }
= α{0.5 ∗ .1[.8 ∗ 0.01 + 0.2 ∗ 0.1 ]+
0.5 ∗ 0.5[0.2 ∗ 0.01 + 0.8 ∗ 0.1] }
= α{0.5 ∗ .1 ∗ 0.028 + 0.5 ∗ 0.5 ∗ 0.082 }
= α{0.0014 + 0.0205 } = α0.0219
P P
P (¬s|¬w) = α c P (c)P (¬s|c) r P (r|c)P (¬w|r, ¬s)
= α{P (c)P (¬s|c)[P (r|c)P (¬w|¬s, r) + P (¬r|c)P (¬w|¬s, ¬r) ]+
P (¬c)P (¬s|¬c)[P (r|¬c)P (¬w|¬s, r) + P (¬r|¬c)P (¬w|¬r, ¬s) ]}
= α{0.5 ∗ .9 ∗ [.8 ∗ 0.10 + 0.2 ∗ 1] }+
{0.5 ∗ 0.5[0.2 ∗ 0.10 + 0.8 ∗ 1 ] }
= α{0.5 ∗ 0.1 ∗ 0.28 + 0.5 ∗ 0.50.82 }
= α{0.0205 + 0.126 } = α0.1465
P (s|¬w) + P (¬s|¬w) = 1
α0.0219 + α0.1465 = 1
α(0.0219 + 0.1465) = 1
1
α = 0.0219+0.1465
1
α = 0.22995
α = 5.93824228
5
Problem 4 (11 pts): Consider the query P (Rain|Sprinkler = true, W etGrass = true) and how
we can use Gibbs sampling to answer this question. (Chapter 14 material, not Chapter 15).