Monty Hall Problem: Simulation
Assume you choose door #1 as above.
num_samples = 10000
monty_1 <- dplyr::tibble(
door_with_prize = sample(c(1,2,3), num_samples, replace = TRUE),
door_monte_opens = dplyr::case_when(
door_with_prize == 1 ~ sample(c(2,3), num_samples, replace = TRUE),
door_with_prize == 2 ~ 3,
door_with_prize == 3 ~ 2)
)
Now condition on the observation “Monty opens door 2”:
## # A tibble: 1 × 1
## `mean(door_with_prize == 1)`
## <dbl>
## 1 0.344