Probability Puzzles in R
Peter Chi
Assistant Professor of Statistics Villanova University
Total number of possibilities:
$$ n_1 \times n_2 \times \ldots \times n_k $$
Example. Roll three dice. Total number of configurations:
$$ 6 \times 6 \times 6 = 6^3 $$
6^3
216
$k$ objects, $n$ total possibilities, Each possibility used once at most
Total number of configurations:
$$ n \times (n-1) \times ... \times (n-k+1) = \frac{n!}{(n-k)!} $$
Example. Number of ways for three dice to land as {2,3,4}:
$$ 3 \times 2 \times 1 = \frac{3!}{(3-3)!} = 3! $$
factorial(3)
6
Given disjoint events $A$ and $B$::
$$ P(A \cup B) = P(A) + P(B) $$
Example 1. Probability of rolling {2,3,4} or {3,4,5} with three dice
factorial(3)/6^3 + factorial(3)/6^3
0.05555556
Example 2. Probability of rolling three dice landing on the same denomination
1/6^3 + 1/6^3 + 1/6^3 + 1/6^3 + 1/6^3 + 1/6^3
0.02777778
$n$ total objects Choose $k$ of them; order does not matter
Total number of ways:
$$ {n \choose k} = \frac{n!}{k! \times (n-k)!} $$
Example. Number of ways to choose 2 dice out of 3:
$$ {3 \choose 2} = \frac{3!}{2! \times (3-2)!} = 3$$
choose(3,2)
3
Example. Roll 10 dice
Number of ways to roll 5 of one denomination and 5 of another:
n_denom <- factorial(6) / factorial(4)
n_groupings <- choose(10,5) * choose(5,5)
n_total <- n_denom * n_groupings
n_total
7560
Probability Puzzles in R