6 * 5 * 4 * 3 * 2 * 1[1] 720
factorial(6)[1] 720
POSC 8410
Every counting problem comes down to two questions:
1. A ballot lists 6 candidates. How many possible orderings are there?
Six candidates can go in the first slot. For each of those, five remain for the second slot, then four, and so on. This is the multiplication rule:
\[6 \times 5 \times 4 \times 3 \times 2 \times 1 = 6! = 720\]
6 * 5 * 4 * 3 * 2 * 1[1] 720
factorial(6)[1] 720
This is the cabinet formula \(n(n-1)\cdots(n-k+1)\) with \(k = n\): we are filling every slot, so the count runs all the way down to 1. With 720 possible orders, there is no “neutral” ordering. Someone always gets the top line, which is why election officials randomize or rotate the order across ballots.
2. You are selecting 4 countries from a pool of 15 for a comparative case study. How many possible sets?
If order mattered, the multiplication rule would give \(15 \times 14 \times 13 \times 12 = 32{,}760\). But a case study design is a set. Picking Brazil first and Chile second gives the same four cases as picking Chile first and Brazil second. Each set of four was counted once for every way of ordering it, which is \(4! = 24\) times. So divide:
\[\binom{15}{4} = \frac{15 \times 14 \times 13 \times 12}{4!} = \frac{32{,}760}{24} = 1{,}365\]
15 * 14 * 13 * 12 # ordered selections[1] 32760
(15 * 14 * 13 * 12) / factorial(4)[1] 1365
choose(15, 4)[1] 1365
combn() writes out every subset of size 4 as a column, so counting the columns counts the sets:
ncol(combn(15, 4))[1] 1365
3. A content analyst codes each of 20 documents into one of 5 categories. How many possible coding schemes?
Each document gets one of 5 codes, and using a category for one document does not use it up for the next. That makes 20 choices, each with 5 options:
\[5^{20} = 95{,}367{,}431{,}640{,}625\]
5^20[1] 9.536743e+13
format(5^20, big.mark = ",", scientific = FALSE) # the same number, written out in full[1] "95,367,431,640,625"
R prints very large numbers in scientific notation by default: 9.536743e+13 means \(9.54 \times 10^{13}\). The second line asks R to write it out in full.
This is the same structure as the roll-call example from class (\(2^{10}\) voting records), with 5 options per choice instead of 2. The count is about 95 trillion from only 20 documents, which is why you can never check every possible coding by hand. Text-as-data methods have to work with the coding the analyst actually produced.
4. For each: with or without replacement? Does order matter?
Collecting the answers above:
| Problem | Replacement? | Order matters? | Formula | Count |
|---|---|---|---|---|
| Ballot order | Without | Yes | \(6!\) | 720 |
| Case selection | Without | No | \(\binom{15}{4}\) | 1,365 |
| Document coding | With | Yes | \(5^{20}\) | about 95 trillion |
A good habit is to ask the two questions before you do anything else. Most counting mistakes come from using the right formula for the wrong world. For example, treating the case-selection problem as ordered overcounts by a factor of 24.