2E1. Which of the expressions below correspond to the statement: the probability of rain on Monday? (1) Pr(rain) (2) Pr(rain|Monday) (3) Pr(Monday|rain) (4) Pr(rain, Monday)/ Pr(Monday)

Answer is (4) Pr(rain, Monday)/ Pr(Monday)

2E2. Which of the following statements corresponds to the expression: Pr(Monday|rain)? (1) The probability of rain on Monday. (2) The probability of rain, given that it is Monday. (3) The probability that it is Monday, given that it is raining. (4) The probability that it is Monday and that it is raining.

Answer is (3) The probability that it is Monday given that it is raining.

2E3. Which of the expressions below correspond to the statement: the probability that it is Monday, given that it is raining? (1) Pr(Monday|rain) (2) Pr(rain|Monday) (3) Pr(rain|Monday) Pr(Monday) (4) Pr(rain|Monday) Pr(Monday)/ Pr(rain) (5) Pr(Monday|rain) Pr(rain)/ Pr(Monday)

Answer is (1) Pr(Monday|rain)

2E4. The Bayesian statistician Bruno de Finetti (1906–1985) began his 1973 book on probability theory with the declaration: “PROBABILITY DOES NOT EXIST.” The capitals appeared in the original, so I imagine de Finetti wanted us to shout this statement. What he meant is that probability is a device for describing uncertainty from the perspective of an observer with limited knowledge; it has no objective reality. Discuss the globe tossing example from the chapter, in light of this statement. What does it mean to say “the probability of water is 0.7”?

Answer is: Given our limited knowledge and the results of the experiment, we believe that the true proportion of water in the globe is 0.7.

2M1. Recall the globe tossing model from the chapter. Compute and plot the grid approximate posterior distribution for each of the following sets of observations. In each case, assume a uniform prior for p. (1) W, W, W (2) W, W, W, L (3) L, W, W, L, W, W, W

# (1) W, W, W
# Grid approximation with 1000 points
prior <- rep(1, 1000)
p_grid <- seq(from=0, to=1, length.out = 1000)

likelihood <- dbinom(3, 3, prob = p_grid)

unstd.posterior <- prior * likelihood

posterior <- unstd.posterior / sum(unstd.posterior)

plot(p_grid, posterior, type="b",
     ylab="Posterior Probability",
     xlab = "Probability of Water")

# W, W, W, L
# Grid approximation with 1000 points
prior <- rep(1, 1000)
p_grid <- seq(from=0, to=1, length.out = 1000)

likelihood <- dbinom(3, 4, prob = p_grid)

unstd.posterior <- prior * likelihood

posterior <- unstd.posterior / sum(unstd.posterior)

plot(p_grid, posterior, type="b",
     ylab="Posterior Probability",
     xlab = "Probability of Water")

# L, W, W, L, W, W, W
# Grid approximation with 1000 points
prior <- rep(1, 1000)
p_grid <- seq(from=0, to=1, length.out = 1000)

likelihood <- dbinom(5, 7, prob = p_grid)

unstd.posterior <- prior * likelihood

posterior <- unstd.posterior / sum(unstd.posterior)

plot(p_grid, posterior, type="b",
     ylab="Posterior Probability",
     xlab = "Probability of Water")

2M2. Now assume a prior for p that is equal to zero when p < 0.5 and is a positive constant when p ≥ 0.5. Again compute and plot the grid approximate posterior distribution for each of the sets of observations in the problem just above.

# (1) W, W, W

prior <- ifelse(p_grid < 0.5, 0, 1)
p_grid <- seq(from=0, to=1, length.out = 1000)

likelihood <- dbinom(3, 3, prob = p_grid)

unstd.posterior <- prior * likelihood

posterior <- unstd.posterior / sum(unstd.posterior)

plot(p_grid, posterior, type="b",
     ylab="Posterior Probability",
     xlab = "Probability of Water")

# W, W, W, L

prior <- ifelse(p_grid < 0.5, 0, 1)
p_grid <- seq(from=0, to=1, length.out = 1000)

likelihood <- dbinom(3, 4, prob = p_grid)

unstd.posterior <- prior * likelihood

posterior <- unstd.posterior / sum(unstd.posterior)

plot(p_grid, posterior, type="b",
     ylab="Posterior Probability",
     xlab = "Probability of Water")

# L, W, W, L, W, W, W

prior <- ifelse(p_grid < 0.5, 0, 1)
p_grid <- seq(from=0, to=1, length.out = 1000)

likelihood <- dbinom(5, 7, prob = p_grid)

unstd.posterior <- prior * likelihood

posterior <- unstd.posterior / sum(unstd.posterior)

plot(p_grid, posterior, type="b",
     ylab="Posterior Probability",
     xlab = "Probability of Water")

2M3. Suppose there are two globes, one for Earth and one for Mars. The Earth globe is 70% covered in water. The Mars globe is 100% land. Further suppose that one of these globes—you don’t know which—was tossed in the air and produced a “land” observation. Assume that each globe was equally likely to be tossed. Show that the posterior probability that the globe was the Earth, conditional on seeing “land” (Pr(Earth|land)), is 0.23.

0.3 * 0.5 /(0.3 * 0.5 +1 * 0.5)
## [1] 0.2307692

Pr(water|Earth) = 0.7 so Pr(land|Earth) = 0.3 Pr(land|Mars) = 1

Pr(Mars) = 0.5 Pr(Earth) = 0.5

