# Exercise 2.8
p_morning <- 0.30
p_delay <- 0.15
p_not_delay <- 1 - p_delay
p_morning_given_delay <- 0.40
# Part A: P(Delay | Morning)
p_delay_given_morning <- (p_morning_given_delay * p_delay) / p_morning
cat("Part A:", p_delay_given_morning, "\n")
## Part A: 0.2
# Part B: P(Morning | Not Delay)
p_morning_and_delay <- p_morning_given_delay * p_delay
p_morning_and_not_delay <- p_morning - p_morning_and_delay
p_morning_given_not_delay <- p_morning_and_not_delay / p_not_delay
cat("Part B:", round(p_morning_given_not_delay, 4), "\n")
## Part B: 0.2824
# Exercise 2.14
pi_values <- c(0.15, 0.25, 0.50, 0.75, 0.85)
prior_probs <- c(3/20, 3/20, 8/20, 3/20, 3/20)
likelihoods <- dbinom(x = 3, size = 13, prob = pi_values)
unnormalized <- prior_probs * likelihoods
posterior_probs <- unnormalized / sum(unnormalized)
bayes_table <- data.frame(
pi = pi_values,
prior = prior_probs,
posterior = round(posterior_probs, 5)
)
print(bayes_table)
## pi prior posterior
## 1 0.15 0.15 0.35527
## 2 0.25 0.15 0.47046
## 3 0.50 0.40 0.17405
## 4 0.75 0.15 0.00022
## 5 0.85 0.15 0.00000
Exercise 2.8
Explanations Part A: Using Bayes’ rule to reverse the conditional probabilities, the probability that Mine’s morning flight will be delayed is 20% (\(0.20\)).
Part B: By isolating the joint probability of a flight being both in the morning and on time, we determine that given Alicia’s flight is not delayed, there is approximately a 28.24% probability she is on a morning flight.
Exercise 2.14
Explanations Part A: The prior model is constructed by calculating the proportion of the 20 surveyed commuters for each \(\pi\) value, placing the heaviest initial weight on \(\pi = 0.50\) (probability of 0.40).
Part B: The posterior model is generated by updating the prior with a Binomial likelihood function (\(y = 3\) successes out of \(n = 13\) trials). The probability mass shifts heavily to \(\pi = 0.25\) (approx. 47.1%) and \(\pi = 0.15\) (approx. 35.5%).
Part C: Comparing the models reveals that Li Qiang’s peers significantly overestimated the bus’s tardiness. The prior assumed a 50% chance of being late, but the real-world data effectively eliminated the higher probabilities, proving the bus is far more reliable than initially believed.