Combinatorics

STAT1003 – Statistical Techniques

Dr. Emi Tanaka

Australian National University

These slides are best viewed on a modern browser like Google Chrome on a desktop or laptop. Some interactive components may require some time to fully load.

Challenge Rolling two dice

If we roll two fair dice, what is the probability that the sum of the two numbers is 5?

Challenge Rolling ten dice

What is the probability that the sum of the numbers when rolling ten fair dice is 30?

  • To answer this question, there are a number of different approaches that can be taken:
    1. List all possible outcomes and count those that sum to 30. But there \(6^{10} = 60,466,176\) possible outcomes!
    2. Use combinatorial methods to count the number of outcomes that sum to 30.
    3. Use simulation to estimate the probability.
1 1 1 1 1 1 6 6 6 6 
1 1 1 1 1 2 5 6 6 6 
1 1 1 1 1 3 4 6 6 6 
1 1 1 1 1 3 5 5 6 6 
1 1 1 1 1 4 4 5 6 6 
1 1 1 1 1 4 5 5 5 6 
1 1 1 1 1 5 5 5 5 5 
1 1 1 1 2 2 4 6 6 6 
1 1 1 1 2 2 5 5 6 6 
1 1 1 1 2 3 3 6 6 6 
1 1 1 1 2 3 4 5 6 6 
1 1 1 1 2 3 5 5 5 6 
1 1 1 1 2 4 4 4 6 6 
1 1 1 1 2 4 4 5 5 6 
1 1 1 1 2 4 5 5 5 5 
1 1 1 1 3 3 3 5 6 6 
1 1 1 1 3 3 4 4 6 6 
1 1 1 1 3 3 4 5 5 6 
1 1 1 1 3 3 5 5 5 5 
1 1 1 1 3 4 4 4 5 6 
1 1 1 1 3 4 4 5 5 5 
1 1 1 1 4 4 4 4 4 6 
1 1 1 1 4 4 4 4 5 5 
1 1 1 2 2 2 3 6 6 6 
1 1 1 2 2 2 4 5 6 6 
1 1 1 2 2 2 5 5 5 6 
1 1 1 2 2 3 3 5 6 6 
1 1 1 2 2 3 4 4 6 6 
1 1 1 2 2 3 4 5 5 6 
1 1 1 2 2 3 5 5 5 5 
1 1 1 2 2 4 4 4 5 6 
1 1 1 2 2 4 4 5 5 5 
1 1 1 2 3 3 3 4 6 6 
1 1 1 2 3 3 3 5 5 6 
1 1 1 2 3 3 4 4 5 6 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 4 5 
1 2 2 2 3 3 3 3 5 6 
1 2 2 2 3 3 3 4 4 6 
1 2 2 2 3 3 3 4 5 5 
1 2 2 2 3 3 4 4 4 5 
1 2 2 2 3 4 4 4 4 4 
1 2 2 3 3 3 3 3 4 6 
1 2 2 3 3 3 3 3 5 5 
1 2 2 3 3 3 3 4 4 5 
1 2 2 3 3 3 4 4 4 4 
1 2 3 3 3 3 3 3 3 6 
1 2 3 3 3 3 3 3 4 5 
1 2 3 3 3 3 3 4 4 4 
1 3 3 3 3 3 3 3 3 5 
1 3 3 3 3 3 3 3 4 4 
2 2 2 2 2 2 2 4 6 6 
2 2 2 2 2 2 2 5 5 6 
2 2 2 2 2 2 3 3 6 6 
2 2 2 2 2 2 3 4 5 6 
2 2 2 2 2 2 3 5 5 5 
2 2 2 2 2 2 4 4 4 6 
2 2 2 2 2 2 4 4 5 5 
2 2 2 2 2 3 3 3 5 6 
2 2 2 2 2 3 3 4 4 6 
2 2 2 2 2 3 3 4 5 5 
2 2 2 2 2 3 4 4 4 5 
2 2 2 2 2 4 4 4 4 4 
2 2 2 2 3 3 3 3 4 6 
2 2 2 2 3 3 3 3 5 5 
2 2 2 2 3 3 3 4 4 5 
2 2 2 2 3 3 4 4 4 4 
2 2 2 3 3 3 3 3 3 6 
2 2 2 3 3 3 3 3 4 5 
2 2 2 3 3 3 3 4 4 4 
2 2 3 3 3 3 3 3 3 5 
2 2 3 3 3 3 3 3 4 4 
2 3 3 3 3 3 3 3 3 4 
3 3 3 3 3 3 3 3 3 3 
Total combinations (without taking into account the order): 121

How long would it take to list all possible outcomes?

Brute force analytical solution

What is the probability that the sum of the numbers when rolling ten fair dice is 30?

Factorial

The factorial of a non–negative integer \(n\), denoted by \(n!\), is the product of all positive integers less than or equal to \(n\).

  • E.g \(5! = 5\times 4\times 3\times 2\times 1 = 120\).
  • Note: we define \(0!=1\) by convention.
  • In R, there are several ways to compute factorials:

Combination

A combination is a selection of objects from a collection where the order of selection does not matter. The number of combinations of \(r\) objects from a collection of \(n\) objects is given by the formula:

\[{n \choose r}=\frac{n !}{(n-r) ! r !}.\]

  • This is read as “\(n\) choose \(r\)”.
  • E.g. choosing a committee of 3 people from 10 candidates: \[{10 \choose 3} = \dfrac{10!}{(10-3)!3!} = 120\] combinations.

Permutation

A permutation is an arrangement of items from a collection where the order matters. The number of permutations of \(r\) objects from a collection of \(n\) objects is given as:

\[(n)_r = \frac{n!}{(n-r)!}\]

  • E.g. arranging 3 books from a shelf of 5 books: \[(5)_3 = \dfrac{5!}{(5-3)!} = 60\] permutations.

Challenge

A password is created by selecting 3 unique letters from the word “PASSWORD” and arranging them in any order. How many possible passwords are there?

A committee of 5 people is selected from a group of 8 men and 6 women. What is the probability that the committee contains exactly 3 women?

How many ways can 8 people sit around a circular table?

Summary

  • Factorials are used to count the number of ways to arrange objects.
  • Combinations count the number of ways to choose objects when order does not matter.
  • Permutations count the number of ways to arrange objects when order matters.