We want Pr(Earth|land):

Pr(Earth|land) = Pr(land|Earth) * Pr(Earth) / Pr(land)

which expands to:

Pr(Earth|land) = Pr(land|Earth) * Pr(Earth) / (Pr(land|Earth) * Pr(Earth) + Pr(land|Mars) * Pr(Mars))

which ends up being:

Pr(Earth|land) = 0.3 * 0.5 /(0.3 * 0.5 + 1 * 0.5)

2M4. Suppose you have a deck with only three cards. Each card has two sides, and each side is either black or white. One card has two black sides. The second card has one black and one white side. The third card has two white sides. Now suppose all three cards are placed in a bag and shuffled. Someone reaches into the bag and pulls out a card and places it flat on a table. A black side is shown facing up, but you don’t know the color of the side facing down. Show that the probability that the other side is also black is 2/3. Use the counting method (Section 2 of the chapter) to approach this problem. This means counting up the ways that each card could produce the observed data (a black side facing up on the table).

Answer is: Define the three cards as BB, BW, and WW to indicate their sides of being black (B) or white (W). Then to count the number of ways each card could produce the observed data (a black card facing up on the table). Since BB could produce this result from either side facing up, it has two ways to produce it (2). BW could only produce this with its black side facing up (1), and WW cannot produce it in any way (0). So there are three total ways to produce the current observation (2+1+0=3). In the 3 ways to develop a black card facing up on the table, 2 ways of them have a black side back, which belong to BB. Therefore the probablity is 2/3 = 0.6667

2M5. Now suppose there are four cards: B/B, B/W, W/W, and another B/B. Again suppose a card is drawn from the bag and a black side appears face up. Again calculate the probability that the other side is black.

Answer is: With an extra B/B card:

If we observe one black side up, there are 4 ways of producing the black side up (2 for each B/B card) and 1 for picking the B/W card. The total probability that the other side is black is thus: 4/5

2M6. Imagine that black ink is heavy, and so cards with black sides are heavier than cards with white sides. As a result, it’s less likely that a card with black sides is pulled from the bag. So again assume there are three cards: B/B, B/W, and W/W. After experimenting a number of times, you conclude that for every way to pull the B/B card from the bag, there are 2 ways to pull the B/W card and 3 ways to pull the W/W card. Again suppose that a card is pulled and a black side appears face up. Show that the probability the other side is black is now 0.5. Use the counting method, as before.

Answer is: Card1: B/B Card2: B/W Card3: W/W

Black sides are heavier than cards with white sides so it is less likely that a card with black sides is pulled from the bag.

There are still 2 ways for B/B to produce a black side up, 1 way for B/W and zero ways for W/W. But according to the prior information, there is 1 way to get the B/B card, 2 ways to get the B/W card and 3 ways to get the W/W card so:

The total ways for the B/B card to produce a black side up are 2 * 1 and the total ways for the B/W card to produce a black side up are 1 * 2.

So, there are 4 ways total to see a black side up and 2 of these come from the B/B card so: The probability is 2/4.

2M7. Assume again the original card problem, with a single card showing a black side face up. Before looking at the other side, we draw another card from the bag and lay it face up on the table. The face that is shown on the new card is white. Show that the probability that the first card, the one showing a black side, has black on its other side is now 0.75. Use the counting method, if you can. Hint: Treat this like the sequence of globe tosses, counting all the ways to see each observation, for each possible first card.

Answer is: Card1: B/B Card2: B/W Card3: W/W

The B/B card has 2 ways to produce an observation with the black side up. This leaves the B/W and the W/W card with the job of producing the next observation. The B/W has only 1 way to produce a white side up while the W/W has 2 ways. So there are 3 ways to get the second card to show the white side up. Assuming the first card is B/B, there are 6 ways to see the BW sequence.

If however the B/W card is drawn first, there is 1 way for it to show the black side up. This leaves the other two cards to show the white side up. The B/B can’t show white while W/W has 2 ways to show white up so that is 2 ways to see the sequence Black and White when the first card drawn is B/W.

The probability is thus: 8 total ways of producing the sequence BW with 6 ways with B/B being drawn first.

The Probablity is 6/8.

2H1. Suppose there are two species of panda bear. Both are equally common in the wild and live in the same places. They look exactly alike and eat the same food, and there is yet no genetic assay capable of telling them apart. They differ however in their family sizes. Species A gives birth to twins 10% of the time, otherwise birthing a single infant. Species B births twins 20% of the time, otherwise birthing singleton infants. Assume these numbers are known with certainty, from many years of field research. Now suppose you are managing a captive panda breeding program. You have a new female panda of unknown species, and she has just given birth to twins. What is the probability that her next birth will also be twins?

Answer is: We are trying to find the probability that the second birth is twins, knowing that the first birth was twins.

Pr(twin2|twin1) = Pr(twin1 & twin2) / Pr(twins)

Pr(twins) = 1/2 * (0.1) + 1/2 * (0.2) for species A and B respectively

Pr of a Species A female having two twins is: 1/2 * (0.1 * 0.1)

Pr of a Species B female having two twins is: 1/2 * (0.2 * 0.2)

Thus:

Pr_twins <- 0.5 * 0.1 + 0.5 * 0.2
Pr_twin1and2 <- 0.5 * (0.1 * 0.1) + 0.5 * (0.2 * 0.2)

Final_pr <- Pr_twin1and2 / Pr_twins
Final_pr
## [1] 0.1666667