Stat.Concentration.TailBounds
Scalar/bounded-difference tail inequalities: Hoeffding, Bernstein and its empirical (variance-adaptive) form, McDiarmid's bounded-difference inequality, the sub-exponential moment-generating-function machinery, finite ma
SubExponential 2 core · 7 supporting This file defines HasSubexponentialMGF, a (v, b) moment-generating-function condition for real random variables, and proves the basic calculus needed by Bernstein-style concentration: finiteness of the underlying measure ★ measure_ge_le
Sub-exponential moment bounds
This file defines HasSubexponentialMGF, a (v, b) moment-generating-function
condition for real random variables, and proves the basic calculus needed by
Bernstein-style concentration: finiteness of the underlying measure, closure
under negation, a.e. congruence, scaling, independent addition, the zero
variable, sums over independent families, and the Chernoff tail theorem
HasSubexponentialMGF.measure_ge_le.
A random variable X has a sub-exponential moment-generating function with parameters (v, b) with respect to μ if, for every t with b · |t| < 1, exp (t * X) is μ-integrable and the moment-generating function obeys mgf X μ t ≤ exp (v t² / 2).
Definition (Lean source)
Chernoff bound for the right tail of a sub-exponential random variable. If X has a sub-exponential moment-generating function with parameters (v, b) with respect to μ and ε is nonnegative, then the probability that X is at least ε is at most .
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
isFiniteMeasurelemma — A sub-exponential random variable lives on a finite measure (integrability of exp (0 · X) = 1).Proof (Lean source)
lemma isFiniteMeasure (hX : HasSubexponentialMGF X v b μ) : IsFiniteMeasure μ := by have h := hX.integrable_exp_mul 0 (by simp) simp only [zero_mul, Real.exp_zero] at h exact (integrable_const_iff.mp h).resolve_left one_ne_zero -
neglemma — Sub-exponentiality is preserved under negation (same parameters).hypotheseshX :HasSubexponentialMGF X v b μconclusionHasSubexponentialMGF (fun ω => -X ω) v b μ where integrable_exp_mul t htProof (Lean source)
lemma neg (hX : HasSubexponentialMGF X v b μ) : HasSubexponentialMGF (fun ω => -X ω) v b μ where integrable_exp_mul t ht := by have := hX.integrable_exp_mul (-t) (by rwa [abs_neg]) simpa [mul_comm, mul_neg, neg_mul] using this mgf_le t ht := by have hmt : (b : ℝ) * |(-t)| < 1 := by rwa [abs_neg] have h := hX.mgf_le (-t) hmt have hmgf : mgf (fun ω => -X ω) μ t = mgf X μ (-t) := by simp only [mgf, neg_mul, mul_neg] rw [hmgf] refine h.trans_eq ?_ congr 1; ring -
congrlemma — Sub-exponentiality transfers along an a.e.-equality.hypothesesconclusionHasSubexponentialMGF Y v b μ where integrable_exp_mul t htProof (Lean source)
lemma congr (hX : HasSubexponentialMGF X v b μ) {Y : Ω → ℝ} (hXY : X =ᵐ[μ] Y) : HasSubexponentialMGF Y v b μ where integrable_exp_mul t ht := by refine (integrable_congr ?_).mp (hX.integrable_exp_mul t ht) filter_upwards [hXY] with ω hω using by rw [hω] mgf_le t ht := by rw [mgf_congr (hXY.symm)] exact hX.mgf_le t ht -
const_mullemma — Sub-exponentiality is preserved under scaling: r • X has parameters (r² v, |r| b).Proof (Lean source)
lemma const_mul (hX : HasSubexponentialMGF X v b μ) (r : ℝ) : HasSubexponentialMGF (fun ω => r * X ω) (⟨r ^ 2, sq_nonneg r⟩ * v) (⟨|r|, abs_nonneg r⟩ * b) μ := by have hbcoe : ((⟨|r|, abs_nonneg r⟩ * b : ℝ≥0) : ℝ) = |r| * b := by rfl have hvcoe : ((⟨r ^ 2, sq_nonneg r⟩ * v : ℝ≥0) : ℝ) = r ^ 2 * v := by rfl have hbnd : ∀ t : ℝ, ((⟨|r|, abs_nonneg r⟩ * b : ℝ≥0) : ℝ) * |t| < 1 → (b : ℝ) * |r * t| < 1 := by intro t ht; rw [hbcoe] at ht; rw [abs_mul]; nlinarith [abs_nonneg t, abs_nonneg r, b.coe_nonneg] refine ⟨fun t ht => ?_, fun t ht => ?_⟩ · have := hX.integrable_exp_mul (r * t) (hbnd t ht) refine (integrable_congr ?_).mpr this filter_upwards with ω using by ring_nf · rw [mgf_const_mul] refine (hX.mgf_le (r * t) (hbnd t ht)).trans_eq ?_ rw [hvcoe]; congr 1; ring -
add_of_indepFunlemma — Independent sub-exponential variables add: X + Y has parameters (vX + vY, max bX bY).hypothesesY :Ω → ℝvX bX vY bY :ℝ≥0hX :HasSubexponentialMGF X vX bX μhY :HasSubexponentialMGF Y vY bY μhindep :IndepFun X Y μconclusionHasSubexponentialMGF (fun ω => X ω + Y ω) (vX + vY) (max bX bY) μProof (Lean source)
lemma add_of_indepFun {Y : Ω → ℝ} {vX bX vY bY : ℝ≥0} (hX : HasSubexponentialMGF X vX bX μ) (hY : HasSubexponentialMGF Y vY bY μ) (hindep : IndepFun X Y μ) : HasSubexponentialMGF (fun ω => X ω + Y ω) (vX + vY) (max bX bY) μ := by have hbX : ∀ t : ℝ, ((max bX bY : ℝ≥0) : ℝ) * |t| < 1 → (bX : ℝ) * |t| < 1 := by intro t ht refine lt_of_le_of_lt (by gcongr; exact_mod_cast le_max_left bX bY) ht have hbY : ∀ t : ℝ, ((max bX bY : ℝ≥0) : ℝ) * |t| < 1 → (bY : ℝ) * |t| < 1 := by intro t ht refine lt_of_le_of_lt (by gcongr; exact_mod_cast le_max_right bX bY) ht refine ⟨fun t ht => ?_, fun t ht => ?_⟩ · have hiX := hX.integrable_exp_mul t (hbX t ht) have hiY := hY.integrable_exp_mul t (hbY t ht) have hind : IndepFun (fun ω => exp (t * X ω)) (fun ω => exp (t * Y ω)) μ := hindep.comp (φ := fun x => exp (t * x)) (ψ := fun x => exp (t * x)) (by fun_prop) (by fun_prop) simp_rw [mul_add, Real.exp_add] exact hind.integrable_mul hiX hiY · have hiX := hX.integrable_exp_mul t (hbX t ht) have hiY := hY.integrable_exp_mul t (hbY t ht) have hmgf : mgf (fun ω => X ω + Y ω) μ t = mgf X μ t * mgf Y μ t := hindep.mgf_add hiX.aestronglyMeasurable hiY.aestronglyMeasurable rw [hmgf] calc mgf X μ t * mgf Y μ t ≤ exp (vX * t ^ 2 / 2) * exp (vY * t ^ 2 / 2) := by gcongr <;> first | exact mgf_nonneg | exact hX.mgf_le t (hbX t ht) | exact hY.mgf_le t (hbY t ht) _ = exp (((vX + vY : ℝ≥0) : ℝ) * t ^ 2 / 2) := by rw [← Real.exp_add]; congr 1; push_cast; ring -
zerolemma — The constant 0 is sub-exponential with parameters (0, b) (any b).Proof (Lean source)
lemma zero [IsProbabilityMeasure μ] : HasSubexponentialMGF (fun _ : Ω => (0 : ℝ)) 0 b μ := by refine ⟨fun t _ => ?_, fun t _ => ?_⟩ · simp · simp [mgf, mul_zero, Real.exp_zero] -
sum_range_of_iIndepFunlemma — A sum of n independent sub-exponential variables sharing common parameters (v, b) is sub-exponential with parameters (n • v, b) (the b-parameters coincide, so they do not grow).hypothesesZ :ℕ → Ω → ℝh_indep :iIndepFun Z μh_meas :∀ i, AEMeasurable (Z i) μv b :ℝ≥0n :ℕh :∀ i < n, HasSubexponentialMGF (Z i) v b μconclusionHasSubexponentialMGF (fun ω => ∑ i ∈ range n, Z i ω) (n • v) b μProof (Lean source)
lemma sum_range_of_iIndepFun {Z : ℕ → Ω → ℝ} (h_indep : iIndepFun Z μ) (h_meas : ∀ i, AEMeasurable (Z i) μ) {v b : ℝ≥0} {n : ℕ} (h : ∀ i < n, HasSubexponentialMGF (Z i) v b μ) : HasSubexponentialMGF (fun ω => ∑ i ∈ range n, Z i ω) (n • v) b μ := by haveI : IsProbabilityMeasure μ := h_indep.isProbabilityMeasure induction n with | zero => simpa using (zero : HasSubexponentialMGF (fun _ : Ω => (0 : ℝ)) 0 b μ) | succ n ih => have ihn := ih (fun i hi => h i (Nat.lt_succ_of_lt hi)) have hZn : HasSubexponentialMGF (Z n) v b μ := h n (Nat.lt_succ_self n) have hindZ : IndepFun (fun ω => ∑ i ∈ range n, Z i ω) (Z n) μ := by have h' := h_indep.indepFun_finset_sum_of_notMem₀ h_meas (Finset.notMem_range_self (n := n)) have heq : (fun ω => ∑ i ∈ range n, Z i ω) = ∑ j ∈ range n, Z j := by funext ω; rw [Finset.sum_apply] rwa [heq] have hsum := ihn.add_of_indepFun hZn hindZ have hfun : (fun ω => ∑ i ∈ range (n + 1), Z i ω) = fun ω => (∑ i ∈ range n, Z i ω) + Z n ω := by funext ω; rw [Finset.sum_range_succ] rw [hfun, show ((n + 1) • v) = n • v + v from succ_nsmul v n] convert hsum using 2 exact (max_self b).symm
Bernstein 2 core · 3 supporting This file proves Bernstein-style concentration bounds for bounded i.i.d. ★ bernstein_ge★ bernstein_abs_ge
Bernstein inequalities
This file proves Bernstein-style concentration bounds for bounded i.i.d.
sample means by packaging bounded centered variables as sub-exponential
random variables. The main bridge is bounded_hasSubexponentialMGF, derived
from the elementary MGF estimate bounded_mgf_le_exp_sq; the exported tail
theorems are bernstein_ge and bernstein_abs_ge.
The constants intentionally come from the constant-v sub-exponential route:
the variance proxy is 2 * σ ^ 2 and the final exponent is
-n * ε ^ 2 / (2 * (2 * σ ^ 2 + c * ε)).
One-sided Bernstein inequality for the sample mean of a bounded statistic. Given an i.i.d. sample S and a statistic f that is measurable and integrable under the population law P, suppose c is nonnegative, f stays within c of its population mean m = ∫ f ∂P, P-almost everywhere, and the population variance of f is at most σ². Then for any sample size n ≥ 1 and any threshold ε ≥ 0, the probability that the sample mean of f over n draws exceeds m by at least ε is at most .
Formal statement
Proof (Lean source)
Two-sided Bernstein inequality for the sample mean of a bounded statistic. Given an i.i.d. sample S and a statistic f that is measurable and integrable under the population law P, suppose c is nonnegative, f stays within c of its population mean m = ∫ f ∂P, P-almost everywhere, and the population variance of f is at most σ². Then for any sample size n ≥ 1 and any threshold ε ≥ 0, the probability that the sample mean of f over n draws deviates from m by at least ε in absolute value is at most .
Formal statement
Proof (Lean source)
3 supporting declarations (lemmas, instances)
-
exp_le_one_add_add_sqlemma — Pointwise elementary bound exp u ≤ 1 + u + u² valid for |u| ≤ 1.Proof (Lean source)
lemma exp_le_one_add_add_sq {u : ℝ} (hu : |u| ≤ 1) : exp u ≤ 1 + u + u ^ 2 := by have h := Real.norm_exp_sub_one_sub_id_le (x := u) (by rwa [Real.norm_eq_abs]) rw [Real.norm_eq_abs, Real.norm_eq_abs, sq_abs] at h have := (le_abs_self (exp u - 1 - u)).trans h linarith -
bounded_mgf_le_exp_sqlemma — MGF bound for a bounded mean-zero random variable on the validity interval. For a mean-zero X with |X| ≤ c μ-a.e. and second moment E[X²] ≤ σ², the moment-generating function obeys mgf X μ t ≤ exp(σ² t²) whenever c |t| ≤ 1.hypothesesc σ :ℝhc :0 ≤ chmeas :AEMeasurable X μhmean :μ[X] = 0hbound :∀ᵐ ω ∂μ, |X ω| ≤ chvar :μ[fun ω => X ω ^ 2] ≤ σ ^ 2t :ℝht :c * |t| ≤ 1Proof (Lean source)
lemma bounded_mgf_le_exp_sq [IsProbabilityMeasure μ] {c σ : ℝ} (hc : 0 ≤ c) (hmeas : AEMeasurable X μ) (hmean : μ[X] = 0) (hbound : ∀ᵐ ω ∂μ, |X ω| ≤ c) (hvar : μ[fun ω => X ω ^ 2] ≤ σ ^ 2) {t : ℝ} (ht : c * |t| ≤ 1) : mgf X μ t ≤ exp (σ ^ 2 * t ^ 2) := by -- integrability of the summands have hint_exp : Integrable (fun ω => exp (t * X ω)) μ := by refine Integrable.mono' (integrable_const (exp (|t| * c))) ((Real.measurable_exp.comp_aemeasurable (hmeas.const_mul t)).aestronglyMeasurable) ?_ filter_upwards [hbound] with ω hω rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] exact Real.exp_le_exp.mpr <| (le_abs_self _).trans <| by rw [abs_mul]; gcongr have hint_X : Integrable X μ := Integrable.mono' (integrable_const c) hmeas.aestronglyMeasurable (by filter_upwards [hbound] with ω hω; rwa [Real.norm_eq_abs]) have hint_Xsq : Integrable (fun ω => X ω ^ 2) μ := Integrable.mono' (integrable_const (c ^ 2)) (hmeas.pow_const 2).aestronglyMeasurable (by filter_upwards [hbound] with ω hω rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] nlinarith [hω, abs_nonneg (X ω), sq_abs (X ω)]) -- pointwise bound `exp (t X) ≤ 1 + t X + t² X²` have hpt : ∀ᵐ ω ∂μ, exp (t * X ω) ≤ 1 + t * X ω + t ^ 2 * X ω ^ 2 := by filter_upwards [hbound] with ω hω have hu : |t * X ω| ≤ 1 := by rw [abs_mul] calc |t| * |X ω| ≤ |t| * c := by gcongr _ = c * |t| := by ring _ ≤ 1 := ht calc exp (t * X ω) ≤ 1 + t * X ω + (t * X ω) ^ 2 := exp_le_one_add_add_sq hu _ = 1 + t * X ω + t ^ 2 * X ω ^ 2 := by ring -- integrate have hrhs_int : Integrable (fun ω => 1 + t * X ω + t ^ 2 * X ω ^ 2) μ := ((integrable_const (1 : ℝ)).add (hint_X.const_mul t)).add (hint_Xsq.const_mul (t ^ 2)) have hval : (∫ ω, (1 + t * X ω + t ^ 2 * X ω ^ 2) ∂μ) = 1 + t ^ 2 * (μ[fun ω => X ω ^ 2]) := by have h1a : Integrable (fun _ : Ω => (1 : ℝ)) μ := integrable_const 1 have h1b : Integrable (fun ω => t * X ω) μ := hint_X.const_mul t have h1 : Integrable (fun ω => (1 : ℝ) + t * X ω) μ := h1a.add h1b have hg : Integrable (fun ω => t ^ 2 * X ω ^ 2) μ := hint_Xsq.const_mul (t ^ 2) rw [integral_add h1 hg, integral_add h1a h1b, integral_const_mul, integral_const_mul, integral_const, hmean] simp calc mgf X μ t = ∫ ω, exp (t * X ω) ∂μ := by rw [mgf] _ ≤ ∫ ω, (1 + t * X ω + t ^ 2 * X ω ^ 2) ∂μ := integral_mono_ae hint_exp hrhs_int hpt _ = 1 + t ^ 2 * (μ[fun ω => X ω ^ 2]) := hval _ ≤ 1 + t ^ 2 * σ ^ 2 := by nlinarith [hvar, sq_nonneg t] _ ≤ exp (σ ^ 2 * t ^ 2) := by have := Real.add_one_le_exp (σ ^ 2 * t ^ 2); nlinarith [this] -
bounded_hasSubexponentialMGFlemma — A bounded mean-zero random variable is sub-exponential with parameters (2σ², c). The MGF branch is bounded_mgf_le_exp_sq (note 2σ² · t²/2 = σ²t²), valid on c|t| < 1.hypothesesc σ :ℝhc :0 ≤ chmeas :AEMeasurable X μhmean :μ[X] = 0hbound :∀ᵐ ω ∂μ, |X ω| ≤ chvar :μ[fun ω => X ω ^ 2] ≤ σ ^ 2conclusionHasSubexponentialMGF X ⟨2 * σ ^ 2, by positivity⟩ ⟨c, hc⟩ μProof (Lean source)
lemma bounded_hasSubexponentialMGF [IsProbabilityMeasure μ] {c σ : ℝ} (hc : 0 ≤ c) (hmeas : AEMeasurable X μ) (hmean : μ[X] = 0) (hbound : ∀ᵐ ω ∂μ, |X ω| ≤ c) (hvar : μ[fun ω => X ω ^ 2] ≤ σ ^ 2) : HasSubexponentialMGF X ⟨2 * σ ^ 2, by positivity⟩ ⟨c, hc⟩ μ := by refine ⟨fun t ht => ?_, fun t ht => ?_⟩ · -- integrability of `exp (t X)`: bounded above by the constant `exp (|t| c)` refine Integrable.mono' (integrable_const (exp (|t| * c))) ((Real.measurable_exp.comp_aemeasurable (hmeas.const_mul t)).aestronglyMeasurable) ?_ filter_upwards [hbound] with ω hω rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] exact Real.exp_le_exp.mpr <| (le_abs_self _).trans <| by rw [abs_mul]; gcongr · -- mgf bound: `2σ² · t²/2 = σ²t²` replace ht : c * |t| < 1 := ht show mgf X μ t ≤ exp (2 * σ ^ 2 * t ^ 2 / 2) calc mgf X μ t ≤ exp (σ ^ 2 * t ^ 2) := bounded_mgf_le_exp_sq hc hmeas hmean hbound hvar (le_of_lt ht) _ = exp (2 * σ ^ 2 * t ^ 2 / 2) := by rw [show 2 * σ ^ 2 * t ^ 2 / 2 = σ ^ 2 * t ^ 2 from by ring]
BinomialCount 3 core · 10 supporting This file develops the Chernoff chain for the sum of the first m observations of a measurable [0,1]-valued statistic along an IIDSample. ★ bernoulliCount_upper_tail★ bernoulliCount_lower_tail
Multiplicative tails for bounded i.i.d. counts
This file develops the Chernoff chain for the sum of the first m observations
of a measurable [0,1]-valued statistic along an IIDSample. The chain is
exposed one step at a time so that downstream work can enter at whatever level
it needs and can pick its own exponential tilt:
* exp_mul_le_secant — the chord bound for exp on the unit interval;
* mgf_le_of_mem_Icc_zero_one — the one-observation moment generating
function bound mgf ≤ exp (mean * (exp s - 1));
* boundedCount_mgf_le_integral / boundedCount_mgf_le — the same bound for
the m-fold count, in terms of the population integral respectively an
upper bound p for it;
* boundedCount_upper_tail_of_tilt / boundedCount_lower_tail_of_tilt — the
resulting one-sided tails at an arbitrary tilt s.
bernoulliCount_upper_tail and bernoulliCount_lower_tail are the historical
{0,1}-valued specializations at the tilt s = ± log 2; mgf_eq_of_mem_zero_one
records that for a {0,1}-valued statistic the one-observation bound is an
equality. bernoulliCount_measurable, bernoulliCount_nonneg and
bernoulliCount_le record the basic properties of the count itself.
The number of the first m observations on which f is one.
Definition (Lean source)
Upper multiplicative tail for the count of an i.i.d. [0,1]-valued statistic. Let S be an i.i.d. sample and let f be a measurable statistic taking values in the unit interval. If the population mean of f is at most p and m times p is less than half the threshold a, then the probability that the sum of f over the first m draws exceeds a is at most .
Formal statement
Proof (Lean source)
Lower multiplicative tail for the count of an i.i.d. [0,1]-valued statistic. Let S be an i.i.d. sample and let f be a measurable statistic taking values in the unit interval. If p is nonnegative, the population mean of f is at least p, and twice the threshold a is less than m times p, then the probability that the sum of f over the first m draws is at most a is at most .
Formal statement
Proof (Lean source)
10 supporting declarations (lemmas, instances)
-
bernoulliCount_measurablelemmahypothesesconclusionMeasurable (bernoulliCount S f m)Proof (Lean source)
lemma bernoulliCount_measurable (S : IIDSample Ω 𝒳 μ P) {f : 𝒳 → ℝ} (hf : Measurable f) (m : ℕ) : Measurable (bernoulliCount S f m) := by unfold bernoulliCount exact Finset.measurable_fun_sum _ fun i _ ↦ hf.comp (S.meas i) -
bernoulliCount_nonneglemma — A count built from a nonnegative statistic is nonnegative.hypothesesconclusion0 ≤ bernoulliCount S f m ωProof (Lean source)
lemma bernoulliCount_nonneg (S : IIDSample Ω 𝒳 μ P) {f : 𝒳 → ℝ} (h0 : ∀ x, 0 ≤ f x) (m : ℕ) (ω : Ω) : 0 ≤ bernoulliCount S f m ω := by simp only [bernoulliCount] exact sum_nonneg fun i _ ↦ h0 _ -
bernoulliCount_lelemma — A count of m observations of a statistic bounded by one never exceeds m.hypothesesconclusionbernoulliCount S f m ω ≤ mProof (Lean source)
lemma bernoulliCount_le (S : IIDSample Ω 𝒳 μ P) {f : 𝒳 → ℝ} (h1 : ∀ x, f x ≤ 1) (m : ℕ) (ω : Ω) : bernoulliCount S f m ω ≤ m := by simp only [bernoulliCount] calc (∑ i ∈ range m, f (S.Z i ω)) ≤ ∑ _i ∈ range m, (1 : ℝ) := by gcongr with i hi exact h1 _ _ = m := by simp -
exp_mul_le_secantlemma — On the unit interval the exponential function stays below the chord joining its values at the two endpoints: for a number x between zero and one and any tilt s, exp (s * x) is at most 1 + x * (exp s - 1). This is the convexity step behind every Bernoulli-type Chernoff bound.Proof (Lean source)
lemma exp_mul_le_secant {x s : ℝ} (hx : x ∈ Icc (0 : ℝ) 1) : exp (s * x) ≤ 1 + x * (exp s - 1) := by calc exp (s * x) = exp (x * s + (1 - x) * 0) := by ring_nf _ ≤ x * exp s + (1 - x) * exp 0 := convexOn_exp.2 (Set.mem_univ _) (Set.mem_univ _) hx.1 (by linarith [hx.2]) (by ring) _ = 1 + x * (exp s - 1) := by rw [exp_zero]; ring -
mgf_le_of_mem_Icc_zero_onelemma — The moment generating function of a measurable statistic taking values in the unit interval is at most exp (mean * (exp s - 1)), where mean is the statistic's population mean. This holds at every tilt s, positive or negative.hypothesesconclusionmgf f P s ≤ exp ((∫ x, f x ∂P) * (exp s - 1))Proof (Lean source)
lemma mgf_le_of_mem_Icc_zero_one [IsProbabilityMeasure P] {f : 𝒳 → ℝ} (hf : AEMeasurable f P) (h01 : ∀ᵐ x ∂P, f x ∈ Icc (0 : ℝ) 1) (s : ℝ) : mgf f P s ≤ exp ((∫ x, f x ∂P) * (exp s - 1)) := by have hfint : Integrable f P := by refine Integrable.of_bound hf.aestronglyMeasurable 1 (h01.mono fun x hx ↦ ?_) rw [Real.norm_eq_abs] exact abs_le.2 ⟨by linarith [hx.1], hx.2⟩ have hexpint : Integrable (fun x ↦ exp (s * f x)) P := by refine Integrable.of_bound ((hf.const_mul s).exp.aestronglyMeasurable) (exp |s|) (h01.mono fun x hx ↦ ?_) rw [Real.norm_eq_abs, abs_of_pos (exp_pos _)] apply exp_le_exp.mpr calc s * f x ≤ |s * f x| := le_abs_self _ _ = |s| * |f x| := abs_mul _ _ _ ≤ |s| * 1 := by gcongr exact abs_le.2 ⟨by linarith [hx.1], hx.2⟩ _ = |s| := mul_one _ rw [mgf] calc (∫ x, exp (s * f x) ∂P) ≤ ∫ x, (1 + f x * (exp s - 1)) ∂P := integral_mono_ae hexpint ((integrable_const 1).add (hfint.mul_const _)) (h01.mono fun x hx ↦ exp_mul_le_secant hx) _ = 1 + (∫ x, f x ∂P) * (exp s - 1) := by rw [integral_add (integrable_const 1) (hfint.mul_const _), integral_const, integral_mul_const] simp _ ≤ exp ((∫ x, f x ∂P) * (exp s - 1)) := by simpa [add_comm] using Real.add_one_le_exp ((∫ x, f x ∂P) * (exp s - 1)) -
mgf_eq_of_mem_zero_onelemma — For a statistic that only takes the values zero and one, the moment generating function is exactly 1 + p * (exp s - 1), where p is the probability that the statistic equals one.hypothesesconclusionmgf f P s = 1 + p * (exp s - 1)Proof (Lean source)
lemma mgf_eq_of_mem_zero_one [IsProbabilityMeasure P] {f : 𝒳 → ℝ} (hf : AEMeasurable f P) (h01 : ∀ᵐ x ∂P, f x = 0 ∨ f x = 1) (p s : ℝ) (hmean : ∫ x, f x ∂P = p) : mgf f P s = 1 + p * (exp s - 1) := by have hf_int : Integrable f P := by refine Integrable.of_bound hf.aestronglyMeasurable 1 (h01.mono fun x hx ↦ ?_) rcases hx with hx | hx <;> simp [hx] rw [mgf] calc (∫ x, exp (s * f x) ∂P) = ∫ x, (1 + f x * (exp s - 1)) ∂P := by refine integral_congr_ae (h01.mono fun x hx ↦ ?_) rcases hx with hx | hx · simp [hx] · simp [hx] _ = 1 + p * (exp s - 1) := by rw [integral_add (integrable_const 1) (hf_int.mul_const _), integral_const, integral_mul_const, hmean] simp -
boundedCount_mgf_le_integraltheorem — The moment generating function of the count of the first m observations of a measurable [0,1]-valued statistic is at most exp (m * mean * (exp s - 1)), where mean is the statistic's population mean. This is the i.i.d. tensorisation of the one-observation bound and holds at every tilt s.hypothesesconclusionmgf (bernoulliCount S f m) μ s ≤ exp ((m : ℝ) * ((∫ x, f x ∂P) * (exp s - 1)))Proof (Lean source)
theorem boundedCount_mgf_le_integral (S : IIDSample Ω 𝒳 μ P) {f : 𝒳 → ℝ} (hf : Measurable f) (h01 : ∀ x, f x ∈ Icc (0 : ℝ) 1) (m : ℕ) (s : ℝ) : mgf (bernoulliCount S f m) μ s ≤ exp ((m : ℝ) * ((∫ x, f x ∂P) * (exp s - 1))) := by haveI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure haveI : IsProbabilityMeasure P := by rw [← S.map_eq 0] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable let X : ℕ → Ω → ℝ := fun i ↦ f ∘ S.Z i have hX_meas : ∀ i, Measurable (X i) := fun i ↦ hf.comp (S.meas i) have hX_indep : iIndepFun X μ := S.indep.comp (fun _ ↦ f) (fun _ ↦ hf) have hmgf_one : ∀ i, mgf (X i) μ s ≤ exp ((∫ x, f x ∂P) * (exp s - 1)) := by intro i rw [← mgf_map (S.meas i).aemeasurable (by fun_prop), S.map_eq] exact mgf_le_of_mem_Icc_zero_one hf.aemeasurable (ae_of_all _ h01) s have hsum : bernoulliCount S f m = ∑ i ∈ range m, X i := by ext ω simp [bernoulliCount, X, Function.comp_apply] rw [hsum, hX_indep.mgf_sum hX_meas] calc (∏ i ∈ range m, mgf (X i) μ s) ≤ ∏ _i ∈ range m, exp ((∫ x, f x ∂P) * (exp s - 1)) := Finset.prod_le_prod (fun i _ ↦ mgf_nonneg) (fun i _ ↦ hmgf_one i) _ = exp ((m : ℝ) * ((∫ x, f x ∂P) * (exp s - 1))) := by rw [Finset.prod_const, Finset.card_range, ← Real.exp_nat_mul] -
boundedCount_mgf_letheorem — If the population mean of a measurable [0,1]-valued statistic is at most p, then at every nonnegative tilt s the moment generating function of the count of the first m observations is at most exp (m * p * (exp s - 1)).hypothesesS :IIDSample Ω 𝒳 μ Pf :𝒳 → ℝhf :h01 :∀ x, f x ∈ Icc (0 : ℝ) 1p :ℝhmean :∫ x, f x ∂P ≤ pm :ℕs :ℝhs :0 ≤ sconclusionmgf (bernoulliCount S f m) μ s ≤ exp ((m : ℝ) * (p * (exp s - 1)))Proof (Lean source)
theorem boundedCount_mgf_le (S : IIDSample Ω 𝒳 μ P) {f : 𝒳 → ℝ} (hf : Measurable f) (h01 : ∀ x, f x ∈ Icc (0 : ℝ) 1) {p : ℝ} (hmean : ∫ x, f x ∂P ≤ p) (m : ℕ) (s : ℝ) (hs : 0 ≤ s) : mgf (bernoulliCount S f m) μ s ≤ exp ((m : ℝ) * (p * (exp s - 1))) := by haveI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure haveI : IsProbabilityMeasure P := by rw [← S.map_eq 0] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable refine (boundedCount_mgf_le_integral S hf h01 m s).trans (exp_le_exp.mpr ?_) have hexp : 0 ≤ exp s - 1 := by have := Real.one_le_exp hs linarith exact mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hmean hexp) (Nat.cast_nonneg m) -
boundedCount_upper_tail_of_tilttheorem — Chernoff upper tail at an arbitrary nonnegative tilt. For a measurable [0,1]-valued statistic with population mean at most p, the probability that the count of the first m observations exceeds a level a is at most exp (-s * a + m * p * (exp s - 1)), for every nonnegative s. Optimising over s recovers the usual multiplicative Chernoff bounds.hypothesesS :IIDSample Ω 𝒳 μ Pf :𝒳 → ℝhf :h01 :∀ x, f x ∈ Icc (0 : ℝ) 1p a :ℝhmean :∫ x, f x ∂P ≤ pm :ℕs :ℝhs :0 ≤ sconclusionμ.real {ω | a < bernoulliCount S f m ω} ≤ exp (-s * a + (m : ℝ) * (p * (exp s - 1)))Proof (Lean source)
theorem boundedCount_upper_tail_of_tilt (S : IIDSample Ω 𝒳 μ P) {f : 𝒳 → ℝ} (hf : Measurable f) (h01 : ∀ x, f x ∈ Icc (0 : ℝ) 1) {p a : ℝ} (hmean : ∫ x, f x ∂P ≤ p) (m : ℕ) (s : ℝ) (hs : 0 ≤ s) : μ.real {ω | a < bernoulliCount S f m ω} ≤ exp (-s * a + (m : ℝ) * (p * (exp s - 1))) := by haveI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure haveI : IsProbabilityMeasure P := by rw [← S.map_eq 0] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable have hint : Integrable (fun ω ↦ exp (s * bernoulliCount S f m ω)) μ := by refine Integrable.of_bound ((bernoulliCount_measurable S hf m).const_mul _ |>.exp.aestronglyMeasurable) (exp (s * m)) (ae_of_all _ fun ω ↦ ?_) rw [Real.norm_eq_abs, abs_of_pos (exp_pos _)] exact exp_le_exp.mpr (mul_le_mul_of_nonneg_left (bernoulliCount_le S (fun x ↦ (h01 x).2) m ω) hs) have hmgf := boundedCount_mgf_le S hf h01 hmean m s hs calc μ.real {ω | a < bernoulliCount S f m ω} ≤ μ.real {ω | a ≤ bernoulliCount S f m ω} := measureReal_mono (by intro ω hω change a < bernoulliCount S f m ω at hω exact hω.le) _ ≤ exp (-s * a) * mgf (bernoulliCount S f m) μ s := measure_ge_le_exp_mul_mgf a hs hint _ ≤ exp (-s * a) * exp ((m : ℝ) * (p * (exp s - 1))) := mul_le_mul_of_nonneg_left hmgf (exp_pos _).le _ = exp (-s * a + (m : ℝ) * (p * (exp s - 1))) := (exp_add _ _).symm -
boundedCount_lower_tail_of_tilttheorem — Chernoff lower tail at an arbitrary nonpositive tilt. For a measurable [0,1]-valued statistic with population mean at least p, the probability that the count of the first m observations falls at or below a level a is at most exp (-s * a + m * p * (exp s - 1)), for every nonpositive s. Optimising over s recovers the usual multiplicative Chernoff bounds.hypothesesS :IIDSample Ω 𝒳 μ Pf :𝒳 → ℝhf :h01 :∀ x, f x ∈ Icc (0 : ℝ) 1p a :ℝhmean :p ≤ ∫ x, f x ∂Pm :ℕs :ℝhs :s ≤ 0conclusionμ.real {ω | bernoulliCount S f m ω ≤ a} ≤ exp (-s * a + (m : ℝ) * (p * (exp s - 1)))Proof (Lean source)
theorem boundedCount_lower_tail_of_tilt (S : IIDSample Ω 𝒳 μ P) {f : 𝒳 → ℝ} (hf : Measurable f) (h01 : ∀ x, f x ∈ Icc (0 : ℝ) 1) {p a : ℝ} (hmean : p ≤ ∫ x, f x ∂P) (m : ℕ) (s : ℝ) (hs : s ≤ 0) : μ.real {ω | bernoulliCount S f m ω ≤ a} ≤ exp (-s * a + (m : ℝ) * (p * (exp s - 1))) := by haveI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure haveI : IsProbabilityMeasure P := by rw [← S.map_eq 0] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable have hint : Integrable (fun ω ↦ exp (s * bernoulliCount S f m ω)) μ := by refine Integrable.of_bound ((bernoulliCount_measurable S hf m).const_mul _ |>.exp.aestronglyMeasurable) 1 (ae_of_all _ fun ω ↦ ?_) rw [Real.norm_eq_abs, abs_of_pos (exp_pos _)] calc exp (s * bernoulliCount S f m ω) ≤ exp 0 := exp_le_exp.mpr (mul_nonpos_of_nonpos_of_nonneg hs (bernoulliCount_nonneg S (fun x ↦ (h01 x).1) m ω)) _ = 1 := exp_zero have hbase := boundedCount_mgf_le_integral S hf h01 m s have hcoef : exp s - 1 ≤ 0 := by have := Real.exp_le_one_iff.mpr hs linarith have hmgf : mgf (bernoulliCount S f m) μ s ≤ exp ((m : ℝ) * (p * (exp s - 1))) := hbase.trans (exp_le_exp.mpr (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonpos_right hmean hcoef) (Nat.cast_nonneg m))) calc μ.real {ω | bernoulliCount S f m ω ≤ a} ≤ exp (-s * a) * mgf (bernoulliCount S f m) μ s := measure_le_le_exp_mul_mgf a hs hint _ ≤ exp (-s * a) * exp ((m : ℝ) * (p * (exp s - 1))) := mul_le_mul_of_nonneg_left hmgf (exp_pos _).le _ = exp (-s * a + (m : ℝ) * (p * (exp s - 1))) := (exp_add _ _).symm
EmpiricalBernstein 5 core · 5 supporting This file develops the sample-variance layer needed for data-driven Bernstein intervals. ★ empirical_variance_concentration★ empiricalBernsteinCIHalfWidth★ empirical_bernstein_ci_miss
Empirical Bernstein confidence intervals
This file develops the sample-variance layer needed for data-driven Bernstein
intervals. It defines IIDSample.sampleVariance and proves its nonnegativity,
measurability, and computational identity; defines the deterministic slack
empiricalVarianceSlack; proves empirical_variance_concentration, a
high-probability upper bound on the population variance by observed sample
variance plus slack; and proves empirical_bernstein_ci_miss, an empirical
Bernstein miss-probability theorem whose half-width is
empiricalBernsteinCIHalfWidth.
The sample variance of f over the first n observations, normalised by 1/n: V̂ₙ(ω) = (1/n) ∑_{i<n} (f (Zᵢ ω) − X̄ₙ(ω))², where X̄ₙ = S.sampleMean f n is the sample mean. (This is the biased estimator; the unbiased one would divide by n − 1.)
The deterministic slack added to the observed sample variance to upper-bound the population variance with probability ≥ 1 − δ. With M := max |a| |b| and d := √(log(4/δ)/(2n)) the (level δ/2) Hoeffding deviation factor, it is M²·d + 2 M (b − a)·d. The first term controls the second-moment deviation (f² on [0, M²]), the second the squared-mean deviation (|X̄ₙ² − m²| ≤ 2M·|X̄ₙ − m|).
Data-driven population-variance bound. Let S be an i.i.d. sample and let f be a measurable statistic taking values in an interval [a, b] with a < b P-almost everywhere. For any confidence level δ in (0, 1] and any positive sample size n, the event that the observed sample variance plus the deterministic slack empiricalVarianceSlack a b n δ falls short of the population variance σ² = ∫ (f − ∫ f)² ∂P has probability at most δ; equivalently, with probability at least 1 − δ the population variance is bounded by the observed sample variance plus that slack.
Formal statement
Proof (Lean source)
The data-driven Bernstein half-width: the Bernstein half-width with the oracle standard deviation σ replaced by the observed upper bound √(V̂ₙ(ω) + τ), where τ = empiricalVarianceSlack a b n δ. This is a function of ω (it depends on the sample through V̂ₙ).
Definition (Lean source)
Data-driven (empirical) Bernstein confidence interval, miss-probability form. Let S be an i.i.d. sample and let f be a measurable statistic taking values in an interval [a,b] with a < b, with population mean m = ∫ f ∂P. Suppose c is a nonnegative bound with f deviating from m by at most c, P-almost everywhere, the population variance σ² = ∫ (f − m)² ∂P is strictly positive, the sample size n is positive, and the confidence level δ lies in (0, 1]. Then the population mean m falls outside the random, data-driven interval [X̄ₙ − ŵ(ω), X̄ₙ + ŵ(ω)] — whose half-width ŵ(ω) = empiricalBernsteinCIHalfWidth S f a b c n δ ω is computed from the observed sample variance via √(V̂ₙ(ω) + τ) — with probability at most 2δ.
Formal statement
Proof (Lean source)
5 supporting declarations (lemmas, instances)
-
sampleVariance_nonnegtheorem — The sample variance is nonnegative: it is 1/n times a sum of squares.Proof (Lean source)
theorem IIDSample.sampleVariance_nonneg (S : IIDSample Ω X μ P) (f : X → ℝ) (n : ℕ) (ω : Ω) : 0 ≤ S.sampleVariance f n ω := by unfold IIDSample.sampleVariance apply mul_nonneg · positivity · apply sum_nonneg intro i _ positivity -
measurable_sampleVariancetheorem — The sample variance is a measurable function of ω.hypothesesconclusionMeasurable (S.sampleVariance f n)Proof (Lean source)
theorem IIDSample.measurable_sampleVariance (S : IIDSample Ω X μ P) (hf : Measurable f) (n : ℕ) : Measurable (S.sampleVariance f n) := by unfold IIDSample.sampleVariance apply Measurable.const_mul apply Finset.measurable_sum intro i _ have hmean : Measurable (S.sampleMean f n) := by unfold IIDSample.sampleMean apply Measurable.const_mul apply Finset.measurable_sum intro j _ exact hf.comp (S.meas j) exact ((hf.comp (S.meas i)).sub hmean).pow_const 2 -
sampleVariance_eqtheorem — The classical computational form of the sample variance: empirical second moment minus the square of the empirical mean, V̂ₙ(ω) = (1/n) ∑_{i<n} f(Zᵢ ω)² − X̄ₙ(ω)².hypothesesconclusionS.sampleVariance f n ω= (n : ℝ)⁻¹ * ∑ i ∈ range n, (f (S.Z i ω)) ^ 2 - (S.sampleMean f n ω) ^ 2Proof (Lean source)
theorem IIDSample.sampleVariance_eq (S : IIDSample Ω X μ P) (f : X → ℝ) (n : ℕ) (ω : Ω) : S.sampleVariance f n ω = (n : ℝ)⁻¹ * ∑ i ∈ range n, (f (S.Z i ω)) ^ 2 - (S.sampleMean f n ω) ^ 2 := by rcases Nat.eq_zero_or_pos n with hn | hn · subst hn simp [IIDSample.sampleVariance, IIDSample.sampleMean] have hn' : (n : ℝ) ≠ 0 := by positivity set m := S.sampleMean f n ω with hm have hsum_mean : ∑ i ∈ range n, f (S.Z i ω) = (n : ℝ) * m := by rw [hm, IIDSample.sampleMean] field_simp have hexpand : ∀ i ∈ range n, (f (S.Z i ω) - m) ^ 2 = (f (S.Z i ω)) ^ 2 - 2 * m * f (S.Z i ω) + m ^ 2 := by intro i _; ring rw [IIDSample.sampleVariance, ← hm, Finset.sum_congr rfl hexpand] rw [Finset.sum_add_distrib, Finset.sum_sub_distrib, Finset.sum_const, Finset.card_range, nsmul_eq_mul, ← Finset.mul_sum, hsum_mean] field_simp ring -
hoeffdingCIHalfWidth_halflemma — Halving the confidence level in a Hoeffding half-width replaces its logarithmic factor with log(4/δ), so the resulting half-width can be used in split-confidence and union-bound calculations.hypothesesa b :ℝn :ℕδ :ℝconclusionProof (Lean source)
lemma hoeffdingCIHalfWidth_half (a b : ℝ) (n : ℕ) {δ : ℝ} : hoeffdingCIHalfWidth a b n (δ / 2) = (b - a) * sqrt (log (4 / δ) / (2 * n)) := by rw [hoeffdingCIHalfWidth] congr 3 rw [div_div_eq_mul_div] ring_nf -
bernsteinCIHalfWidth_mono_sigmalemma — The Bernstein confidence-interval half-width does not decrease when its standard-deviation input is increased, so an upper variance bound gives a conservative interval.hypothesesc :ℝn :ℕδ σ σ' :ℝhσσ' :σ ≤ σ'conclusionbernsteinCIHalfWidth c σ n δ ≤ bernsteinCIHalfWidth c σ' n δProof (Lean source)
lemma bernsteinCIHalfWidth_mono_sigma {c : ℝ} {n : ℕ} {δ σ σ' : ℝ} (hσσ' : σ ≤ σ') : bernsteinCIHalfWidth c σ n δ ≤ bernsteinCIHalfWidth c σ' n δ := by unfold bernsteinCIHalfWidth gcongr
Hoeffding 2 core · 4 supporting This file specializes Mathlib's sub-Gaussian tail machinery to the IIDSample model. ★ hoeffding_ge★ hoeffding_abs_ge
Hoeffding inequalities
This file specializes Mathlib's sub-Gaussian tail machinery to the
IIDSample model. It records sample-point law and expectation identities
(IIDSample.map_eq from Causalean.Stat.Sample, IIDSample.integral_comp_eq),
independence of composed sample statistics (IIDSample.iIndepFun_comp), the
centered sample-mean/sum event identity sampleMean_sub_ge_setEq, and the
one- and two-sided sample-mean bounds hoeffding_ge and hoeffding_abs_ge.
One-sided Hoeffding inequality for the sample mean of a bounded statistic. Let S be an i.i.d. sample and let f be a measurable statistic taking values in an interval [a, b] with a < b P-almost everywhere. Then for any sample size n ≥ 1 and any threshold ε ≥ 0, the probability that the sample mean of f over n draws exceeds its population mean by at least ε is at most .
Formal statement
Proof (Lean source)
Two-sided Hoeffding inequality for the sample mean of a bounded statistic. Let S be an i.i.d. sample and let f be a measurable statistic taking values in an interval [a, b] with a < b P-almost everywhere. Then for any sample size n ≥ 1 and any threshold ε ≥ 0, the probability that the sample mean of f over n draws deviates from its population mean by at least ε in absolute value is at most .
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
integral_comp_eqlemma — The population mean of a statistic equals its sample-point expectation: ∫ ω, f (S.Z i ω) ∂μ = ∫ x, f x ∂P.hypothesesconclusion∫ ω, f (S.Z i ω) ∂μ = ∫ x, f x ∂PProof (Lean source)
lemma IIDSample.integral_comp_eq (S : IIDSample Ω X μ P) {f : X → ℝ} (hf : AEMeasurable f P) (i : ℕ) : ∫ ω, f (S.Z i ω) ∂μ = ∫ x, f x ∂P := by have hf' : AEStronglyMeasurable f (μ.map (S.Z i)) := by rw [S.map_eq i] exact hf.aestronglyMeasurable calc ∫ ω, f (S.Z i ω) ∂μ = ∫ x, f x ∂μ.map (S.Z i) := (integral_map (S.meas i).aemeasurable hf').symm _ = ∫ x, f x ∂P := by rw [S.map_eq i] -
iIndepFun_complemma — Independence of the composed family fun i ↦ f ∘ S.Z i.hypothesesconclusioniIndepFun (fun i ω => f (S.Z i ω)) μProof (Lean source)
lemma IIDSample.iIndepFun_comp (S : IIDSample Ω X μ P) {f : X → ℝ} (hf : Measurable f) : iIndepFun (fun i ω => f (S.Z i ω)) μ := S.indep.comp (fun _ => f) (fun _ => hf) -
sampleMean_sub_ge_setEqlemma — For n > 0, the centered sample-mean tail event coincides with the centered-sum tail event: ε ≤ X̄ₙ − m ⟺ n ε ≤ ∑_{i<n} (f (Z i) − m). Reused by both the Hoeffding and Bernstein tail bounds.hypothesesconclusion{ω | ε ≤ S.sampleMean f n ω - m}= {ω | (n : ℝ) * ε ≤ ∑ i ∈ range n, (f (S.Z i ω) - m)}Proof (Lean source)
lemma sampleMean_sub_ge_setEq (S : IIDSample Ω X μ P) (f : X → ℝ) (m : ℝ) {n : ℕ} (hn : 0 < n) (ε : ℝ) : {ω | ε ≤ S.sampleMean f n ω - m} = {ω | (n : ℝ) * ε ≤ ∑ i ∈ range n, (f (S.Z i ω) - m)} := by have hnR : (0 : ℝ) < n := by exact_mod_cast hn ext ω simp only [Set.mem_setOf_eq, IIDSample.sampleMean, Finset.sum_sub_distrib, Finset.sum_const, Finset.card_range, nsmul_eq_mul] constructor · intro h have := mul_le_mul_of_nonneg_left h (le_of_lt hnR) rw [mul_sub, ← mul_assoc, mul_inv_cancel₀ (ne_of_gt hnR), one_mul] at this exact this · intro h have := mul_le_mul_of_nonneg_left h (le_of_lt (inv_pos.mpr hnR)) rw [mul_sub, ← mul_assoc, ← mul_assoc, inv_mul_cancel₀ (ne_of_gt hnR), one_mul, one_mul] at this exact this -
measureReal_abs_dev_le_two_sidedlemma — Generic two-sided assembly: the two-sided deviation event {ε ≤ |T − m|} is covered by the two one-sided events, so its measure is at most the sum of their one-sided bounds. Reused by the Hoeffding and Bernstein two-sided tail bounds.hypothesesΩ :T :Ω → ℝm Bup Blow ε :ℝhup :μ.real {ω | ε ≤ T ω - m} ≤ Buphlow :μ.real {ω | ε ≤ -T ω + m} ≤ Blowconclusionμ.real {ω | ε ≤ |T ω - m|} ≤ Bup + BlowProof (Lean source)
lemma measureReal_abs_dev_le_two_sided {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsFiniteMeasure μ] (T : Ω → ℝ) (m Bup Blow ε : ℝ) (hup : μ.real {ω | ε ≤ T ω - m} ≤ Bup) (hlow : μ.real {ω | ε ≤ -T ω + m} ≤ Blow) : μ.real {ω | ε ≤ |T ω - m|} ≤ Bup + Blow := by have hunion : {ω | ε ≤ |T ω - m|} ⊆ {ω | ε ≤ T ω - m} ∪ {ω | ε ≤ -T ω + m} := by intro ω hω simp only [Set.mem_setOf_eq] at hω rcases le_abs.mp hω with h | h · exact inl h · exact inr (by simp only [Set.mem_setOf_eq]; linarith) calc μ.real {ω | ε ≤ |T ω - m|} ≤ μ.real ({ω | ε ≤ T ω - m} ∪ {ω | ε ≤ -T ω + m}) := measureReal_mono hunion _ ≤ μ.real {ω | ε ≤ T ω - m} + μ.real {ω | ε ≤ -T ω + m} := measureReal_union_le _ _ _ ≤ Bup + Blow := add_le_add hup hlow
Massart 6 core · 6 supporting Proves the finite-class Massart maximal inequality used by Dudley entropy chaining and localized Rademacher-complexity bounds. ★ massart_lemma_pmf
Proves the finite-class Massart maximal inequality used by Dudley entropy chaining and localized Rademacher-complexity bounds.
The file supplies the sign-vector measure bridge (measurablespace_eq,
measure_eq), the finite-class notation used to match the maximal-inequality
API (MassartNotation.Y, MassartNotation.X, MassartNotation.r), the
finite restriction F_on, and the exported bound massart_lemma_pmf.
Declarations live in Causalean.Stat.Concentration; the proof follows the
FoML development with only namespace and Mathlib API adjustments.
A Rademacher increment is the signed, sample-scaled value of one function at one sample coordinate.
Definition (Lean source)
The aggregated Rademacher variable for one class index is the sum of its coordinate increments.
Definition (Lean source)
The finite-class coordinate envelope is the sample-scaled supremum absolute value over a finite index set.
The pointwise coordinate radius is the sample-scaled absolute value for one index and one sample coordinate.
Restricting a function class to a finite index set yields the corresponding subtype-indexed class.
Massart's finite-class lemma. Given a nonempty finite subset f of the index set selecting finitely many functions from the class, the empirical Rademacher complexity (without absolute value) of that finite subclass, evaluated at the sample S of size m, is at most the largest per-function coordinate -radius over j ∈ f, times .
Formal statement
Proof (Lean source)
6 supporting declarations (lemmas, instances)
-
instNonemptySubtypeIntMemFinsetInsertNegOfNatSingleton_causaleaninstance — The two-point sign set is nonempty.instance : Nonempty ({-1, 1} : Finset ℤ) := by use -1 simp -
instMeasurableSingletonClassSigns_causaleaninstance — The finite sign-vector space has measurable singletons under the product measurable structure.instance : @MeasurableSingletonClass (Signs m) pi := by classical refine @MeasurableSingletonClass.mk (Signs m) pi ?_ intro x let f : Fin m → Set (Signs m) := fun i : Fin m ↦ (Function.eval i)⁻¹' {x i} have : ∀ i : Fin m, @MeasurableSet (Signs m) pi (f i) := by intro i dsimp [f] apply MeasurableSet.preimage · exact measurableSet_singleton (x i) · exact measurable_pi_apply i convert MeasurableSet.iInter this ext y constructor · intro eq simp only [Set.mem_singleton_iff] at eq rw [eq] exact Set.mem_iInter.mpr (congrFun rfl) · intro h simp only [Set.mem_singleton_iff] dsimp [Signs] ext i have hi : y i = x i := Set.mem_iInter.mp h i exact congrArg val hi -
measurablespace_eqlemma — The sign-vector measurable space agrees with the product measurable space.conclusioninstMeasurableSpaceSigns m = pi -
measure_eqlemma — The Rademacher sign-vector law agrees with the product of uniform two-point coordinate laws.conclusion(signVecPMF m).toMeasure ≍ Measure.pi fun (_ : Fin m) ↦ (uniformOfFintype ({-1, 1} : Finset ℤ)).toMeasureProof (Lean source)
lemma measure_eq : (signVecPMF m).toMeasure ≍ Measure.pi fun (_ : Fin m) ↦ (uniformOfFintype ({-1, 1} : Finset ℤ)).toMeasure := by classical rw [measurablespace_eq] -- After `measurablespace_eq` both sides carry the product σ-algebra, so the two -- measure types are definitionally equal and the `HEq` reduces to an `Eq`. refine heq_of_eq ?_ · apply symm apply Measure.pi_eq intro s hs -- `Signs m` is a semireducible `def`, so `dsimp` cannot unfold it together with -- its `Fintype` instance; state the unfolded goal instead. show (uniformOfFintype (Fin m → ({-1, 1} : Finset ℤ))).toMeasure (Set.univ.pi s) = ∏ i : Fin m, (uniformOfFintype ({-1, 1} : Finset ℤ)).toMeasure (s i) rw [PMF.toMeasure_uniformOfFintype_apply (Set.univ.pi s) (MeasurableSet.univ_pi hs)] have : (card (Set.univ.pi s) : ENNReal) / (card (Fin m → ({-1, 1} : Finset ℤ)) : ENNReal) = ∏ i : Fin m, (card (s i) : ENNReal) / (2 : ENNReal) := by have Ps_eq: {f : Fin m → ({-1, 1} : Finset ℤ) // ∀ i, f i ∈ (s i)} ≃ ∀ (i : Fin m), {fi // fi ∈ (s i)} := by apply Equiv.subtypePiEquivPi have : ((Set.univ.pi s) : Type) = {f : Fin m → ({-1, 1} : Finset ℤ) // ∀ i, f i ∈ (s i)} := by congr exact Set.Subset.antisymm (fun ⦃a⦄ a i ↦ a i trivial) fun ⦃a⦄ a i a_1 ↦ a i rw [←this] at Ps_eq rw [Fintype.card_congr Ps_eq, Fintype.card_pi, Fintype.card_pi] have : ∏ i : Fin m, (card ↑(s i) : ENNReal) / 2 = ∏ i : Fin m, ↑(card ↑(s i) : ENNReal) * 2⁻¹ := by congr rw [this] rw [Finset.prod_mul_distrib] simp only [Int.reduceNeg, Nat.cast_prod, Finset.mem_insert, mem_singleton, Fintype.card_coe, reduceCtorEq, not_false_eq_true, Finset.card_insert_of_notMem, Finset.card_singleton, Nat.reduceAdd, Finset.prod_const, Finset.card_univ, Fintype.card_fin, Nat.cast_pow, Nat.cast_ofNat] rw [div_eq_mul_inv] congr exact ENNReal.inv_pow rw [this] congr ext i rw [PMF.toMeasure_uniformOfFintype_apply (s i) (hs i)] simp -
xy_identitylemma — The aggregate Rademacher variable is exactly the sum of its coordinate increments.conclusion∀ j,(MassartNotation.X (F:=F) (S:=S) (m:=m) (ι:=ι) j = ∑ i : Fin m, MassartNotation.Y (F:=F) (S:=S) (m:=m) (ι:=ι) i j)Proof (Lean source)
lemma MassartNotation.xy_identity : ∀ j, (MassartNotation.X (F:=F) (S:=S) (m:=m) (ι:=ι) j = ∑ i : Fin m, MassartNotation.Y (F:=F) (S:=S) (m:=m) (ι:=ι) i j) := by intro j -- Now show function equality pointwise in `σ`. funext σ -- Expand definitions; the RHS reduces to the sum over `univ` via `sum_image`. simp [MassartNotation.X, MassartNotation.Y] -
sign_mean_zerotheorem — A single Rademacher-signed sample value has mean zero.hypothesesconclusion∫ (ω : Signs m), ↑↑(ω a) * f (S a) ∂(signVecPMF m).toMeasure = 0Proof (Lean source)
theorem massart_lemma_pmf.sign_mean_zero {Z : Type v} {m : ℕ} (f : Z → ℝ) (S : Fin m → Z) (a : Fin m) : ∫ (ω : Signs m), ↑↑(ω a) * f (S a) ∂(signVecPMF m).toMeasure = 0 := by rw [PMF.integral_eq_tsum] · dsimp [signVecPMF, uniformOfFintype] simp only [Finset.mem_univ, ↓reduceIte, Signs.card, Nat.cast_pow, Nat.cast_ofNat, ENNReal.toReal_inv, ENNReal.toReal_pow, ENNReal.toReal_ofNat, Int.reduceNeg] rw [tsum_mul_left] suffices ∑' (a_1 : Signs m), (↑↑(a_1 a) * f (S a)) = 0 from by exact mul_eq_zero_of_right (2 ^ m)⁻¹ this rw [tsum_mul_right] simp only [Int.reduceNeg, tsum_fintype, mul_eq_zero] left apply sign_sum_eq_zero · exact Integrable.of_finite
MaximalInequality 3 core · 0 supporting This file proves finite-union maximal inequalities for families of sub-exponential random variables. ★ measure_abs_ge_le★ measure_exists_abs_ge_le★ measure_sup'_ge_le
Finite Maximal Inequalities
This file proves finite-union maximal inequalities for families of
sub-exponential random variables. The theorem
HasSubexponentialMGF.measure_abs_ge_le gives the two-sided tail bound for one
variable, measure_exists_abs_ge_le applies a finite union bound to an indexed
family, and measure_sup'_ge_le states the same estimate for a finite pointwise
maximum.
Two-sided Chernoff bound. If the random variable X has a sub-exponential moment-generating function with parameters (v, b) with respect to μ and ε is nonnegative, then the probability that |X| is at least ε is at most .
Formal statement
Proof (Lean source)
Maximal inequality (existential form). If every member Y i, i ∈ t, of a finite family indexed by t has a sub-exponential moment-generating function with common parameters (v, b) with respect to μ and ε is nonnegative, then the probability that |Y i| ≥ ε for at least one i ∈ t is at most the union bound card t · 2 exp(−ε² / (2 (v + b ε))).
Formal statement
Proof (Lean source)
Maximal inequality (sup' form). If t is a nonempty finite index set, every member Y i, i ∈ t, has a sub-exponential moment-generating function with common parameters (v, b) with respect to μ, and ε is nonnegative, then the probability that the pointwise maximum of |Y i| over i ∈ t is at least ε is at most the union bound card t · 2 exp(−ε² / (2 (v + b ε))).