Lemma 26.4 (McDiarmid): w.p. ≥ 1−δ, |f(X) − E f(X)| ≤ c√(ln(2/δ) m/2) for f with bounded differences c
ProvedUnderstandingML.mcdiarmid_inequality_piLemma 26.4 (McDiarmid's inequality). Let be a set and let be a function of variables such that, for some , for all and all ,
Let be independent random variables taking values in . Then for every , with probability at least ,
This is the concentration inequality used in Chapter 26 to turn the bound on the expected representativeness (Lemma 26.2) into the high-probability generalization bounds of Theorem 26.5: the representativeness and the empirical Rademacher complexity both change by at most when a single example is replaced.
Formalization Note Independence is modelled by the product measure of probability measures on a measurable space (Measure.pi μ), and the random vector is the identity on . The function is assumed measurable. The conclusion bounds the probability of the failure event by .
import Mathlib.Probability.Moments.SubGaussian import Mathlib.MeasureTheory.Constructions.Pi import Mathlib.MeasureTheory.Integral.Prod open MeasureTheory
namespace UnderstandingML
/-- **Lemma 26.4 (McDiarmid's inequality)** (p. 377). Let `V` be a set and `f : V^m → ℝ` a function
of `m` variables such that, for some `c`, changing any single coordinate changes `f` by at most
`c`. Let `X₁, …, X_m` be independent random variables with values in `V` (here: the coordinates
under a product of probability measures `μ₁ ⊗ ⋯ ⊗ μ_m`). Then, with probability at least `1 − δ`,
`|f(X₁, …, X_m) − E f(X₁, …, X_m)| ≤ c √(ln(2/δ) m / 2)`. `f` is measurable. -/
theorem mcdiarmid_inequality_pi {V : Type*} [MeasurableSpace V] (m : ℕ) (μ : Fin m → Measure V)
[∀ i, IsProbabilityMeasure (μ i)] (f : (Fin m → V) → ℝ) (hf : Measurable f) (c : ℝ)
(hc : ∀ (x : Fin m → V) (i : Fin m) (v : V), |f x - f (Function.update x i v)| ≤ c)
(δ : ℝ) (hδ : 0 < δ) (hδ1 : δ < 1) :
Measure.pi μ {x | c * Real.sqrt (Real.log (2 / δ) * m / 2) <
|f x - ∫ y, f y ∂(Measure.pi μ)|} ≤ ENNReal.ofReal δ := by sorry
end UnderstandingML