PSTAT 5A: Counting

Lecture 7 - Combinations

Narjes Mathlouthi

2025-07-10

Welcome to Lecture 7 (Part 2)

The art and science of systematic enumeration

Today’s Learning Objectives

Learning Objectives

By the end of this lecture, you will be able to:

  • Calculate combinations and understand when to use them (Section 3, Section 4)
  • Distinguish between permutations and combinations (Section 7)
  • Use counting techniques to solve probability problems (Section 12)
  • Apply the inclusion-exclusion principle (Section 17)
  • Solve complex counting problems systematically (Section 21)

What Are Combinations?

Combination

A selection of objects where order does NOT matter

Committee Selection:

ABC, BAC, CAB → Same committee!

Race Results:

ABC, BAC, CAB → Different outcomes!

Note

Key Point: Order doesn’t matter for combinations

All combinations of 4 items taken 2 at a time:
1. A, B
2. A, C
3. A, D
4. B, C
5. B, D
6. C, D

Combinations Formula

Key Formula

\(C(n,r)\) or \(\binom{n}{r}\): Number of ways to choose \(r\) objects from \(n\) distinct objects (order doesn’t matter)

\[C(n,r) = \binom{n}{r} = \frac{n!}{r!(n-r)!}\]

\(\binom{n}{r}\) reads “\(n\) choose \(r\)

How many ways can we choose 3 people from a group of 8 for a committee?

Solution. \(C(8,3) = \frac{8!}{3!(8-3)!} = \frac{8!}{3! \times 5!} = \frac{8 \times 7 \times 6}{3 \times 2 \times 1} = 56\)

Permutations vs Combinations

Relationship

  • \(P(n,r) = \frac{n!}{(n-r)!} \quad (1)\)

and,

  • \(C(n,r) = \frac{n!}{(n-r)!} \quad (2)\)

Plugging (2) into (1) and multiplying by \(r\) which represents the number of arrangements we get :

\(P(n,r) = C(n,r) \times r!\) (multiply by arrangements)

Why? For each combination of \(r\) objects, there are \(r!\) ways to arrange them

Similarly,

\(C(n,r) = P(n,r)/ r!\) (divide out arrangements)

Why? diving by \(r\) removes the arrangements from our formula and leaves us with the number of selection possible from \(n\) objects.

Note

  • Permutations = Combinations × Arrangements

  • Combinations answer: “How many ways can I choose?”

  • Arrangements answer: “How many ways can I order what I chose?”*

  • Permutations answer: “How many ways can I choose AND order?”

\(\text{Choose} \times \text{Arrange} = \text{Choose and Arrange}\)

\[ \underbrace{\binom{n}{r}}{\substack{\text{choose which}\\r\text{ elements}}} \;\times\; \underbrace{r!}{\substack{\text{order those}\\r\text{ elements}}} \;=\; \frac{n!}{r!(n-r)!}\;\times\;r! \;=\; \frac{n!}{(n-r)!} \;=\; P(n,r). \]

Thus,

\(C(n,r)×r!= P(n,r)\)

Permutations vs Combinations Example

Select 3 people from a group of 5 for different purposes.

  • For a ranked competition (order matters):

    1st place, 2nd place, 3rd place matter

    Use permutations: \(P(5,3) = \frac{5!}{(5-3)!} = \frac{5!}{2!} = \frac{120}{2} = 60\) ways

  • For a committee (order doesn’t matter):

    Just need 3 people, no specific roles

    Use combinations: \(C(5,3) = \frac{5!}{3!(5-3)!} = \frac{5!}{3! \cdot 2!} = \frac{120}{6 \cdot 2} = 10\) ways

Verifying the relationship:

\(P(5,3)=C(5,3)×3!\)

\(60=10 \times 6 \checkmark\)

For each of the 10 combinations, there are \(3! = 6\) ways to arrange them, giving us the 60 permutations.

Key Decision: Permutation or Combination?

How to Decide

Ask yourself: Does order matter?

Order matters → Use Permutations

  • Arrangements, sequences, rankings

Order doesn’t matter → Use Combinations

  • Selections, groups, subsets

Note

\(P(n,r)\) = counts both selection & arrangement → grows faster

\(C(n,r)\) = counts only selection → grows slower

✅ The difference comes from \(r!\), which is big even for modest \(r\).

Practice Problem 3

From a class of 20 students:

  1. How many ways to choose 5 students for a study group?
  2. How many ways to choose a president, vice-president, and secretary?

Solution.

  1. \(C(20,5) = \frac{20!}{5! \times 15!} = 15,504\) (order doesn’t matter)
  2. \(P(20,3) = \frac{20!}{17!} = 6,840\) (order matters)

Properties of Combinations

