Discrete Math for Data Science
DSCI 220, 2025 W1
November 17, 2025
Warm-Up: Multiplication Rule
Question:
What happens to the number of rows in a DataFrame when we use pandas.melt()?
This is a data-science version of the multiplication rule :
when we consider every possible combination of two attributes, the number of possibilities multiplies.
➡️ We’ll use the same reasoning today — but with people and chairs instead of rows and columns.
Notes:
Use this to remind students that the multiplication rule already appears in data contexts they know.
Encourage them to connect this to the idea of enumerating combinations of attributes.
Keep the demo under 4 minutes — it’s just a bridge to the main activity.
⏱️ Timing: 3–4 minutes warm-up discussion.
Visualizing Wide to Long
Before melting (wide format):
After melting (long format):
Each wide row expands into three long rows — one for each temperature.
Each pair (Object, Temperature) is one combination —just like the outfits we counted last time.
The total number of rows = 4 objects × 3 temperatures = 12 outcomes.
Notes:
Use this visual to anchor the idea that melting enumerates combinations explicitly.
Optional ask: “Where do we see repetition here? What does that tell us about memory use?”
⏱️ Timing: 3 minutes (interpretation and discussion)
Visualizing the Mapping Change
Before melting:
We have a function that maps each Object to a tuple of states across temperatures:
\[ f:\ \text{Object} \to (\text{Cold},\ \text{Warm},\ \text{Hot}) \]
Example: \[ f( \text{Wicked Witch}) = ( \text{fine}, \text{dripping}, \text{gone?}) \]
After melting:
We redefine the function so that the pair (Object, Temperature) is the input:
\[ g: ( \text{Object}, \text{Temperature}) \to \text{State} \]
Example: \[g( \text{Wicked Witch}, \text{Warm}) = \text{dripping} \]
The input domain has expanded from Objects to Objects × Temperatures . Each input now produces a single scalar output instead of a vector.
This is why the melted data get longer — we’ve made all combinations explicit.
Notes: Emphasize the structural change: multivariate output → single-valued function on a larger domain. This perspective connects directly to Cartesian products and the multiplication rule .
⏱️ Timing: 3 minutes for explanation + brief class recap.
How Melting Affects Data Size
When we melt data, we don’t add new information — we just make existing information longer and more explicit.
Wide
(4, 4)
One row per object; columns for Cold, Warm, Hot
Long (Melted)
(12, 3)
One row for each (Object, Temperature) pair
Effect: The number of rows increases by a factor equal to the number of melted columns.
Each object’s name and each temperature label are now repeated multiple times.
Memory tradeoff : Long data are larger in memory but easier to work with for grouping and plotting.
Prompt: Why would we use a representation that takes more space?
What’s the parallel to our counting models — when do we expand possibilities to make reasoning easier?
Notes:
Emphasize the connection to the multiplication rule: 4 objects × 3 temperatures = 12 outcomes.
Use this as a conceptual bridge — from data transformation to counting combinations in the upcoming seating activity.
⏱️ Timing: 3 minutes for explanation + 1 minute discussion.
A New Counting Challenge
Arrange 4 people around a table.
Question:
How many different ways can the people be seated?
Discuss:
What counts as a different arrangement?
What information defines one arrangement?
Notes:
Begin open-ended — let students debate what counts as a unique arrangement.
The goal is for them to build a model of the outcomes before applying counting rules.
Encourage language like “distinct arrangements,” “rotations,” and “mirror images.”
This primes them for the concepts of permutations (order matters) and combinations (order doesn’t).
⏱️ Timing: 4–5 minutes of pair discussion + 1 minute group debrief. TODO: make “tables with seat numbers” on cardstock
Observing the Structure
Let’s agree on a model for our table:
Each arrangement can be described as a 4-tuple :
(Who’s in seat 1, Who’s in seat 2, Who’s in seat 3, Who’s in seat 4)
Our model is the set of all possible 4-tuples with no repeats.
Notes:
Link this back to the closet model from last time: both are built from describing all possible outcomes.
Here, though, the choices are dependent —once a person is seated, they can’t be chosen again.
Introduce the term permutation : each arrangement of distinct objects where order matters.
⏱️ Timing: 3 minutes setup + 2 minutes partner explanation.
Building an Arrangement
How many choices do we have for each chair?
Seat 1: 4 choices
Seat 2: 3 remaining
Seat 3: 2 remaining
Seat 4: 1 remaining
\(\text{Total} = 4 \times 3 \times 2 \times 1 = 24\) arrangements
That’s the multiplication rule — just like outfits, but now the choices depend on previous ones.
Notes:
Highlight that we’re applying the same reasoning pattern as before: define the structure → count each step → multiply.
Emphasize how dependency reduces the count.
Reinforce vocabulary: these 24 ordered arrangements are permutations of 4 distinct items.
⏱️ Timing: 4 minutes walkthrough + 2 minutes reflection.
Permutations
A permutation is an arrangement of \(n\) distinct objects in a specific order .
Order matters — changing the order creates a new permutation.
Each permutation corresponds to a unique sequence of choices from the set.
If there are \(n\) distinct objects, then the number of permutations is:
\[
P(n) = n! = n \times (n-1) \times (n-2) \times \dots \times 1
\]
Example: Four people can sit in a row in
\[
P(4) = 4! = 24
\]
different ways.
Counting under rotation
Embrace the fact that the table is round .
For any rotation, the group of people is sitting in the same relative order.
For each arrangement there are 4 equivalent. Thus we ______________ the total by ______________.
Alternatively we can fix one person’s seat .
Then the remaining 3 can be arranged freely around the table.
Total distinct circular seatings: \((4 − 1)! = 6\) .
Notes:
Have students physically fix one card to visualize duplicate rotations.
Use the term circular permutation : order still matters, but rotations count as the same.
Ask: “Why does fixing one position remove all rotations?”
⏱️ Timing: 5–6 minutes including demonstration.
Friendship Bracelets
Given: 20 beads , each a different color . Make a circular bracelet by threading all 20 beads.
20-bead bracelet
Twenty differently colored beads arranged in a circle.
Question:
How many different bracelets can be made?
🧶 Think first:
- Does rotating the bracelet create something new?
- What about flipping it over (reflection)?
💭 Discuss with a partner:
1. How does this relate to our “round table” reasoning?
2. What changes when reflections (mirror images) count as the same?
3. How could we generalize our earlier counting model?
Notes:
This parallels circular permutations, but now students must reason about rotations and reflections together (dihedral symmetry).
Encourage qualitative reasoning before formulas — the goal is generalization, not numeric computation.
⏱️ Timing: 5 minutes total (2 think, 2 pair, 1 share).
Choosing a Committee
Goal: From 8 people, form a 3-person committee .
Question:
How many different committees could we form?
Discuss:
Consider it a sequence of 3 choices
Which of those describe the same committee?
How can we apply what we learned about rotations?
💭 Hint: In this model, order doesn’t matter —
it’s who’s in the committee, not who was picked first.
Notes:
This builds on the rotational symmetry reasoning: we’re collapsing multiple ordered arrangements into a single unordered outcome.
Students should reason qualitatively that each distinct committee corresponds to several ordered sequences — and we divide by that number.
⏱️ Timing: 5 minutes total (2 think, 2 pair, 1 share).
From Choices to Combinations
Model our 3-person committee.
If we make choices one at a time:
\[
8 \times 7 \times 6 = 336
\]
That counts every possible order of picking 3 people.
But a committee doesn’t have an order — each group of 3 appears \(3! = 6\) times, once for every possible order.
So the number of distinct committees is:
\[
\frac{8 \times 7 \times 6}{3!} = 56
\]
💡 Model:
Each unordered committee corresponds to 3! ordered sequences.
Notes:
- Connect explicitly to the “rotations” reasoning — we’re dividing out symmetry again, this time the order symmetry of identical choices.
- Encourage students to verbalize what makes two outcomes “the same.”
- Use this moment to name the new idea: combinations .
⏱️ Timing: 4 minutes walkthrough + 1 minute class check-in.
Combinations
A combination is a selection of \(k\) objects from \(n\) where order does not matter .
The group \(\{A, B, C\}\) is the same as \(\{B, A, C\}\) .
Each combination represents a unique set of choices.
If there are \(n\) objects and we choose \(k\) of them, the number of distinct combinations is:
\[
C(n, k) = \binom{n}{k} = \frac{n!}{k!(n-k)!}
\]
Example: Choosing a 3-person committee from 8 people:
\[
C(8, 3) = \frac{8!}{3!5!} = 56
\]
Note: Each committee is a subset of the 8 people — we ignore order, only membership matters.
Notes:
- Use this to formalize what students discovered in the activity: dividing by the number of equivalent orders.
- Emphasize the contrast with permutations : same domain, different notion of sameness.
- Optionally end with: “Next time we’ll see how these appear in binomial coefficients and counting problems.”
Reflection
Compare the models:
Outfits
(shoe, pant, shirt)
\(|S|\times|P|\times|H|\)
Seating
(seat 1, seat 2, seat 3, seat 4)
\(4\times 3\times 2\times 1\)
Circular Seating
(fix one person)
\((4 − 1)! = 6\)
Choosing Guests
{subset of guests}
\(\binom{4}{k}\)
All start by modeling the outcomes carefully before counting.
The model determines whether order matters.
Notes:
Pause for synthesis: have students summarize in their own words how the model affects the formula.
Reinforce the difference between permutations (ordered) and combinations (unordered) .
⏱️ Timing: 4–5 minutes for class synthesis.
Challenge: Putting It All Together
There are 8 people, and 4 seats at the round table.
Question: How many distinct arrangements are possible if rotations and reflections count as the same?
Communicate: Explain each step of your reasoning.
Generalize: What if there are \(n\) people and \(k\) seats?
💭 Think first. Then compare reasoning with a neighbor.
We’ll build the model together and find the count at the end.
Notes:
Encourage modeling before computation.
Ask: “How can we anchor the rotations and reflections?”
Extend gently to dihedral symmetry ideas: we’re dividing out both rotation and flip equivalences.
End with applause for reasoning, not the number.
⏱️ Timing: 6–8 minutes (think–pair–share + group wrap).
Summary
Permutation
Yes
Ordered arrangement
4! = 24
Combination
No
Unordered selection
\(\binom{4}{2} = 6\)
Punchline:
Counting always starts with modeling the outcomes .
Once we know what counts as “different,” the computation follows.
Notes:
End with reflection: “What do we gain by naming these ideas?”
Encourage them to see permutation and combination as families of counting models, not just formulas.
Optional: connect to data sampling — rows (ordered) vs. groups (unordered).
⏱️ Timing: 3–4 minutes as a closing summary.