| hypothesis | prior | likelihood | product | posterior |
|---|---|---|---|---|
| Carries HIV | 0.005 | 0.977 | 0.0049 | 0.0622 |
| Does not carry HIV | 0.995 | 0.074 | 0.0736 | 0.9378 |
| sum | 1.000 | NA | 0.0785 | 1.0000 |
Homework 2 Solutions
In the solutions some of the parts have the wrong numbers, but all solutions should be there.
Problem 1
A standard deck of playing cards has 52 cards, 13 cards (2 through 10, jack, king, queen, ace) in each of 4 suits (hearts, diamonds, clubs, spades). Shuffle a deck and deals cards one at a time without replacement.
- What is the probability that the first card dealt is a heart?
- What is the probability that the second card dealt is a heart? Just make a guess now before proceeding, but you’ll revisit this a few parts down.
- What is the probability that the second card dealt is a heart if the first card dealt is a heart?
- What is the probability that the second card dealt is a heart if the first card dealt is not a heart?
- Revisit part 2. What is the probability that the second card dealt is a heart? Hint: your answer should be a single number, but show all your work.
- Find the probability that the first two cards dealt are hearts.
- Find the probability that the first two cards dealt are hearts and the third card dealt is a diamond.
Solution
- If the cards are well shuffled, then any of the cards in the deck is equally likely to be the first card dealt. There are 13 hearts out of 52 cards in the deck, so the probability that the first card is a heart is 13/52 = 1/4 = 0.25.
- It’s still 13/52. If the cards are well shuffled, then any of the cards in the deck is equally likely to be the second card in the deck. There are 13 hearts out of 52 cards in the deck, so the probability that the second card is a heart is 13/52 = 1/4 = 0.25. See the following parts for more discussion.
- If the first card dealt is a heart, there are 51 cards left in the deck, 12 of which are hearts (and all the remaining cards in the deck are equally likely to be the next one drawn). So the conditional probability that the second card is a heart given that the first card is a heart is 12/51 = 0.2353.
- If the first card dealt is not a heart, there are 51 cards left in the deck, 13 of which are hearts (and all the remaining cards in the deck are equally likely to be the next one drawn). So the conditional probability that the second card is a heart given that the first card is NOT a heart is 13/51 = 0.2549.
- The probability that the second card is a heart is 13/52 = 0.25. Don’t let the fact that it is “second” fool you; if you do not know what the first card is, then you have no information that would revise your probability of what happens on the second card. If you do not know what the first card is, you need to consider both cases: either the first card is a heart or it’s not. Use the law of total probability: \[\begin{align*} \text{P}(H_2) & = \text{P}(H_2|H_1)\text{P}(H_1) + \text{P}(H_2|H_1^c)\text{P}(H_1^c) \\ & =(12/51)(13/52) + (13/51)(39/52) = 13/52 = 0.25 \end{align*}\] Imagine 2652 repetitions (\(52\times51\), a convenient choice given these fractions) of drawing two cards, summarized in a two-way table.
| First is H | First is NOT H | Total | |
|---|---|---|---|
| Second is H | 156 | 507 | 663 |
| Second is NOT H | 507 | 1482 | 1989 |
| Total | 663 | 1989 | 2652 |
- Use the multiplication rule: the probability the both cards are hearts is the product of the probability that the first card is a heart and the conditional probability that the second card is a heart given that the first card is a heart, (13/52)(12/51) = 0.0588. If we imagine 2652 repetitions, then we would expect the first card to be a heart in 663=2652(13/52) repetitions, and among these 663 repetitions we would expect the second card to be a heart in 156=663(12/51) repetitions, so the proportion of repetitions in which both cards are hearts is 156/2652 = 0.0588.
- The third card adds a third “stage” but the multiplication rule extends naturally. The probability the first two cards dealt are hearts and the third card dealt is a diamond is (13/52)(12/51)(13/50)= 0.0153, the product of:
- 13/52, the probability that the first card is a heart,
- 12/51, the conditional probability that the second card is a heart given that the first card is a heart, and
- 13/50, the conditional probability that the third card is a diamond given that the first two cards are hearts. (If the first two cards are hearts, then there are 50 cards remaining in the deck, of which 13 are diamonds.)
Problem 2
The ELISA test for HIV was widely used in the mid-1990s for screening blood donations. As with most medical diagnostic tests, the ELISA test is not perfect. If a person actually carries the HIV virus, experts estimate that this test gives a positive result 97.7% of the time. (This number is called the sensitivity of the test.) If a person does not carry the HIV virus, ELISA gives a negative (correct) result 92.6% of the time (the specificity of the test). Estimates at the time were that 0.5% of the American public carried the HIV virus.
Suppose that a randomly selected American tests positive; we are interested in the conditional probability that the person actually carries the virus.
- Before proceeding, make a guess for the probability in question. Which range do you think it’s in: 0-20%, 20-40%, 40-60%, 60-80%, or 80-100%?
- Denote the probabilities provided in the setup using proper notation
- Construct an appropriate two-way table and use it to compute the probability of interest.
- Construct a Bayes table and use it to compute the probability of interest.
- Explain why this probability is small, compared to the sensitivity and specificity.
- By what factor has the probability of carrying HIV increased, given a positive test result, as compared to before the test?
- Now suppose that 5% of individuals in a high-risk group carry the HIV virus. Consider a randomly selectd person from this group who takes the test. Given that the test is positive, how many times more likely is it for the person not to have HIV than to have it? Answer without first computing a two-way or Bayes table.
- Using the result from the previous part, compute the conditional probability that a person in this risk group who tests positive has HIV.
- Is the posterior probability influenced by the prior probability? Discuss.
Solution
- We don’t know what you guessed, but from experience many people guess 80-100%. Afterall, the test is correct for most of people who carry HIV, and also correct for most people who don’t carry HIV, so it seems like the test is correct most of the time. But this argument ignores one important piece of information that has a huge impact on the results: most people do not carry HIV.
- Let \(H\) denote the event that the person carries HIV (hypothesis), and let \(E\) denote the event that the test is positive (evidence). Therefore, \(H^c\) is the event that the person does not carry HIV, another hypothesis. We are given
- prior probability: \(P(H) = 0.005\)
- likelihood of testing positive, if the person carries HIV: \(P(E|H) = 0.977\)
- \(P(E^c|H^c) = 0.926\)
- likelihood of testing positive, if the person does not carry HIV: \(P(E|H^c) = 1-P(E^c|H^c) = 1-0.926 = 0.074\)
- We want to find the posterior probability \(P(H|E)\).
Assuming 1000000 Americans
Tests positive Does not test positive Total Carries HIV 4885 115 5000 Does not carry HIV 73630 921370 995000 Total 78515 921485 1000000 Among the 78515 who test positive, 4885 carry HIV, so the probability that an American who tests positive actually carries HIV is 4885/78515 = 0.062.
See Table 1.
The result says that only 6.2% of Americans who test positive actually carry HIV. It is true that the test is correct for most Americans with HIV (4885 out of 5000) and incorrect only for a small proportion of Americans who do not carry HIV (73630 out of 995000). But since so few Americans carry HIV, the sheer number of false positives (73630) swamps the number of true positives (4885).
Prior to observing the test result, the prior probability that an American carries HIV is \(P(H) = 0.005\). The posterior probability that an American carries HIV given a positive test result is \(P(H|E)=0.062\). \[ \frac{P(H|E)}{P(H)} = \frac{0.062}{0.005} = 12.44 \] An American who tests positive is about 12.4 times more likely to carry HIV than an American whom the test result is not known.
So while 0.067 is still small in absolute terms, the posterior probability is much larger relative to the prior probability.In this risk group
- a person is 19 times more likely to not have HIV than to have it (\(0.95/0.05 = 19\)).
- A positive test is 13.2 times less likely when the person does not have HIV than when they have it (\(0.074/0.977 = 1/13.2\)).
- The product of these ratios is \(19(1/13.2) = 1.44\).
Since posterior is proportional to the product of prior and likelihood, a person in this risk group who tests positive is 1.44 times more likely to not have HIV than to have HIV.
- The posterior probabilities of not having HIV and having HIV are in a 1.44 to 1 ratio, the so the posterior probability of not having HIV is \(1.44/(1+1.44) = 0.59\) and the posterior probability of having HIV is 0.41.
- Yes, the posterior probability is influenced by the prior probability. Even though the prior probability of 5% is still relatively small in absolute terms, the posterior probability given a positive test is not close to 50/50.
Problem 3
Consider three tennis players Arya (“A”), Brienne (“B”), and Cersei (“C”). One of these players is better than the other two, who are equally good/bad. When the best player plays either of the others, she has a 2/3 probability of winning the match. When the other two players play each other, each has a 1/2 probability of winning the match. But you do not know which player is the best. Based on watching the players warm up, you start with subjective probabilities of 0.5 that A is the best, 0.35 that B is the best, and 0.15 that C is the best. A and B will play the first match.
- Suppose that A beats B in the first match. Compute your posterior probability that each of A, B, C is best given that A beats B in the first match.
- Compare the posterior probabilities from the previous part to the prior probabilities. Explain how your probabilities changed, and why that makes sense.
- Coding required. Code and run a simulation to simulate (1) who is the best player according to your prior distribution, (2) who wins the first match given who is the best player; then use the results to approximate the probabilities from the first part.
- Suppose instead that B beats A in the first match. Compute your posterior probability that each of A, B, C is best given that B beats A in the first match.
- Compare the posterior probabilities from the previous part to the prior probabilities. Explain how your probabilities changed, and why that makes sense.
- Now suppose again that A beats B in the first match, and also that A beats C in the second match. Compute your posterior probability that each of A, B, C is best given the results of the first two matches. (Hint: use as the prior your posterior probabilities from the previous part.) Explain how your probabilities changed, and why that makes sense.
Solution
- Hypotheses are which player is best (A, B, C). Evidence is that A beats B. The likelihood is the probability that A beats B given each of the best players.
- If A is best, probability A beats B is 2/3.
- If B is best, probability A beats B is 1/3.
- If C is best, probability A beats B is 1/2.
| best_player | prior | likelihood_A_beats_B | product | posterior |
|---|---|---|---|---|
| A | 0.50 | 0.6667 | 0.3333 | 0.6349 |
| B | 0.35 | 0.3333 | 0.1167 | 0.2222 |
| C | 0.15 | 0.5000 | 0.0750 | 0.1429 |
| Total | 1.00 | 1.5000 | 0.5250 | 1.0000 |
A’s probability of being the best increased, which makes sense because A won the match. B’s probability of being the best decreased considerably, which makes sense because B lost the match. C’s probability of being the best decreased slightly, despite C not being involved in the match.
Description of simulation
- Spinner that returns “A is best”, “B is best”, “C is best” with probability 0.5, 0.35, 0.15.
- Three additional spinners:
- “Given A is best”: returns “A beats B” with probability 2/3 and “B beats A” with probability 1/3
- “Given B is best”: returns “A beats B” with probability 1/3 and “B beats A” with probability 2/3
- “Given C is best”: returns “A beats B” with probability 1/2 and “B beats A” with probability 1/2
- Spin the first spinner once to determine who is best. Given the result of the first spin, spin the appropriate spinner to determine whether or not A beats B. The pair of spins is one repetition.
- Repeat many times to simulate many pairs.
- To find the conditional probabilities for which player is best given A beats B, only consider the repetitions in which A beats B, and among those repetitions find the proportion of repetitions where A is best, etc.
Hypotheses are which player is best (A, B, C). Evidence is that B beats A. The likelihood is the probability that B beats A given each of the best players.
- If A is best, probability B beats A is 1/3.
- If B is best, probability B beats A is 2/3.
- If C is best, probability B beats A is 1/2.
| best_player | prior | likelihood_B_beats_A | product | posterior |
|---|---|---|---|---|
| A | 0.50 | 0.3333 | 0.1667 | 0.3509 |
| B | 0.35 | 0.6667 | 0.2333 | 0.4912 |
| C | 0.15 | 0.5000 | 0.0750 | 0.1579 |
| Total | 1.00 | 1.5000 | 0.4750 | 1.0000 |
A’s probability of being the best decreased, which makes sense because A lost the match. B’s probability of being the best increased, which makes sense because B won the match. C’s probability of being the best changed slightly, despite C not being involved in the match.
The prior is the posterior from the first part. Evidence is that A beats C. The likelihood is the probability that A beats C given each of the best players.
- If A is best, probability A beats C is 2/3.
- If B is best, probability A beats C is 1/2.
- If C is best, probability A beats C is 1/3.
| best_player | prior | likelihood_A_beats_C | product | posterior |
|---|---|---|---|---|
| A | 0.6349 | 0.6667 | 0.4233 | 0.7273 |
| B | 0.2222 | 0.5000 | 0.1111 | 0.1909 |
| C | 0.1429 | 0.3333 | 0.0476 | 0.0818 |
| Total | 1.0000 | 1.5000 | 0.5820 | 1.0000 |
By winning both matches, A’s probability of being the best has increased considerably. By losing their only matches, B’s and C’s probabilities of being the best have decreased considerably.
Problem 4
In the Powerball lottery, a player picks five different whole numbers between 1 and 69, and another whole number between 1 and 26 that is called the Powerball. In the drawing, the 5 numbers are drawn without replacement from a “hopper” with balls labeled 1 through 69, but the Powerball is drawn from a separate hopper with balls labeled 1 through 26. The player wins the jackpot if both the first 5 numbers match those drawn, in any order, and the Powerball is a match. Under this set up, there are 292,201,338 possible winning numbers.
- What is the probability the next winning number is 6-7-16-23-26, plus the Powerball number, 4.
- What is the probability the next winning number is 1-2-3-4-5, plus the Powerball number, 6.
- The Powerball drawing happens twice a week. Suppose you play the same Powerball number, twice a week, every week for over 50 years. Let’s say you purchase a ticket for 6000 drawings in total. What is the probability that you win at least once?
- Instead of playing for 50 years, you decide only to play one lottery, but you buy 6000 tickets, each with a different Powerball number. What is the probability that at least one of your tickets wins? How does this compare to the previous part? Why?
- Each ticket costs 2 dollars, but the jackpot changes from drawing to drawing. Suppose you buy 6000 tickets for a single drawing. How large does the jackpot need to be for your “expected” profit to be positive? To be $100,000? (We’re ignoring inflation, taxes, transaction costs, and any changes in the rules.)
Solution
- Each of the possible winning numbers is equally likely, so the probability is \(1/292,201,338\approx 3\times 10^{-9}\).
- Each of the possible winning numbers is equally likely. Remember, don’t confuse a general event with a specific outcome.
- The probability that you lose in any single drawing is \((1-1/292201338)\). The drawings are independent so the probability that you lose all 6000 is \((1-1/292201338)^{6000}\). The probability that you win at least once is \(1 - (1-1/292201338)^{6000}\approx 0.00002\). If many people each play 6000 drawings, about 2 in every 100,000 people win will at least once.
- If you play 6000 different numbers, the events that each different number wins are disjoint. So the probability you win at least once is \(6000/292201338\approx 0.00002\). This is about the same as the probability in the previous part. When you play 6000 different independent drawings, there is a possibility that you win multiple times, so the events of winning in each different drawing are not disjoint. But the probability of winning multiple lotteries is so small that it’s negligible. The probability of winning any single drawing is about 1 in 300 million. The probability of winning twice in any two drawings is about 1 in 85 quadrillion.
- You pay $12,000 in total. Let \(w\) be the value of the jackpot. You win either 0 or \(w\) so your “expected” profit is \(w(6000/292201338)-12000\). But this not what you expect in a single repetition. Rather, it is the profit you would expect to see on average in the long run. You probably won’t be buying 6000 tickets for a large number of drawings, so your long run average isn’t really relevant. In any case, we must have \(w>584,402,676\) for the expected profit to be positive. Sometimes, but not often, the jackpot does get this high; even so, this just guarantees that your expected profit is positive. In order for your expected long run average profit to be greater than just $100,000, the jackpot must be over 5 billion dollars, and the largest jackpot ever was 1.6 billion. The moral: there are better things to do with $12,000 dollars.
Problem 5
Consider a “best-of-5” series of games between two teams: games are played until one of the teams has won 3 games (requiring at most 5 games total). Suppose one team, team A, is better than the other, having a 0.55 probability of winning any particular game. Assume the results of the games are independent (and ignore advantage, etc). Let \(X\) represent the number of games played in the series. (Hint: It’s helpful to first construct a two-way table of probabilities with the number of games played and which team wins, and then use it to answer the following questions. It will also help to list some outcomes, like AABA (team A wins game 1, 2, and 4, and B wins game 3).)
- Compute the probability that team A wins the series in 3 games.
- Compute the probability that the series ends in 3 games.
- Compute the probability that team A wins the series.
- Are the events “team A wins the series” and “the series ends in 3 games” independent? Explain by comparing relevant probabilities.
- Let \(X\) represent the number of games played in the series. Find the distribution of \(X\).
Solution
It is helpful to construct a two-way table to answer the following questions.
x 3 4 5 Total A wins 0.553 = 0.166 3(0.553)(0.45) = 0.225 6(0.553)(0.45)2 = 0.202 0.593 A does not win 0.453 = 0.091 3(0.453)(0.55) = 0.150 6(0.453)(0.55)2 = 0.165 0.407 Total 0.258 0.375 0.368 1 There is only one outcome for which A wins in 3 games: AAA. There are three outcomes in which A wins in 4 games: AABA, ABAA, BAAA. (Not AAAB because then the series would be over in 3 games.) Since the games are independent, an outcome like AABA has probability \((0.55^3)(0.45)\), so the probability that A wins in 4 games is \(3(0.55^3)(0.45)\). There are six outcomes in which A wins in 5 games: AABBA, ABABA, BAABA, ABBAA, BABAA, BBAAA. (Not outcomes like AAABB or AABAB because then the series would be over in 3 or 4 games.) Since the games are independent, an outcome like AABBA has probability \((0.55^3)(0.45)^2\), so the probability that A wins in 5 games is \(6(0.55^3)(0.45)\). You can fill in the rest of the table similarly.
The probability that team A wins the series in 3 games is \(\text{P}(X=3, A) = 0.55^3=0.166\).
Either the stronger team wins 3 in a row or loses 3 in a row. The probability is \(0.55^3+(1-0.55)^3=0.2575\).
The probability that team A wins the series is the sum of first row: \(\text{P}(A) = 0.593\).
No. \(\text{P}(X=3, A) = 0.55^3=0.166 \neq 0.152 = (0.2575)(0.593) = \text{P}(X=3)\text{P}(A)\). Alternatively, \(\text{P}(X = 3 | A) = 0.166/0.593 = 0.2799 \neq 0.2575 = \text{P}(X = 3)\). Given that \(A\) wins the series the series it more likely to end in 3 games than when B wins the series.
Total row above. \(X\) can take values 3, 4, or 5. Consider first the ways in which the stronger team wins in 4 games: AABA, ABAA, BAAA. (For example AABA, means the stronger team wins game 1, 2, and 4, and the weaker team wins game 3). Each of these outcomes has probability \(0.55^3(0.45)\) so the probability that team A wins in 4 games in \(3(0.55)^3(0.45)\). Similarly, the probability that team B wins in 4 games is \(3(0.45)^3(0.55)\). So \[ \text{P}(X = 4) = 3(0.55)^3(0.45) + 3(0.45)^3(0.55) = 0.3750 \] You could find \(\text{P}(X=5)\) in a similar way, or just use the fact that the probabilities have to add up to 1. The distribution of \(X\) is given by the following table. \[\begin{align*} x & \qquad & & \qquad \text{P}(X = x)\\ 3 & \qquad & & \qquad 0.2575\\ 4 & \qquad & & \qquad 0.3750\\ 5 & \qquad & & \qquad 0.3675\\ \end{align*}\]