Geometric Distribution Simulator
Run the Geometric Distribution Simulator MicroSim Fullscreen
Edit this MicroSim in the p5.js Editor
About This MicroSim
The geometric distribution answers the question: "How many trials until the first success?" This simulator lets you run experiments and watch the empirical distribution converge to the theoretical geometric distribution.
Each experiment continues until a success occurs (shown as green "S"), counting all the failures (shown as auburn "F") along the way.
How to Use
- Adjust the probability slider to set P(success) for each trial
- Click "Run 1" to see a single experiment with its trial sequence
- Click "Run 10" or "Run 100" to accumulate data faster
- Watch the histogram build up and compare green bars (empirical) to orange markers (theoretical)
- Track the empirical mean and see it converge to 1/p
Key Concepts
The Geometric Distribution
If X = number of trials until first success, then:
- Fail (k-1) times: \((1-p)^{k-1}\)
- Then succeed on trial k: \(p\)
Expected Value (Mean)
The expected number of trials until first success is beautifully simple:
| P(success) | Expected Trials |
|---|---|
| 0.5 | 2 |
| 0.25 | 4 |
| 0.1 | 10 |
| 0.05 | 20 |
Geometric vs. Binomial
| Feature | Binomial | Geometric |
|---|---|---|
| Question | How many successes in n trials? | How many trials until first success? |
| Fixed? | n is fixed | n is random |
| Values | 0, 1, 2, ..., n | 1, 2, 3, ... (infinite) |
| Mean | np | 1/p |
Learning Objectives
After using this MicroSim, you'll be able to:
- Calculate geometric probabilities using the formula
- Understand why the mean is 1/p
- Compare empirical results to theoretical predictions
- Distinguish between binomial and geometric settings
- Observe the Law of Large Numbers in action
Lesson Plan
Introduction (3 minutes)
Ask: "If I'm searching for a four-leaf clover and there's a 1 in 10 chance under each clover, how many clovers should I expect to check?" (Answer: 10)
Guided Exploration (10 minutes)
- Start with p = 0.3: Run 1 experiment, observe the sequence
- Run 10 experiments: Start building the histogram
- Run 100 experiments: Watch the empirical distribution take shape
- Check the mean: It should be approaching 1/0.3 = 3.33
- Try p = 0.5: Mean should approach 2
Observations to Make
- The distribution is always right-skewed (tail stretches right)
- k = 1 always has the highest probability
- As p decreases, the distribution spreads out more
- With enough experiments, empirical matches theoretical
Discussion Questions
- Why is the geometric distribution always right-skewed?
- If p is very small (rare event), what happens to the expected waiting time?
- Why does the mean equal 1/p? (Think about it intuitively)
Sylvia Says
"When I'm searching for the perfect acorn, sometimes I find one under the first tree, sometimes it takes 10 tries. The geometric distribution captures that uncertainty perfectly. On average, if p = 0.2, I check 5 trees. Some days I'm lucky, some days... well, I keep searching!"
Embedding This MicroSim
1 | |
Technical Notes
- Built with p5.js 1.11.10
- Uses canvas-based controls
- Experiments run in batches for efficiency
- Shows last 30 trials in sequence display
- Trials > 20 are lumped into the "20+" category
- Drawing height: 400px, Control height: 100px
References
- Chapter 13: Random Variables
- Concepts: Geometric Setting, Geometric Distribution, Geometric Probability, Geometric Mean