The binomial assumes every trial has the same probability, which is only true with replacement. Net a fish and keep it, and the odds shift for the next draw. Counting tagged fish in a catch from a finite lake is the hypergeometric distribution, and it underpins one of ecology's cleverest tricks.
wildlife_capture_recapture.csv records 1,000 expeditions, each tagging K = 100 of N = 500 fish,
then catching n = 30 and counting the tagged_fish_count. We model the recaptures and then run the
model backward to estimate N.
Drawing Without Replacement
With 100 of 500 fish tagged, a fraction K/N = 0.2 of the lake carries a tag, so a catch of 30 should contain about n·K/N = 6 tagged fish. The observed mean is 5.91, and the hypergeometric PMF lands neatly on the data.
Because the lake is finite and caught fish are not returned before the next draw, each catch slightly changes the remaining proportion of tags, so this is hypergeometric, not binomial. The distinction is small here but exact.
Without vs With Replacement
Had the fish been tossed back (or the lake been effectively infinite), the count would be Binomial(30, 0.2). Both models share the mean of 6, but the hypergeometric is tighter: drawing without replacement carries a finite-population correction that shrinks the variance.
| Model | mean | variance |
|---|---|---|
| Hypergeometric (without replacement) | 6.00 | 4.52 |
| Binomial (with replacement) | 6.00 | 4.80 |
| correction factor (N−n)/(N−1) | 0.942 × 4.80 = 4.52 | |
The correction factor (N−n)/(N−1) = 0.94 is exactly the ratio of the two variances. When the sample is tiny relative to the population, the factor approaches 1 and the binomial becomes an excellent approximation, which is why the two distributions are so often used interchangeably.
Estimating the Uncountable
Here is the payoff. In a real survey N is unknown, that is the whole point. But if a fraction k/n of the catch is tagged and K fish are tagged in total, you can solve for the population: N̂ = K·n / k, the Lincoln-Petersen estimator.
Averaged across expeditions, the simple Lincoln-Petersen estimate overshoots (mean ≈ 609), because dividing by a small recapture count k inflates it, a genuine bias. The bias-corrected Chapman estimator, (K+1)(n+1)/(k+1) − 1, fixes this and recovers the true N ≈ 500 (mean ≈ 513). This is the magic of capture-recapture: it measures a whole no one could ever count, the method behind wildlife censuses, estimating undiscovered software bugs, and even counting hidden human populations.
Run the recapture analysis
The companion notebook fits the hypergeometric to the tagged counts, compares its variance to the binomial via the finite-population correction, and inverts the model with both the Lincoln-Petersen and the bias-corrected Chapman estimators to recover the unknown population, every number from code.
View opens the rendered notebook instantly (no setup). Open in Colab runs &
edits it live in your browser. To run locally, install numpy, pandas, scipy,
and matplotlib and launch jupyter notebook.
🎓 Key Takeaways
- ✓Sampling without replacement is hypergeometric, not binomial; mean = n·K/N = 6 tagged per catch.
- ✓The finite-population correction (N−n)/(N−1) = 0.94 shrinks the variance below the binomial's.
- ✓When n « N, the correction approaches 1 and the binomial is a fine approximation.
- ✓Lincoln-Petersen N̂ = Kn/k estimates the unknown population, but overshoots; the Chapman estimator is bias-corrected.
- ✓Run a distribution backward and a sample becomes a census, the engine of capture-recapture across many fields.
Quiz: Test Yourself
Eight quick questions on the hypergeometric case study. Answer them, hit Check Answers, and keep refining until you score 100%. Your progress is saved, so you can hop back to the chapter and return anytime.