cs-113 — Dice Before Data
| Field | Value |
|---|---|
| id | cs-113 |
| difficulty | Beginner |
| topics | simulation, randomness |
| lecture | lecture-29 |
| estimated time | 5-minute attempt + 10-minute discussion |
| prerequisites | none |
| objective | state inputs, outputs, and assumptions, then solve a small instance by hand |
| solution | held by the instructor; discussed after the attempt |
Problem
Simulate 10,000 rolls of two dice; compare the sum distribution to theory. Building the generator and trusting the sample.
Your deliverable is the simulation result with trials and spread, the one-trial story, and the comparison with exact reasoning. If the problem is ambiguous anywhere, state the assumption you are making and carry on — a stated assumption is part of a good answer.
Examples
- Input: two dice, 10,000 rolls
- Output: sum 7 ~ 16.7% (6/36 exact); distribution matches theory within ~1%
Solve for the worked instance first. Then ask what would change if one number, name, or condition were replaced by something stranger.
What to notice
- One trial = roll two dice. The only skill is the loop and the comparison table.
- A simulation is only as good as the story of one trial.
- Error shrinks like 1/sqrt(trials) — quadruple the work, halve the error.
Discussion starter
After the solution is revealed, the class spends five minutes on this prompt: "How many trials would you demand before believing a 1-in-1000 event estimate?"
Constraints and assumptions
- Difficulty: Beginner (no prior experience assumed).
- Topics: simulation, randomness.
- Classroom-scale inputs unless the problem says otherwise.
- Time-box: about five minutes for a first attempt; partial answers with clear reasoning are worth more than silent struggling.
- Optional stretch (not required): describe an alternative approach and say when it beats the obvious one.
Hints and extension
- First nudge: identify the pattern the worked instance uses before computing anything.
- If stuck after three minutes, write the input/output line you expect and trace the smallest example by hand.
- After the reveal, attempt the extension below before the next lecture.
- Extension challenge: Halve and double the trial count; report how the estimate wobbles.