Combinations and the Binomial Coefficient
Master unordered selection using the binomial coefficient, Pascal's triangle, and combinatorial identities.
Introduction
So far, we've counted ordered arrangements (permutations). But what if order doesn't matter? When selecting a committee of 3 people from 10, {Alice, Bob, Carol} is the same as {Carol, Alice, Bob}. This is the realm of combinations.
Learning Objectives:
- Understand the difference between permutations and combinations
- Master the binomial coefficient formula
- Apply Pascal's triangle and combinatorial identities
- Verify calculations using Python
Permutations vs Combinations
The fundamental distinction:
- Permutation: Order matters - ABC โ BAC (different arrangements)
- Combination: Order doesn't matter - {A, B, C} = {C, A, B} (same selection)
Example 1: Card Selection
Draw 2 cards from a deck of 4 cards {A, B, C, D}:
Permutations (ordered): AB, AC, AD, BA, BC, BD, CA, CB, CD, DA, DB, DC โ 12 permutations
Combinations (unordered): {A,B}, {A,C}, {A,D}, {B,C}, {B,D}, {C,D} โ 6 combinations
Notice: (each combination corresponds to permutations)
Key Question: "Does the order matter?" If selecting a team, order doesn't matter. If assigning roles (president, VP), order matters.
The Binomial Coefficient
The number of ways to choose objects from distinct objects without regard to order is:
Read as " choose " or "C(n, k)".
Derivation:
- Permutations of from :
- Each combination has orderings (overcounting by factor of )
- Divide by to get combinations:
Example 2: Committee Selection
Choose a committee of 3 people from 10 people. How many possible committees?
Solution:
Why divide by ? Each committee of {A, B, C} was counted times in the permutation count (ABC, ACB, BAC, BCA, CAB, CBA are all the same committee).
import math
def combination(n, k):
"""Calculate C(n, k) = n! / (k! * (n-k)!)"""
return math.factorial(n) // (math.factorial(k) * math.factorial(n - k))
# Committee of 3 from 10
n = 10
k = 3
result = combination(n, k)
print(f"C({n}, {k}) = {result}")
print(f"\nThere are {result} possible committees")
# Show calculation breakdown
numerator = math.factorial(n)
denominator = math.factorial(k) * math.factorial(n - k)
print(f"\nCalculation:")
print(f" Numerator: {n}! = {numerator:,}")
print(f" Denominator: {k}! ร {n-k}! = {math.factorial(k)} ร {math.factorial(n-k):,} = {denominator:,}")
print(f" Result: {numerator:,} / {denominator:,} = {result}")
# Alternative: using scipy
from scipy.special import comb as scipy_comb
print(f"\nVerification with scipy: {int(scipy_comb(n, k, exact=True))}")Symmetry Property
One of the most beautiful identities:
Intuition: Choosing objects to include is the same as choosing objects to exclude.
Example 3: Card Selection
From a deck of 52 cards, choose 50 cards:
Computing directly involves huge factorials, but using symmetry, we compute instead - much easier!
from scipy.special import comb
# Demonstrate symmetry
n = 52
# Computing C(52, 50) directly
result1 = int(comb(n, 50, exact=True))
# Using symmetry: C(52, 50) = C(52, 2)
result2 = int(comb(n, 2, exact=True))
print(f"C({n}, 50) = {result1:,}")
print(f"C({n}, 2) = {result2:,}")
print(f"Equal: {result1 == result2}")
# Show computational advantage
print(f"\nDirect calculation of C(52, 2):")
print(f" (52 ร 51) / 2 = {52 * 51 // 2:,}")Pascal's Triangle
Pascal's Triangle is a visual representation of binomial coefficients:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
Each number is where is the row (starting from 0) and is the position (starting from 0).
Pascal's Identity:
Intuition: To choose from objects, consider object #1:
- Include object #1: Choose from remaining โ
- Exclude object #1: Choose from remaining โ
from scipy.special import comb
def pascal_triangle(rows):
"""Generate Pascal's triangle"""
for n in range(rows):
row = [int(comb(n, k, exact=True)) for k in range(n + 1)]
print(f"Row {n}: {row}")
print("Pascal's Triangle (first 8 rows):")
pascal_triangle(8)
# Verify Pascal's Identity: C(n,k) = C(n-1,k-1) + C(n-1,k)
n, k = 6, 3
left = int(comb(n, k, exact=True))
right = int(comb(n-1, k-1, exact=True)) + int(comb(n-1, k, exact=True))
print(f"\nVerifying Pascal's Identity for C({n}, {k}):")
print(f" C({n}, {k}) = {left}")
print(f" C({n-1}, {k-1}) + C({n-1}, {k}) = {int(comb(n-1, k-1, exact=True))} + {int(comb(n-1, k, exact=True))} = {right}")
print(f" Equal: {left == right}")The Binomial Theorem
Binomial coefficients appear in polynomial expansions:
Example 4:
The coefficients are row 3 of Pascal's Triangle: 1, 3, 3, 1
Special case:
Interpretation: The sum of all binomial coefficients in row equals (total subsets of an -element set).
Key Takeaways
- Combination: Unordered selection,
- Symmetry: (choosing vs excluding)
- Pascal's Identity:
- Binomial Theorem:
- Sum of row:
Next Lesson: We'll tackle multisets and stars and bars for counting with repetition allowed!
Formula | Description | Example |
|---|---|---|
| $\binom{n}{k} = \frac{n!}{k!(n-k)!}$ | Combinations | $\binom{10}{3} = 120$ |
| $\binom{n}{k} = \binom{n}{n-k}$ | Symmetry | $\binom{52}{50} = \binom{52}{2}$ |
| $\binom{n}{k} = \binom{n-1}{k-1} + \binom{n-1}{k}$ | Pascal's Identity | $\binom{6}{3} = \binom{5}{2} + \binom{5}{3}$ |
| $\sum_{k=0}^{n} \binom{n}{k} = 2^n$ | Sum of row | $1+3+3+1 = 8 = 2^3$ |