2M1. Grid approximation with a uniform prior

The globe-tossing likelihood is Binomial: given \(p\) (the true proportion of water on the globe), the probability of observing \(W\) water tosses out of \(N = W + L\) total tosses is \(\binom{N}{W} p^{W}(1-p)^{L}\).

We approximate the posterior by evaluating \(\text{prior}(p)\times\text{likelihood}(p)\) on a fine grid of \(p\) values and then normalizing.

grid_posterior <- function(W, L, prior_func = function(p) rep(1, length(p)),
                           grid_size = 100) {
  p_grid <- seq(from = 0, to = 1, length.out = grid_size)
  prior <- prior_func(p_grid)
  likelihood <- dbinom(W, size = W + L, prob = p_grid)
  unstd_posterior <- likelihood * prior
  posterior <- unstd_posterior / sum(unstd_posterior)
  data.frame(p = p_grid, posterior = posterior)
}

uniform_prior <- function(p) rep(1, length(p))

par(mfrow = c(1, 3))

post1 <- grid_posterior(W = 3, L = 0, prior_func = uniform_prior)
plot(post1$p, post1$posterior, type = "b",
     xlab = "p (probability of water)", ylab = "posterior",
     main = "(1) W, W, W")

post2 <- grid_posterior(W = 3, L = 1, prior_func = uniform_prior)
plot(post2$p, post2$posterior, type = "b",
     xlab = "p (probability of water)", ylab = "posterior",
     main = "(2) W, W, W, L")

post3 <- grid_posterior(W = 5, L = 2, prior_func = uniform_prior)
plot(post3$p, post3$posterior, type = "b",
     xlab = "p (probability of water)", ylab = "posterior",
     main = "(3) L, W, W, L, W, W, W")

The posterior peaks at \(p = 1\) when all observations are water, then shifts left and tightens as land observations are added.


2M2. Grid approximation with a step prior

The prior is now \(0\) for \(p < 0.5\) and a positive constant for \(p \ge 0.5\). This encodes the assumption that the globe is at least half water.

step_prior <- function(p) ifelse(p < 0.5, 0, 1)

par(mfrow = c(1, 3))

post1s <- grid_posterior(W = 3, L = 0, prior_func = step_prior)
plot(post1s$p, post1s$posterior, type = "b",
     xlab = "p", ylab = "posterior", main = "(1) W, W, W")

post2s <- grid_posterior(W = 3, L = 1, prior_func = step_prior)
plot(post2s$p, post2s$posterior, type = "b",
     xlab = "p", ylab = "posterior", main = "(2) W, W, W, L")

post3s <- grid_posterior(W = 5, L = 2, prior_func = step_prior)
plot(post3s$p, post3s$posterior, type = "b",
     xlab = "p", ylab = "posterior", main = "(3) L, W, W, L, W, W, W")

The posterior is now hard-zero for \(p < 0.5\). For case (3), where the data alone would favor \(p \approx 5/7 \approx 0.71\), the posterior looks similar to the uniform-prior case but truncated at \(0.5\). For cases (1) and (2), where the unconstrained posterior puts substantial mass below \(0.5\), the step prior makes a noticeable difference.


2M3. Earth vs. Mars

Given:

By the law of total probability, \[ \Pr(\text{land}) \;=\; \Pr(\text{land}\mid\text{Earth})\Pr(\text{Earth}) + \Pr(\text{land}\mid\text{Mars})\Pr(\text{Mars}) \;=\; 0.3(0.5) + 1.0(0.5) \;=\; 0.65. \]

By Bayes’ rule, \[ \Pr(\text{Earth}\mid\text{land}) \;=\; \frac{\Pr(\text{land}\mid\text{Earth})\Pr(\text{Earth})}{\Pr(\text{land})} \;=\; \frac{0.3 \times 0.5}{0.65} \;=\; \frac{0.15}{0.65} \;\approx\; 0.23. \]

p_land_earth <- 0.3
p_land_mars  <- 1.0
p_earth      <- 0.5
p_mars       <- 0.5

p_land <- p_land_earth * p_earth + p_land_mars * p_mars
(p_earth_given_land <- (p_land_earth * p_earth) / p_land)
## [1] 0.2307692

2M4. Three cards (counting method)

Cards in the bag: B/B, B/W, W/W. A card is drawn and one face is shown black. Count, for each card, the number of ways it could produce the observation “black side up”:

Card Ways to show a black face
B/B 2 (either of its two black sides)
B/W 1 (only the black side)
W/W 0

Total ways to observe “black up” = \(2 + 1 + 0 = 3\).

Of these, the ways whose other side is also black come only from the B/B card, which contributes 2.

\[ \Pr(\text{other side black} \mid \text{black up}) \;=\; \frac{2}{3}. \]


2M5. Four cards (counting method)

Cards: B/B, B/W, W/W, B/B.

Card Ways to show a black face
B/B (#1) 2
B/W 1
W/W 0
B/B (#2) 2

Total ways to see “black up” = \(2 + 1 + 0 + 2 = 5\). Ways with the other side black (both B/B cards): \(2 + 2 = 4\).

\[ \Pr(\text{other side black} \mid \text{black up}) \;=\; \frac{4}{5} \;=\; 0.8. \]


2M6. Weighted draws (counting method)

Cards: B/B, B/W, W/W. The pull weights are 1 : 2 : 3 — i.e., for every way to draw B/B there are 2 ways to draw B/W and 3 ways to draw W/W.

Multiply each card’s “ways to show a black face” by its draw weight:

Card Ways to show black Draw weight Combined ways
B/B 2 1 \(2 \times 1 = 2\)
B/W 1 2 \(1 \times 2 = 2\)
W/W 0 3 \(0 \times 3 = 0\)

Total combined ways = \(2 + 2 + 0 = 4\). Combined ways where the other side is also black (only from B/B) = \(2\).

\[ \Pr(\text{other side black} \mid \text{black up}) \;=\; \frac{2}{4} \;=\; 0.5. \]

The card weights act as a prior on which card was drawn, and the counts of black faces act as the likelihood of the observation — exactly the pattern that becomes Bayes’ rule in 2M3.