Properties

  1. Symmetry: \(\binom{n}{r} = \binom{n}{n-r}\)
  2. Pascal’s Identity: \(\binom{n}{r} = \binom{n-1}{r-1} + \binom{n-1}{r}\)
  3. Boundary conditions: \(\binom{n}{0} = \binom{n}{n} = 1\)

\(\binom{8}{3} = \binom{8}{5} = 56\)

Pascal’s Triangle

Pascal’s Triangle

       1                    ← (x + y)⁰
     1   1                  ← (x + y)¹
   1   2   1                ← (x + y)²
 1   3   3   1              ← (x + y)³
1   4   6   4   1           ← (x + y)⁴
1  5  10  10  5  1          ← (x + y)⁵

Each number equals \(\binom{n}{r}\) where \(n\) is the row number and \(r\) is the position from the left (starting at 0).

Note

Pattern: Each number is the sum of the two numbers above it.

Formula: \(\binom{n}{r} = \binom{n-1}{r-1} + \binom{n-1}{r}\)

Example: \(\binom{4}{2} = 6\) (row 4, position 2)

Row 3:       1   3   3   1
            ↙ ↘ ↙ ↘ ↙ ↘ ↙ ↘
Row 4:     1   4   6   4   1

Binomial Theorem

Key Formula

\[(x + y)^n = \sum_{r=0}^{n} \binom{n}{r} x^{n-r} y^r\]

This formula tells us how to expand \((x + y)\) raised to any positive integer power \(n\).

EXAMPLE

\((x + y)^3 = \binom{3}{0}x^3 + \binom{3}{1}x^2y + \binom{3}{2}xy^2 + \binom{3}{3}y^3\)

\(= x^3 + 3x^2y + 3xy^2 + y^3\)

Key Insights

The General Pattern

Powers decrease and increase systematically:

  • Powers of \(x\): \(n, n-1, n-2, \ldots, 1, 0\)

  • Powers of \(y\): \(0, 1, 2, \ldots, n-1, n\)

  • Sum of powers in each term: always equals \(n\)

Coefficients come from Pascal’s Triangle:

  • Coefficient of \(x^{n-r}y^r\) is \(\binom{n}{r}\)

  • Read directly from row \(n\) of Pascal’s Triangle

Symmetry in coefficients:

First and last terms have coefficient 1 Coefficients are symmetric: \(\binom{n}{0} = \binom{n}{n}\), \(\binom{n}{1} = \binom{n}{n-1}\), etc.

Counting and Probability

A committee of 4 people is chosen from 7 women and 5 men. What’s the probability that exactly 2 are women?

  • Total ways to choose 4 from 12: \(\binom{12}{4} = 495\)

  • Ways to choose 2 women from 7: \(\binom{7}{2} = 21\)

  • Ways to choose 2 men from 5: \(\binom{5}{2} = 10\)

Solution. Favorable outcomes: \(\binom{7}{2} \times \binom{5}{2} = 21 \times 10 = 210\)

Probability: \(\frac{210}{495} = \frac{14}{33}\)

Practice Problem 4

A standard deck has 52 cards. What’s the probability that a 5-card hand contains:

  1. Exactly 3 aces? \(P(\text{exactly 3 aces in 5 cards})\)

Solution.

  1. Total number of 5-card hands \[\binom{52}{5} = \frac{52\cdot51\cdot50\cdot49\cdot48}{5\cdot4\cdot3\cdot2\cdot1} = \frac{311{,}875{,}200}{120} \\ = 2{,}598{,}960 \]

  2. Ways to choose exactly 3 aces \[ \binom{4}{3} = \frac{4\cdot3\cdot2}{3\cdot2\cdot1} = \frac{24}{6} = 4 \]

  3. Ways to choose the other 2 cards from the 48 non-aces \[ \binom{48}{2} = \frac{48\cdot47}{2\cdot1} = \frac{2{,}256}{2} = 1{,}128 \]

  4. Total “successful” hands \(4 \times 1{,}128 = 4{,}512\)

  5. Probability \[P = \frac{\text{successful}}{\text{total}} = \frac{4{,}512}{2{,}598{,}960} \approx 0.001735 \;=\;0.1735\%\]

Practice Problem 4

A standard deck has 52 cards. What’s the probability that a 5-card hand contains:

  1. Exactly 3 aces? \(P(\text{exactly 3 aces in 5 cards})\)
  1. At least 1 ace? \(P(\text{at least one ace})\)

Solution.

  1. Ways to pick 5 cards with zero aces All 5 come from the 48 non-aces: \[\binom{48}{5} = \frac{48\cdot47\cdot46\cdot45\cdot44}{5\cdot4\cdot3\cdot2\cdot1} = \frac{205{,}476{,}480}{120} = 1{,}712{,}304\]

  2. Probability of no aces \[ P(\text{no aces}) = \frac{\binom{48}{5}}{\binom{52}{5}} = \frac{1{,}712{,}304}{2{,}598{,}960} \approx 0.659 \quad \text{or} 65.9 \% \]

  3. Subtract from 1 \[P(\text{at least one ace}) = 1 - P(\text{no aces}) = 1 - 0.659 \approx 0.341\]

