Fisher's exact test
TheoremSum of independent binomials#✓fully proved
MathlibExt.Probability.Statistics.ExactTests.measureReal_add_eq_binomial
If X ~ Bin(n₁, p) and Y ~ Bin(n₂, p) are independent,
then X + Y ~ Bin(n₁ + n₂, p): P(X + Y = t) = C(n₁ + n₂, t) p^t (1 - p)^(n₁ + n₂ - t).
theorem measureReal_add_eq_binomial (hXm : Measurable X) (hYm : Measurable Y)
(hX : HasLaw X Bin(n₁, p) μ) (hY : HasLaw Y Bin(n₂, p) μ) (hXY : IndepFun X Y μ) (t : ℕ) :
μ.real {ω | X ω + Y ω = t} = Bin(n₁ + n₂, p).real {t}
Used by 1
TheoremFisher's exact conditional law#✓fully proved
MathlibExt.Probability.Statistics.ExactTests.cond_measureReal_eq_hypergeometricReal
Let X ~ Bin(n₁, p) and Y ~ Bin(n₂, p) be independent
with a common p ∈ (0, 1). Given the margin X + Y = t with t ≤ n₁ + n₂, the cell X is
hypergeometric: P(X = k | X + Y = t) = C(n₁, k) C(n₂, t - k) / C(n₁ + n₂, t), whatever p.
theorem cond_measureReal_eq_hypergeometricReal (hp₀ : 0 < p) (hp₁ : p < 1)
(hXm : Measurable X) (hYm : Measurable Y) (hX : HasLaw X Bin(n₁, p) μ)
(hY : HasLaw Y Bin(n₂, p) μ) (hXY : IndepFun X Y μ) {t : ℕ} (ht : t ≤ n₁ + n₂) (k : ℕ) :
(μ[|{ω | X ω + Y ω = t}]).real {ω | X ω = k} = hypergeometricReal (n₁ + n₂) n₁ t k
noncomputable def hypergeometricReal (N K n k : ℕ) : ℝ :=
if k ≤ n then (K.choose k * (N - K).choose (n - k) : ℝ) / N.choose n else 0
MathlibExt/Probability/Distributions/Hypergeometric.lean:53
Sources
Sources
- Fisher (1934, §21.02; 1935); Lehmann–Romano (2005), §4.5.
Uses 3
Statement usesHypergeometric mass function
2 fully proved
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.