The hypergeometric distribution #
Draw n of N objects without replacement, K of them marked. The number of marked objects
among those drawn is hypergeometric: exactly k of them turn up in
K.choose k * (N - K).choose (n - k) of the N.choose n draws. This file defines the
distribution on Fin (N + 1) as a kernel from the number of marked objects to the number drawn.
Main definitions #
ProbabilityTheory.hypergeometricCount: the number of draws withkmarked objects.ProbabilityTheory.hypergeometric: the kernel from the number of marked objects to the number of marked objects drawn.
Main results #
ProbabilityTheory.hypergeometric_real_singleton: the mass function, by Vandermonde's identity.ProbabilityTheory.hypergeometric_self: drawing every object is the identity kernel.ProbabilityTheory.posterior_hypergeometric_self: after drawing every object the posterior is the point mass at the number observed.
[UPSTREAM] candidate for Mathlib/Probability/Distributions/.
The number of ways to draw n of N objects, K of them marked, so that exactly k marked
objects are drawn.
Equations
- ProbabilityTheory.hypergeometricCount N K n k = if k ≤ n then K.choose k * (N - K).choose (n - k) else 0
Instances For
Drawing nothing is possible whatever the number of marked objects.
Drawing every object yields exactly the marked ones.
When every object is marked, every object drawn is.
The draws are counted by the number of marked objects in them, by Vandermonde's identity.
The hypergeometric kernel sends the number of marked objects among N to the law of the
number of marked objects among n drawn without replacement.
Equations
- ProbabilityTheory.hypergeometric N n = ProbabilityTheory.Kernel.ofWeights fun (K k : Fin (N + 1)) => ↑(ProbabilityTheory.hypergeometricCount N (↑K) n ↑k)
Instances For
Drawing every object reveals the number of marked ones.
When every object is marked, every object drawn is.
A number of marked draws is possible exactly when some draw has it.
The hypergeometric mass function.
After drawing every object, the posterior over the number of marked ones is the point mass at the number observed.