Practice Problem 4 (continued)

Tip

  • Hypergeometric formula: \[ P(\text{exactly }k\text{ successes}) = \frac{\binom{K}{k}\,\binom{N-K}{n-k}}{\binom{N}{n}} \]

where \(N=52\), \(K=4\) aces, \(n=5\) draws, and \(k\) is the number of aces you want.

  • Complement trick: \(\;P(\ge1\text{ ace}) = 1 - P(0\text{ aces})\).

This structure makes it easy to plug in any “number of successes” you need, or to use the complement when you want “at least one.”

Hypergeometric in one formula

For part (a) you could also write directly:

\[P(k=3) = \frac{\binom{4}{3}\,\binom{48}{2}}{\binom{52}{5}} = \frac{4\cdot1{,}128}{2{,}598{,}960} \approx 0.001735\]

And for part (b):

\[ P(\ge1) = 1 - \frac{\binom{48}{5}}{\binom{52}{5}} = 1 - 0.6590 = 0.3410\]

Permutations with Restrictions

How many 6-letter “words” can be formed from the letters A, B, C, D, E, F if:

  • No letter is repeated

  • A and B must be adjacent

Solution. Treat AB as a single unit

  • 5 units to arrange: (AB), C, D, E, F → \(5! = 120\) ways

  • A and B can be arranged within their unit: \(2! = 2\) ways

  • Total: \(5! \times 2! = 240\) ways

The Inclusion-Exclusion Principle

The Principle of Inclusion–Exclusion lets you count (or find the probability of) the union of several sets by alternately adding and subtracting the sizes of their intersections.

For two sets \(A\) and \(B\): \[|A \cup B| = |A| + |B| - |A \cap B|\]

For three sets \(A\), \(B\), and \(C\): \[|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| \\ - |A \cap C| - |B \cap C| + |A \cap B \cap C|\]

Inclusion-Exclusion Example

How many integers from 1 to 100 are divisible by 2, 3, or 5?

Let:

  • \(A\) = divisible by 2: \(|A| = 50\)

  • \(B\) = divisible by 3: \(|B| = 33\)

  • \(C\) = divisible by 5: \(|C| = 20\)

Note

\(|A \cap B| = 16\) (divisible by 6)

\(|A \cap C| = 10\) (divisible by 10)

\(|B \cap C| = 6\) (divisible by 15)

\(|A \cap B \cap C| = 3\) (divisible by 30)

Inclusion-Exclusion Solution

Solution. \[|A \cup B \cup C| = 50 + 33 + 20 - 16 - 10 - 6 + 3 = 74\]

Answer: 74 integers from 1 to 100 are divisible by at least one of 2, 3, or 5

Multinomial Coefficients

Multinomial Coefficient

Number of ways to divide \(n\) objects into groups of sizes \(n_1, n_2, \ldots, n_k\):

\[\binom{n}{n_1, n_2, \ldots, n_k} = \frac{n!}{n_1! \times n_2! \times \cdots \times n_k!}\]

How many ways can 12 people be divided into 3 teams of 4?

\(\binom{12}{4,4,4} = \frac{12!}{4! \times 4! \times 4!} = 34,650\)

Problem-Solving Strategy

Strategy

  1. Read carefully: What exactly are we counting?
  2. Identify the type: Permutation, combination, or other?
  3. Check for restrictions: Are there constraints?
  4. Does order matter?: This determines permutation vs combination
  5. Break down complex problems: Use multiplication principle
  6. Verify your answer: Does it make sense?

Common Mistakes to Avoid

Common Mistakes

  1. Confusing permutations and combinations
    • Always ask: “Does order matter?”
  2. Forgetting about restrictions
    • Read the problem carefully
  3. Double counting
    • Make sure you’re not counting the same arrangement twice
  4. Not considering the complement
    • Sometimes “at least” problems are easier using complements

Practice Problem 6

A class has 15 students: 8 women and 7 men. How many ways can we:

  1. Form a committee of 5 people with exactly 3 women?
  2. Arrange 6 people in a row with alternating genders (starting with a woman)?

Solution.

  1. \(\binom{8}{3} \times \binom{7}{2} = 56 \times 21 = 1,176\)
  2. Choose 3 women from 8: \(P(8,3) = 336\) Choose 3 men from 7: \(P(7,3) = 210\) Total: \(336 \times 210 = 70,560\)

Counting in Computer Science

Password Security:

  • 8-character password with letters, digits, symbols

  • \((26 + 26 + 10 + 32)^8 = 94^8 \approx 6.1 \times 10^{15}\)

Hash Functions:

  • Distributing data into buckets

  • Collision probability calculations

