Glivenko–Cantelli theorem: almost surely
OpenGlivenkoCantelli.glivenko_cantelliThis is the Glivenko–Cantelli theorem, often called the fundamental theorem of statistics: the empirical distribution function of an i.i.d. sample converges to the true distribution function uniformly over the whole real line, with probability one.
Let be independent real-valued random variables on a probability space , all with the same distribution, and let
be their common distribution function. For the empirical distribution function of the first observations is
the observed frequency of the values not exceeding . Then, for -almost every ,
No assumption is placed on : it may be any distribution function on , with or without atoms.
The theorem upgrades the pointwise almost-sure convergence for each fixed (an instance of the strong law of large numbers) to convergence that is uniform in . It is the prototype of a uniform law of large numbers and the starting point of empirical process theory, including the Dvoretzky–Kiefer–Wolfowitz inequality and Vapnik–Chervonenkis theory.
Formalization Note The observations are indexed from : X i is . Each X i is measurable, the family is mutually independent (iIndepFun X P), and every X i has the same law as X 0 (IdentDistrib (X i) (X 0) P P). The distribution function is Mathlib's cdf (P.map (X 0)), the distribution function of the law of , which equals . The empirical distribution function is the real number #((Finset.range n).filter (fun i => X i ω ≤ x)) / n. The supremum is the real ⨆ x : ℝ; since for all , this is the genuine supremum. For Lean's convention gives , which does not affect the limit.
import Mathlib open MeasureTheory ProbabilityTheory Filter Topology
namespace GlivenkoCantelli
/-- **The Glivenko–Cantelli theorem** (Durrett, *Probability: Theory and Examples*, 5th ed.,
Theorem 2.4.9; Billingsley, *Probability and Measure*, Theorem 20.6).
Let `X 0, X 1, X 2, …` be independent real random variables on a probability space `(Ω, P)`, all
with the same distribution, and let `F = cdf (P.map (X 0))` be their common distribution function,
`F x = P (X 0 ≤ x)`. The empirical distribution function of the first `n` observations is
`F_n(x) = #{i < n : X i ω ≤ x} / n` (observation `i` here is `X_{i+1}` in the textbooks).
Then, almost surely, `sup_x |F_n(x) - F(x)| → 0` as `n → ∞`.
For every `ω` and `n` the function `x ↦ |F_n(x) - F(x)|` takes values in `[0, 1]`, so the real
`⨆ x` below is the genuine supremum (no junk value is involved). At `n = 0` Lean reads
`F_0 = 0 / 0 = 0`, which does not affect the limit. -/
theorem glivenko_cantelli {Ω : Type*} [MeasurableSpace Ω] (P : Measure Ω)
[IsProbabilityMeasure P] (X : ℕ → Ω → ℝ) (hX : ∀ i, Measurable (X i))
(hindep : iIndepFun X P) (hident : ∀ i, IdentDistrib (X i) (X 0) P P) :
∀ᵐ ω ∂P, Tendsto
(fun n : ℕ => ⨆ x : ℝ,
|(((Finset.range n).filter (fun i => X i ω ≤ x)).card : ℝ) / n - cdf (P.map (X 0)) x|)
atTop (𝓝 0) := by sorry
end GlivenkoCantelli