Counting Principles
Counting is the arithmetic behind finite probability. When outcomes are equally likely, probability reduces to a ratio: favorable outcomes divided by possible outcomes. The difficulty is rarely the division; it is deciding what should be counted, whether order matters, and whether repetition is allowed.

Figure: Pascal's triangle organizes binomial coefficients, combinations, and recurrence patterns. Image: Wikimedia Commons, Hersfold, public domain.
This page keeps counting brief because discrete mathematics usually treats it in greater depth. The goal here is to make probability calculations reliable enough for binomial, hypergeometric, multinomial, and card-style examples. For a fuller discrete treatment, use the cross-link at the end.
Definitions
The multiplication principle says that if a process has choices at one stage and choices at the next stage for each first choice, then the two-stage process has outcomes. More generally, stages with choices have
total outcomes.
A permutation is an ordered arrangement. If objects are selected without replacement from distinct objects, the number of ordered selections is
A combination is an unordered selection. If objects are selected without replacement from distinct objects, the number of unordered selections is
The symbol means
A multinomial coefficient counts the number of ways to divide labeled positions into groups of sizes , where :
A combination with repetition chooses items from types when repeated choices are allowed and order does not matter:
Key results
| Situation | Order matters? | Repetition? | Count |
|---|---|---|---|
| length strings from symbols | yes | yes | |
| ordered sample of from | yes | no | |
| unordered sample of from | no | no | |
| split positions into labeled groups | partially | no | |
| choose items from types | no | yes |
Two identities appear constantly in probability.
Symmetry of combinations.
Choosing the included objects is equivalent to choosing the excluded objects.
Pascal identity.
Proof sketch: focus on a particular object, say object . A size- subset either includes it, in which case choose more from the remaining , or excludes it, in which case choose all from the remaining .
Binomial theorem.
In probability, this identity explains why binomial probabilities sum to one:
A useful counting workflow is to decide on a representation before calculating. If the experiment produces a sequence, count ordered sequences. If the final outcome is a set, count unordered selections. If the experiment is easier to count in ordered form but the probability question is unordered, count ordered outcomes consistently in both numerator and denominator or divide by the appropriate number of orderings. Mixing ordered and unordered counts in the same fraction is one of the most common sources of wrong answers.
Sometimes the complement is easier to count than the event itself. For example, "at least one shared birthday" is difficult to count directly because many overlap patterns are possible. Its complement, "all birthdays are different," has a clean product:
Then the desired probability is one minus that value. Similar complement strategies work for "at least one success," "not all distinct," and "at least one collision" problems.
For multinomial counts, remember that the coefficient counts arrangements of category labels, not probabilities. The probability of each arrangement is supplied separately by . If all categories are equally likely, the probability part may look simple, but the arrangement count is still essential.
Counting with restrictions often benefits from building the object in stages. If a password must contain at least one digit, count all passwords and subtract those with no digits. If a committee must contain members from several groups, choose the group counts first and then choose people within each group. If two selected objects cannot be adjacent, place the unrestricted objects first and then count the available gaps. The goal is not to force every problem into one formula; it is to choose stages that avoid double counting.
When inclusion-exclusion is needed, label the "bad" events clearly. For example, if counting arrangements where no task misses its deadline, define as "task misses its deadline." Then the desired count is the total minus the union of the bad events. This keeps the signs and intersections organized.
As a final check, estimate the scale of the answer. A probability should lie between and , and a count should be an integer. If a count of favorable outcomes exceeds the total sample space, the numerator and denominator are probably based on inconsistent outcome definitions.
Visual
| Probability model | Counting tool | Example |
|---|---|---|
| Binomial | combinations | exactly successes in independent trials |
| Hypergeometric | combinations | successes in draws without replacement |
| Multinomial | multinomial coefficients | category counts across repeated trials |
| Poker hands | combinations | unordered five-card hand |
| Passwords | multiplication principle | ordered strings with allowed symbols |
Worked example 1: exactly two aces in a poker hand
Problem. A five-card hand is dealt from a standard deck. What is the probability that the hand contains exactly two aces?
Method.
- A poker hand is unordered, so the total number of hands is
-
To get exactly two aces:
- choose of the aces;
- choose the remaining cards from the non-aces.
Thus the favorable count is
- The probability is
- Compute the pieces:
- Substitute:
Checked answer. The probability is about . The structure matches the hypergeometric distribution: successes are aces, and sampling is without replacement.
Worked example 2: multinomial category counts
Problem. A customer chooses one of three drink sizes on each visit: small with probability , medium with probability , and large with probability . Assuming independent visits, what is the probability that in visits the customer chooses small, medium, and large?
Method.
-
The sequence is ordered in time, but the requested event specifies only counts. We must count how many sequences have those counts.
-
The number of sequences with S, M, and L is
- Compute it:
- Any particular sequence with these counts has probability
- Multiply count by probability per sequence:
Checked answer. The probability is about . If we forgot the multinomial coefficient, we would compute only one particular order, not all orders with the requested counts.
Code
from math import comb, factorial
def poker_exactly_two_aces():
favorable = comb(4, 2) * comb(48, 3)
total = comb(52, 5)
return favorable / total
def multinomial_probability(counts, probs):
n = sum(counts)
coefficient = factorial(n)
for count in counts:
coefficient //= factorial(count)
probability = coefficient
for count, prob in zip(counts, probs):
probability *= prob ** count
return probability
print(poker_exactly_two_aces())
print(multinomial_probability([2, 5, 1], [0.25, 0.50, 0.25]))
Common pitfalls
- Counting ordered objects when the outcome is unordered, especially with card hands.
- Counting unordered objects when order actually matters, such as passwords, rankings, or sequences over time.
- Forgetting to multiply by the number of arrangements after computing the probability of one particular sequence.
- Using when sampling is with replacement. Without replacement and with replacement are different models.
- Treating categories as distinguishable when they are not, or indistinguishable when labels matter.
- Forgetting that probabilities require both a count and an equally likely sample space. Counting alone does not justify a probability model.