Example
Roll 2 dice, you see one of them is a 2, what is the probability that the total is an Eight?
## # A tibble: 6 × 6
## `1` `2` `3` `4` `5` `6`
## <chr> <chr> <chr> <chr> <chr> <chr>
## 1 ( 1 , 1 ) ( 1 , 2 ) ( 1 , 3 ) ( 1 , 4 ) ( 1 , 5 ) ( 1 , 6 )
## 2 ( 2 , 1 ) ( 2 , 2 ) ( 2 , 3 ) ( 2 , 4 ) ( 2 , 5 ) ( 2 , 6 )
## 3 ( 3 , 1 ) ( 3 , 2 ) ( 3 , 3 ) ( 3 , 4 ) ( 3 , 5 ) ( 3 , 6 )
## 4 ( 4 , 1 ) ( 4 , 2 ) ( 4 , 3 ) ( 4 , 4 ) ( 4 , 5 ) ( 4 , 6 )
## 5 ( 5 , 1 ) ( 5 , 2 ) ( 5 , 3 ) ( 5 , 4 ) ( 5 , 5 ) ( 5 , 6 )
## 6 ( 6 , 1 ) ( 6 , 2 ) ( 6 , 3 ) ( 6 , 4 ) ( 6 , 5 ) ( 6 , 6 )
\[ \mathbb{P}[8 \mid 2 \text{ on one die}] = \frac{\mathbb{P}[8 \cap 2 \text{on one die}]}{\mathbb{P}[2 \text{ on one die} ]}\\ = \frac{2/36}{11/36} = 2/11 \]
rolls = 100000
dice = dplyr::tibble(die1 = sample(1:6, rolls, replace = TRUE),
die2 = sample(1:6, rolls, replace = TRUE),
total = die1 + die2)
dice |> dplyr::filter(die1 == 2 | die2 == 2) |>
dplyr::summarize(mean(total==8))
## # A tibble: 1 × 1
## `mean(total == 8)`
## <dbl>
## 1 0.179
## [1] 0.1818182