Algorithm Analysis:

  • Counting operations, comparisons

  • Big O notation foundations

Counting in Genetics

DNA Sequences:

  • 4 bases (A, T, G, C)

  • Gene of length \(n\): \(4^n\) possible sequences

Protein Folding:

  • Number of possible conformations

  • Combinatorial explosion

Population Genetics:

  • Hardy-Weinberg calculations

  • Allele combinations

Real-World Applications

Lottery:

  • Powerball: Choose 5 from 69, then 1 from 26

  • Odds: \(\frac{1}{\binom{69}{5} \times 26} \approx \frac{1}{292,000,000}\)

Cryptography:

  • Key space size determines security

  • RSA encryption relies on large number factorization

Sports Tournaments:

  • March Madness bracket: \(2^{63}\) possible outcomes

  • Round-robin tournaments: \(\binom{n}{2}\) games

Key Formulas Summary

Summary of Key Formulas

  • Permutations: \(P(n,r) = \frac{n!}{(n-r)!}\)
  • Combinations: \(C(n,r) = \binom{n}{r} = \frac{n!}{r!(n-r)!}\)
  • With repetition: \(\frac{n!}{n_1! \times n_2! \times \cdots \times n_k!}\)
  • Inclusion-Exclusion: \(|A \cup B| = |A| + |B| - |A \cap B|\)

Technology and Counting

Tools

Calculators:

  • Use nPr and nCr functions

  • Be careful with large numbers

Software:

  • R: factorial(), choose(), combn()

  • Python: math.factorial(), math.comb()

  • Excel: FACT(), COMBIN(), PERMUT()

Online Tools:

  • Wolfram Alpha for complex calculations

  • Combination/permutation calculators

Practice Problem 7

A standard deck of cards is shuffled. What’s the probability that:

  1. The top 4 cards are all hearts?
  2. In a 13-card hand, you get exactly one card from each rank?

Solution.

  1. \(\frac{13}{52} \times \frac{12}{51} \times \frac{11}{50} \times \frac{10}{49} = \frac{13 \times 12 \times 11 \times 10}{52 \times 51 \times 50 \times 49} \approx 0.0026\)

  2. Choose 1 card from each of 13 ranks: \(4^{13}\) Total 13-card hands: \(\binom{52}{13}\) Probability: \(\frac{4^{13}}{\binom{52}{13}} \approx 6.3 \times 10^{-6}\)

Extending to Probability

Distributions

Hypergeometric Distribution:

  • Drawing without replacement

  • Uses combinations: \(P(X = k) = \frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}\)

Binomial Distribution:

  • Drawing with replacement

  • Uses combinations: \(P(X = k) = \binom{n}{k}p^k(1-p)^{n-k}\)

We’ll explore these distributions in detail in future lectures

Historical Note

History

Blaise Pascal (1623-1662) and Pierre de Fermat (1601-1665): - Founded probability theory through gambling problems - Pascal’s triangle and combinations

Leonhard Euler (1707-1783): - Advanced combinatorics - Graph theory connections

Modern applications span computer science, biology, physics, and economics

Common Student Questions

Q: “When do I use permutations vs combinations?”

A: Ask “Does order matter?” Order matters → permutation

Q: “How do I handle restrictions?”

A: Break the problem into cases or use complementary counting

Q: “What if objects are identical?”

A: Use the formula for permutations with repetition

Q: “How do I check my answer?”

A: Verify with small examples or use different methods

Looking Ahead

Next Lecture

Next lecture: Discrete Probability Distributions - Binomial distribution (using combinations!)

  • Hypergeometric distribution

  • Geometric distribution

  • Expected value and variance

Connection: Today’s counting techniques are essential for probability calculations

Study Tips

Tips

  1. Practice, practice, practice: Work through many examples
  2. Identify patterns: Learn to recognize problem types
  3. Start simple: Build up to complex problems
  4. Check your work: Use different approaches when possible
  5. Understand concepts: Don’t just memorize formulas

Learning Objectives Summary

What We’ve Covered

In this lecture, we’ve addressed all the learning objectives:

  • Calculate combinations and understand when to use them: Covered in Section 3 and Section 4
  • Distinguish between permutations and combinations: Covered in Section 7
  • Use counting techniques to solve probability problems: Covered in Section 12
  • Apply the inclusion-exclusion principle: Covered in Section 17
  • Solve complex counting problems systematically: Covered in Section 21

Final Thoughts

Counting is fundamental to:

  • Probability calculations

  • Statistical inference

  • Computer algorithms

  • Scientific modeling

Know the Basics

Permutations and combinations are the building blocks for advanced statistical concepts

Questions?

Office Hours: Thursday’s 11 AM On Zoom (Link on Canvas)

Email: nmathlouthi@ucsb.edu

Next Class: Random Variables