Stat.Concentration.Conditional­Bernstein

This module provides finite-family Bernstein bounds for outcome-bin counts conditional on an IID design vector.

Basic 8 core · 8 supporting The design partition is represented by a key map with measurable fibres. ★ jointCount_sub_conditionalMean

Finite design-cell and outcome-bin histogram statistics

The design partition is represented by a key map with measurable fibres. Outcome bins are an arbitrary finite measurable family: disjointness is unnecessary for concentration. Counts are natural numbers; conditional means and deviations are real numbers. All statistics include the empty sample and empty cells, with no division by cell counts.

def cellIndicator reviewed
Causalean.Stat.Concentration.ConditionalBernstein

The cell indicator of the cell selected by a key map and a cell label at a design point is the real number one when the key of the point equals the label, and zero otherwise.

Definition (Lean source)
D :
Type u_1
shared
C :
Type u_3
shared
key :
D → C
c :
C
d :
D
cellIndicator key c d :
ℝ
by classical exact if key d = c then 1 else 0
Causalean.Stat.Concentration.ConditionalBernstein.cellIndicator · Causalean/Stat/Concentration/ConditionalBernstein/Basic.lean:24
def binIndicator reviewed
Causalean.Stat.Concentration.ConditionalBernstein

The real bin indicator for an outcome set at an outcome is the real number one when the outcome lies in the set, and zero otherwise.

Definition (Lean source)
Y :
Type u_2
shared
bin :
Set Y
y :
Y
binIndicator bin y :
ℝ
bin.indicator (fun _ => 1) y
Causalean.Stat.Concentration.ConditionalBernstein.binIndicator · Causalean/Stat/Concentration/ConditionalBernstein/Basic.lean:31
def cellCount reviewed
Causalean.Stat.Concentration.ConditionalBernstein

The cell count counts coordinates of a design vector in the cell specified by the key.

Definition (Lean source)
D :
Type u_1
shared
C :
Type u_3
shared
n :
ℕ
shared
key :
D → C
c :
C
x :
Fin n → D
cellCount key c x :
ℕ
by classical exact ∑ i, if key (x i) = c then 1 else 0
Causalean.Stat.Concentration.ConditionalBernstein.cellCount · Causalean/Stat/Concentration/ConditionalBernstein/Basic.lean:36
def jointCount reviewed
Causalean.Stat.Concentration.ConditionalBernstein

The joint count is the number of sample coordinates whose entry of the design vector lies in the design cell given by the key map and cell label and whose entry of the outcome vector lies in the bin.

Definition (Lean source)
D :
Type u_1
shared
Y :
Type u_2
shared
C :
Type u_3
shared
n :
ℕ
shared
key :
D → C
bin :
Set Y
c :
C
x :
Fin n → D
y :
Fin n → Y
jointCount key bin c x y :
ℕ
by classical exact ∑ i, if key (x i) = c ∧ y i ∈ bin then 1 else 0
Causalean.Stat.Concentration.ConditionalBernstein.jointCount · Causalean/Stat/Concentration/ConditionalBernstein/Basic.lean:42
def binProbability reviewed
Causalean.Stat.Concentration.ConditionalBernstein

The bin probability is the real probability of an outcome bin under the conditional outcome kernel at a design point.

Definition (Lean source)
D :
Type u_1
shared
Y :
Type u_2
shared
K :
Kernel D Y
bin :
Set Y
d :
D
binProbability K bin d :
ℝ
(K d).real bin
Causalean.Stat.Concentration.ConditionalBernstein.binProbability · Causalean/Stat/Concentration/ConditionalBernstein/Basic.lean:52
def conditionalMean reviewed
Causalean.Stat.Concentration.ConditionalBernstein

The conditional joint-count mean sums the kernel bin probabilities over coordinates of the design vector in the chosen cell.

Definition (Lean source)
D :
Type u_1
shared
Y :
Type u_2
shared
C :
Type u_3
shared
n :
ℕ
shared
key :
D → C
K :
Kernel D Y
bin :
Set Y
c :
C
x :
Fin n → D
conditionalMean key K bin c x :
ℝ
∑ i, cellIndicator key c (x i) * binProbability K bin (x i)
Causalean.Stat.Concentration.ConditionalBernstein.conditionalMean · Causalean/Stat/Concentration/ConditionalBernstein/Basic.lean:57
def centeredSummand reviewed
Causalean.Stat.Concentration.ConditionalBernstein

The centered count summand at a coordinate of the design and outcome vectors is the indicator that the design entry lies in the selected design cell, multiplied by the indicator that the outcome entry lies in the bin minus the kernel probability of the bin at that design entry.

Definition (Lean source)
D :
Type u_1
shared
Y :
Type u_2
shared
C :
Type u_3
shared
n :
ℕ
shared
key :
D → C
K :
Kernel D Y
bin :
Set Y
c :
C
x :
Fin n → D
i :
Fin n
y :
Fin n → Y
centeredSummand key K bin c x i y :
ℝ
cellIndicator key c (x i) * (binIndicator bin (y i) - binProbability K bin (x i))
Causalean.Stat.Concentration.ConditionalBernstein.centeredSummand · Causalean/Stat/Concentration/ConditionalBernstein/Basic.lean:63
theorem jointCount_sub_conditionalMean reviewed
Causalean.Stat.Concentration.ConditionalBernstein

For any key map, outcome kernel, bin, cell label, design vector and outcome vector, the joint count minus the conditional joint-count mean equals the sum over sample coordinates of the centered count summands.

Formal statement
D :
Type u_1
shared
Y :
Type u_2
shared
C :
Type u_3
shared
n :
ℕ
shared
key :
D → C
K :
Kernel D Y
bin :
Set Y
c :
C
x :
Fin n → D
y :
Fin n → Y
(jointCount key bin c x y : ℝ) - conditionalMean key K bin c x
= ∑ i, centeredSummand key K bin c x i y
Proof (Lean source)
theorem jointCount_sub_conditionalMean (key : D → C) (K : Kernel D Y) (bin : Set Y) (c : C) (x : Fin n → D) (y : Fin n → Y) : (jointCount key bin c x y : ℝ) - conditionalMean key K bin c x = ∑ i, centeredSummand key K bin c x i y := by classical simp only [jointCount, Nat.cast_sum, conditionalMean, centeredSummand, mul_sub, Finset.sum_sub_distrib] congr 1 apply Finset.sum_congr rfl intro i _ by_cases hc : key (x i) = c <;> by_cases hy : y i ∈ bin <;> simp [cellIndicator, binIndicator, hc, hy]
Causalean.Stat.Concentration.ConditionalBernstein.jointCount_sub_conditionalMean · Causalean/Stat/Concentration/ConditionalBernstein/Basic.lean:141 · uses centeredSummand , conditionalMean , jointCount
8 supporting declarations (lemmas, instances)
Total­Variance 2 core · 2 supporting The existing bernstein_sum_ge uses a common variance proxy for all coordinates. ★ bernstein_sum_totalVariance_abs_gt

Bernstein tails with a total second-moment budget

The existing bernstein_sum_ge uses a common variance proxy for all coordinates. Here the budget is the sum of the individual second moments, so inactive histogram coordinates contribute zero instead of inflating the budget to the full sample size.

Reference: Boucheron, Lugosi, and Bousquet, Concentration Inequalities, Theorem 3 (pp. 218–219), https://web.majunjielab.cn/usr/uploads/2024/07/1972749276.pdf. The fetched authors' notes give the denominator 2 * (totalVariance + t / 3). We use the convenient, slightly larger inverted radius sqrt (2 * v * u) + u.

def bernsteinRadius reviewed
Causalean.Stat.Concentration.ConditionalBernstein

The Bernstein radius for a total variance budget v and an exponential-tail parameter u is √(2 v u) + u.

Definition (Lean source)
v u :
ℝ
bernsteinRadius v u :
ℝ
sqrt (2 * v * u) + u
Causalean.Stat.Concentration.ConditionalBernstein.bernsteinRadius · Causalean/Stat/Concentration/ConditionalBernstein/TotalVariance.lean:23
theorem bernstein_sum_totalVariance_abs_gt reviewed
Causalean.Stat.Concentration.ConditionalBernstein

Independent measurable centered summands, integrable with integrable squares, bounded in absolute value by one, and having total second moment at most a nonnegative budget v, satisfy, at a nonnegative tail parameter u, the two-sided Bernstein bound: the probability that the absolute value of their sum strictly exceeds √(2 v u) + u is at most 2 exp(−u).

Formal statement
Ω :
n :
ℕ
Fin n → Ω → ℝ
v u :
ℝ
hv :
0 ≤ v
hu :
0 ≤ u
hindep :
iIndepFun X μ
hmeas :
∀ i, Measurable (X i)
hint :
∀ i, Integrable (X i) μ
hsqint :
∀ i, Integrable (fun ω => X i ω ^ 2) μ
hmean :
∀ i, ∫ ω, X i ω ∂μ = 0
habs :
∀ i, ∀ᵐ ω ∂μ, |X i ω| ≤ 1
hsecond :
(∑ i, ∫ ω, X i ω ^ 2 ∂μ) ≤ v
μ.real {ω | bernsteinRadius v u < |∑ i, X i ω|} ≤ 2 * exp (-u)
Proof (Lean source)
theorem bernstein_sum_totalVariance_abs_gt {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ] {n : ℕ} {X : Fin n → Ω → ℝ} {v u : ℝ} (hv : 0 ≤ v) (hu : 0 ≤ u) (hindep : iIndepFun X μ) (hmeas : ∀ i, Measurable (X i)) (hint : ∀ i, Integrable (X i) μ) (hsqint : ∀ i, Integrable (fun ω => X i ω ^ 2) μ) (hmean : ∀ i, ∫ ω, X i ω ∂μ = 0) (habs : ∀ i, ∀ᵐ ω ∂μ, |X i ω| ≤ 1) (hsecond : (∑ i, ∫ ω, X i ω ^ 2 ∂μ) ≤ v) : μ.real {ω | bernsteinRadius v u < |∑ i, X i ω|} ≤ 2 * exp (-u) := by classical by_cases hn : n = 0 · subst n have hempty : {ω | bernsteinRadius v u < |∑ i : Fin 0, X i ω|} = ∅ := by ext ω simp [not_lt.mpr (bernsteinRadius_nonneg v hu)] rw [hempty] simp only [measureReal_empty] positivity by_cases hu0 : u = 0 · subst u have hprob : μ.real {ω | bernsteinRadius v 0 < |∑ i, X i ω|} ≤ 1 := by calc _ ≤ μ.real univ := measureReal_mono (Set.subset_univ _) _ = 1 := probReal_univ simp only [neg_zero, Real.exp_zero, mul_one] linarith by_cases hv0 : v = 0 · subst v have hnonneg (i : Fin n) : 0 ≤ ∫ ω, X i ω ^ 2 ∂μ := integral_nonneg (fun ω => sq_nonneg (X i ω)) have hzero (i : Fin n) : ∫ ω, X i ω ^ 2 ∂μ = 0 := by have hle := Finset.single_le_sum (fun j _ => hnonneg j) (Finset.mem_univ i) exact le_antisymm (hle.trans hsecond) (hnonneg i) have hXzero (i : Fin n) : ∀ᵐ ω ∂μ, X i ω = 0 := by have hsqzero := (integral_eq_zero_iff_of_nonneg (fun ω => sq_nonneg (X i ω)) (hsqint i)).mp (hzero i) filter_upwards [hsqzero] with ω hω change X i ω ^ 2 = 0 at hω nlinarith have hall : ∀ᵐ ω ∂μ, ∀ i, X i ω = 0 := (ae_all_iff).mpr hXzero have hnull : μ {ω | bernsteinRadius 0 u < |∑ i, X i ω|} = 0 := by have hae : ∀ᵐ ω ∂μ, ¬bernsteinRadius 0 u < |∑ i, X i ω| := by filter_upwards [hall] with ω hω simp [hω, not_lt.mpr (bernsteinRadius_nonneg 0 hu)] simpa only [not_not] using ae_iff.mp hae rw [(measureReal_eq_zero_iff).mpr hnull] positivity have hvpos : 0 < v := lt_of_le_of_ne hv (Ne.symm hv0) have hrnonneg : 0 ≤ bernsteinRadius v u := bernsteinRadius_nonneg v hu have hden : 0 < 2 * (v + bernsteinRadius v u / 3) := by positivity have hradius : 2 * u * (v + bernsteinRadius v u / 3) ≤ bernsteinRadius v u ^ 2 := by have hsqrt := Real.sq_sqrt (show 0 ≤ 2 * v * u by positivity) have hsu : 0 ≤ sqrt (2 * v * u) * u := mul_nonneg (Real.sqrt_nonneg _) hu dsimp [bernsteinRadius] nlinarith [sq_nonneg u] have hexp : exp (-bernsteinRadius v u ^ 2 / (2 * (v + bernsteinRadius v u / 3))) ≤ exp (-u) := by apply Real.exp_le_exp.mpr rw [div_le_iff₀ hden] nlinarith [hradius] have hupper (i : Fin n) : ∀ᵐ ω ∂μ, X i ω ≤ 1 := (habs i).mono (fun ω hω => (le_abs_self _).trans hω) have hlower (i : Fin n) : ∀ᵐ ω ∂μ, -X i ω ≤ 1 := (habs i).mono (fun ω hω => (neg_le_abs _).trans hω) have hpos := (bernstein_sum_totalVariance_ge hvpos hrnonneg hindep hmeas hint hsqint hmean hupper hsecond).trans hexp have hnegindep : iIndepFun (fun i ω => -X i ω) μ := hindep.comp (fun _ x => -x) (fun _ => measurable_neg) have hnegsq (i : Fin n) : Integrable (fun ω => (-X i ω) ^ 2) μ := by simpa only [neg_sq] using hsqint i have hnegmean (i : Fin n) : ∫ ω, -X i ω ∂μ = 0 := by rw [integral_neg, hmean i, neg_zero] have hnegsecond : (∑ i, ∫ ω, (-X i ω) ^ 2 ∂μ) ≤ v := by simpa only [neg_sq] using hsecond have hneg := (bernstein_sum_totalVariance_ge hvpos hrnonneg hnegindep (fun i => (hmeas i).neg) (fun i => (hint i).neg) hnegsq hnegmean hlower hnegsecond).trans hexp calc μ.real {ω | bernsteinRadius v u < |∑ i, X i ω|} ≤ μ.real ({ω | bernsteinRadius v u ≤ ∑ i, X i ω} ∪ {ω | bernsteinRadius v u ≤ ∑ i, -X i ω}) := by refine measureReal_mono ?_ (by finiteness) intro ω hω change bernsteinRadius v u < |∑ i, X i ω| at hω rcases lt_abs.mp hω with hω | hω · exact inl hω.le · exact inr (by simpa only [Set.mem_ofPred_eq, Finset.sum_neg_distrib] using hω.le) _ ≤ μ.real {ω | bernsteinRadius v u ≤ ∑ i, X i ω} + μ.real {ω | bernsteinRadius v u ≤ ∑ i, -X i ω} := measureReal_union_le _ _ _ ≤ 2 * exp (-u) := by linarith
Causalean.Stat.Concentration.ConditionalBernstein.bernstein_sum_totalVariance_abs_gt · Causalean/Stat/Concentration/ConditionalBernstein/TotalVariance.lean:125 · uses bernsteinRadius
2 supporting declarations (lemmas, instances)
  • bernsteinRadius_nonneg theorem — The Bernstein radius is nonnegative at any nonnegative tail parameter.
    v :
    ℝ
    u :
    ℝ
    hu :
    0 ≤ u
    0 ≤ bernsteinRadius v u
    Proof (Lean source)
    theorem bernsteinRadius_nonneg (v : ℝ) {u : ℝ} (hu : 0 ≤ u) : 0 ≤ bernsteinRadius v u := add_nonneg (Real.sqrt_nonneg _) hu
    Causalean.Stat.Concentration.ConditionalBernstein.bernsteinRadius_nonneg · Causalean/Stat/Concentration/ConditionalBernstein/TotalVariance.lean:27
  • bernstein_sum_totalVariance_ge theorem — Independent measurable centered summands, integrable with integrable squares and bounded above by one, whose total second moment is at most a positive budget, satisfy the upper Bernstein tail at any nonnegative threshold.
    Ω :
    n :
    ℕ
    Fin n → Ω → ℝ
    v t :
    ℝ
    hv :
    0 < v
    ht :
    0 ≤ t
    hindep :
    iIndepFun X μ
    hmeas :
    ∀ i, Measurable (X i)
    hint :
    ∀ i, Integrable (X i) μ
    hsqint :
    ∀ i, Integrable (fun ω => X i ω ^ 2) μ
    hmean :
    ∀ i, ∫ ω, X i ω ∂μ = 0
    hupper :
    ∀ i, ∀ᵐ ω ∂μ, X i ω ≤ 1
    hsecond :
    (∑ i, ∫ ω, X i ω ^ 2 ∂μ) ≤ v
    μ.real {ω | t ≤ ∑ i, X i ω} ≤ exp (-t ^ 2 / (2 * (v + t / 3)))
    Proof (Lean source)
    theorem bernstein_sum_totalVariance_ge {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ] {n : ℕ} {X : Fin n → Ω → ℝ} {v t : ℝ} (hv : 0 < v) (ht : 0 ≤ t) (hindep : iIndepFun X μ) (hmeas : ∀ i, Measurable (X i)) (hint : ∀ i, Integrable (X i) μ) (hsqint : ∀ i, Integrable (fun ω => X i ω ^ 2) μ) (hmean : ∀ i, ∫ ω, X i ω ∂μ = 0) (hupper : ∀ i, ∀ᵐ ω ∂μ, X i ω ≤ 1) (hsecond : (∑ i, ∫ ω, X i ω ^ 2 ∂μ) ≤ v) : μ.real {ω | t ≤ ∑ i, X i ω} ≤ exp (-t ^ 2 / (2 * (v + t / 3))) := by classical by_cases htzero : t = 0 · subst t calc _ ≤ μ.real univ := measureReal_mono (Set.subset_univ _) _ = _ := by simp by_cases hn : n = 0 · subst n have htpos : 0 < t := lt_of_le_of_ne ht (Ne.symm htzero) have hempty : {ω | t ≤ ∑ i : Fin 0, X i ω} = ∅ := by ext ω simp [not_le.mpr htpos] rw [hempty] simp only [measureReal_empty] exact (Real.exp_pos _).le set d : ℝ := v + t / 3 with hd have hdpos : 0 < d := by dsimp [d]; positivity set lam : ℝ := t / d with hlam have hlam0 : 0 ≤ lam := div_nonneg ht hdpos.le have hlam3 : lam * 1 < 3 := by rw [mul_one, hlam, div_lt_iff₀ hdpos] dsimp [d] linarith have hexp (i : Fin n) : Integrable (fun ω => exp (lam * X i ω)) μ := by refine Integrable.mono' (integrable_const (exp lam)) ((Real.measurable_exp.comp ((hmeas i).const_mul lam)).aestronglyMeasurable) ?_ filter_upwards [hupper i] with ω hω rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] exact Real.exp_le_exp.mpr (by nlinarith) have hmgfi (i : Fin n) : mgf (X i) μ lam ≤ exp (lam ^ 2 * (∫ ω, X i ω ^ 2 ∂μ) / (2 * (1 - lam / 3))) := by simpa using centered_bounded_mgf_le (b := 1) (by norm_num) hlam0 hlam3 (hmeas i).aemeasurable (hint i) (hsqint i) (hmean i) (hupper i) le_rfl have hden : 0 < 2 * (1 - lam / 3) := by linarith have hmgfsum : mgf (fun ω => ∑ i, X i ω) μ lam ≤ exp (lam ^ 2 * v / (2 * (1 - lam / 3))) := by simp only [← Finset.sum_apply] rw [hindep.mgf_sum hmeas univ] calc ∏ i, mgf (X i) μ lam ≤ ∏ i, exp (lam ^ 2 * (∫ ω, X i ω ^ 2 ∂μ) / (2 * (1 - lam / 3))) := by apply Finset.prod_le_prod · intro i _ exact mgf_nonneg · intro i _ exact hmgfi i _ = exp (lam ^ 2 * (∑ i, ∫ ω, X i ω ^ 2 ∂μ) / (2 * (1 - lam / 3))) := by rw [← Real.exp_sum] congr 1 rw [← Finset.sum_div, ← Finset.mul_sum] _ ≤ _ := by apply Real.exp_le_exp.mpr exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hsecond (sq_nonneg lam)) hden.le have hsumint : Integrable (fun ω => exp (lam * (∑ i, X i ω))) μ := by simp only [← Finset.sum_apply] exact hindep.integrable_exp_mul_sum hmeas (s := univ) (fun i _ => hexp i) calc μ.real {ω | t ≤ ∑ i, X i ω} ≤ exp (-lam * t) * mgf (fun ω => ∑ i, X i ω) μ lam := measure_ge_le_exp_mul_mgf t hlam0 hsumint _ ≤ exp (-lam * t) * exp (lam ^ 2 * v / (2 * (1 - lam / 3))) := mul_le_mul_of_nonneg_left hmgfsum (Real.exp_pos _).le _ = exp (-lam * t + lam ^ 2 * v / (2 * (1 - lam / 3))) := by rw [← Real.exp_add] _ ≤ _ := by apply Real.exp_le_exp.mpr rw [hlam, hd] field_simp [ne_of_gt hv] nlinarith
    Causalean.Stat.Concentration.ConditionalBernstein.bernstein_sum_totalVariance_ge · Causalean/Stat/Concentration/ConditionalBernstein/TotalVariance.lean:31
Simultaneous 2 core · 2 supporting The failure event is a union over all design-cell and outcome-bin pairs. ★ fibre_simultaneous_tail_le

Simultaneous finite-family conditional histogram tails

The failure event is a union over all design-cell and outcome-bin pairs. Outside it, every count deviation is at most sqrt (2 * pMax * N_c * u) + u without division. Finite union bounds require no independence or disjointness between different pairs.

def histogramBadEvent reviewed
Causalean.Stat.Concentration.ConditionalBernstein

The histogram failure event is the set of design and outcome vectors for which, for some design cell of the key map and some outcome bin of the family, the joint count differs from its conditional mean under the outcome kernel by strictly more than √(2 · pMax · N_c · u) + u, where N_c is the number of design entries in the cell and pMax and u are the probability envelope and tail parameter.

Definition (Lean source)
D :
Type u_1
shared
Y :
Type u_2
shared
C :
Type u_3
shared
B :
Type u_4
shared
n :
ℕ
shared
key :
D → C
K :
Kernel D Y
bins :
B → Set Y
pMax u :
ℝ
histogramBadEvent key K bins pMax u :
Set ((Fin n → D) × (Fin n → Y))
{p | ∃ c b, bernsteinRadius (pMax * (cellCount key c p.1 : ℝ)) u < |(jointCount key (bins b) c p.1 p.2 : ℝ) - conditionalMean key K (bins b) c p.1|}
Causalean.Stat.Concentration.ConditionalBernstein.histogramBadEvent · Causalean/Stat/Concentration/ConditionalBernstein/Simultaneous.lean:20
theorem fibre_simultaneous_tail_le reviewed
Causalean.Stat.Concentration.ConditionalBernstein

Fix a complete design vector, finitely many design cells and finitely many measurable outcome bins, and draw the outcomes independently across coordinates from a Markov outcome kernel at the design entries. Suppose the kernel probability of every bin is at most a nonnegative number pMax at every design entry and the tail parameter u is nonnegative. Then the probability that, for some cell and some bin, the joint count differs from its conditional mean by strictly more than √(2 · pMax · N_c · u) + u, where N_c is the number of design entries in the cell, is at most 2 · (number of cells) · (number of bins) · exp(−u).

Formal statement
D :
Type u_1
shared
Y :
Type u_2
shared
C :
Type u_3
shared
B :
Type u_4
shared
n :
ℕ
shared
key :
D → C
bins :
B → Set Y
hbins :
∀ b, MeasurableSet (bins b)
x :
Fin n → D
pMax u :
ℝ
hpMax :
0 ≤ pMax
hu :
0 ≤ u
hprob :
∀ c b i
if
key (x i) = c
then
binProbability K (bins b) (x i) ≤ pMax
(finProductKernel n K x).real (Prod.mk x ⁻¹' histogramBadEvent key K bins pMax u)
≤ 2 * (Fintype.card C : ℝ) * (Fintype.card B : ℝ) * exp (-u)
Proof (Lean source)
theorem fibre_simultaneous_tail_le [Fintype C] [Fintype B] (key : D → C) (K : Kernel D Y) [IsMarkovKernel K] (bins : B → Set Y) (hbins : ∀ b, MeasurableSet (bins b)) (x : Fin n → D) {pMax u : ℝ} (hpMax : 0 ≤ pMax) (hu : 0 ≤ u) (hprob : ∀ c b i, key (x i) = c → binProbability K (bins b) (x i) ≤ pMax) : (finProductKernel n K x).real (Prod.mk x ⁻¹' histogramBadEvent key K bins pMax u) ≤ 2 * (Fintype.card C : ℝ) * (Fintype.card B : ℝ) * exp (-u) := by classical let events : C × B → Set (Fin n → Y) := fun q => {y | bernsteinRadius (pMax * (cellCount key q.1 x : ℝ)) u < |(jointCount key (bins q.2) q.1 x y : ℝ) - conditionalMean key K (bins q.2) q.1 x|} have hevent : Prod.mk x ⁻¹' histogramBadEvent key K bins pMax u = ⋃ q : C × B, events q := by ext y simp only [histogramBadEvent, Set.mem_preimage, Set.mem_ofPred_eq, Set.mem_iUnion, events] exact ⟨fun ⟨c, b, h⟩ => ⟨(c, b), h⟩, fun ⟨q, h⟩ => ⟨q.1, q.2, h⟩⟩ rw [hevent] calc _ ≤ ∑ q : C × B, (finProductKernel n K x).real (events q) := measureReal_iUnion_fintype_le events _ ≤ ∑ _q : C × B, 2 * exp (-u) := Finset.sum_le_sum (fun q _ => fibre_pair_tail_le key K q.1 x (hbins q.2) hpMax hu (hprob q.1 q.2)) _ = _ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_prod, nsmul_eq_mul, Nat.cast_mul] ring
Causalean.Stat.Concentration.ConditionalBernstein.fibre_simultaneous_tail_le · Causalean/Stat/Concentration/ConditionalBernstein/Simultaneous.lean:50 · uses binProbability , histogramBadEvent , finProductKernel
2 supporting declarations (lemmas, instances)
Bernoulli 1 core · 5 supporting These one-coordinate facts supply the Bernoulli means, second moments, and bounds used on each conditional design fibre. ★ integral_sq_centered_bin

Centered measurable-bin indicators

These one-coordinate facts supply the Bernoulli means, second moments, and bounds used on each conditional design fibre. No density or regularity of the outcome law is assumed.

theorem integral_sq_centered_bin reviewed
Causalean.Stat.Concentration.ConditionalBernstein

For a measurable bin with probability p under a probability law, the expected square of the bin indicator minus p equals p (1 − p).

Formal statement
Y :
Type u_1
shared
μ :
shared
bin :
Set Y
shared
hbin :
(∫ y, (binIndicator bin y - μ.real bin) ^ 2 ∂μ) = μ.real bin * (1 - μ.real bin)
Proof (Lean source)
theorem integral_sq_centered_bin (hbin : MeasurableSet bin) : (∫ y, (binIndicator bin y - μ.real bin) ^ 2 ∂μ) = μ.real bin * (1 - μ.real bin) := by have hi : Integrable (binIndicator bin) μ := (integrable_const (1 : ℝ)).indicator hbin have hexpand : (fun y => (binIndicator bin y - μ.real bin) ^ 2) = (fun y => (1 - 2 * μ.real bin) * binIndicator bin y + μ.real bin ^ 2) := by funext y by_cases hy : y ∈ bin · simp [binIndicator, hy] ring · simp [binIndicator, hy] rw [hexpand, integral_add (hi.const_mul _) (integrable_const _), integral_const_mul] simp only [binIndicator, integral_indicator_const (1 : ℝ) hbin, smul_eq_mul, mul_one, integral_const, probReal_univ, one_mul] ring
Causalean.Stat.Concentration.ConditionalBernstein.integral_sq_centered_bin · Causalean/Stat/Concentration/ConditionalBernstein/Bernoulli.lean:54 · uses binIndicator
5 supporting declarations (lemmas, instances)
Disintegration 1 core · 1 supporting This module exposes the generic kernel-law tensorization pattern used by RandomDesignWeightedHoeffding.product_observation_law_map_design_outcome. ★ iid_joint_map_split

Design-fibre disintegration for arbitrary outcome spaces

This module exposes the generic kernel-law tensorization pattern used by RandomDesignWeightedHoeffding.product_observation_law_map_design_outcome. Unlike that conditional-distribution adapter, this kernel-native formulation accepts arbitrary measurable outcome spaces and needs no standard-Borel hypothesis. A second lemma integrates an almost-everywhere fibre event bound over a probability design law.

theorem iid_joint_map_split reviewed
Causalean.Stat.Concentration.ConditionalBernstein

Sampling IID design/outcome pairs from an attached kernel law and separating the complete design and outcome vectors yields the design-product law attached to the coordinatewise product outcome kernel.

Formal statement
(Measure.pi (fun _ : Fin n => Q ⊗ₘ K)).map (fun z => (fun i => (z i).1, fun i => (z i).2))
= Measure.pi (fun _ : Fin n => Q) ⊗ₘ finProductKernel n K
Proof (Lean source)
theorem iid_joint_map_split {D Y : Type*} [MeasurableSpace D] [MeasurableSpace Y] (n : ℕ) (Q : Measure D) [IsProbabilityMeasure Q] (K : Kernel D Y) [IsMarkovKernel K] : (Measure.pi (fun _ : Fin n => Q ⊗ₘ K)).map (fun z => (fun i => (z i).1, fun i => (z i).2)) = Measure.pi (fun _ : Fin n => Q) ⊗ₘ Causalean.Stat.finProductKernel n K := by classical let d₀ : D := choice (nonempty_of_isProbabilityMeasure Q) let split := MeasurableEquiv.arrowProdEquivProdArrow D Y (Fin n) let pairLaw : Measure (D × Y) := Q ⊗ₘ K let designLaw : Measure (Fin n → D) := Measure.pi (fun _ : Fin n => Q) let markKernel := Causalean.Stat.finProductKernel n K let : IsProbabilityMeasure pairLaw := by dsimp only [pairLaw] infer_instance let : IsProbabilityMeasure (Measure.pi (fun _ : Fin n => pairLaw)) := inferInstance let : IsProbabilityMeasure designLaw := by dsimp only [designLaw] infer_instance let : IsMarkovKernel markKernel := by dsimp only [markKernel] infer_instance let lhs := (Measure.pi (fun _ : Fin n => pairLaw)).map split let rhs := designLaw ⊗ₘ markKernel change lhs = rhs refine Measure.FiniteSpanningSetsIn.ext ?_ (isPiSystem_pi.prod isPiSystem_pi) ?_ ?_ · refine (generateFrom_eq_prod generateFrom_pi generateFrom_pi ?_ ?_).symm · exact (Measure.FiniteSpanningSetsIn.pi (fun _ : Fin n => Q.toFiniteSpanningSetsIn)).isCountablySpanning · exact (Measure.FiniteSpanningSetsIn.pi (fun _ : Fin n => (K d₀).toFiniteSpanningSetsIn)).isCountablySpanning · let base := (Measure.pi (fun _ : Fin n => Q)).prod (Measure.pi (fun _ : Fin n => (K d₀))) let hbase := (Measure.FiniteSpanningSetsIn.pi (fun _ : Fin n => Q.toFiniteSpanningSetsIn)).prod (Measure.FiniteSpanningSetsIn.pi (fun _ : Fin n => (K d₀).toFiniteSpanningSetsIn)) exact ⟨hbase.set, hbase.set_mem, fun i => measure_lt_top _ _, hbase.spanning⟩ · rintro _ ⟨s, ⟨s, hs, rfl⟩, ⟨_, ⟨t, ht, rfl⟩, rfl⟩⟩ have hs' : ∀ i, MeasurableSet (s i) := fun i => hs i (Set.mem_univ i) have ht' : ∀ i, MeasurableSet (t i) := fun i => ht i (Set.mem_univ i) have hdesignSet : MeasurableSet (Set.univ.pi s) := MeasurableSet.pi Set.finite_univ.countable (fun i _ => hs' i) have hmarkSet : MeasurableSet (Set.univ.pi t) := MeasurableSet.pi Set.finite_univ.countable (fun i _ => ht' i) simp only [lhs, rhs] rw [Measure.map_apply split.measurable (hdesignSet.prod hmarkSet)] rw [show split ⁻¹' (Set.univ.pi s ×ˢ Set.univ.pi t) = Set.univ.pi (fun i => s i ×ˢ t i) by ext x simp only [split, MeasurableEquiv.arrowProdEquivProdArrow, MeasurableEquiv.coe_mk, Set.mem_preimage, Set.mem_prod, Set.mem_pi, Set.mem_univ, true_implies, Equiv.arrowProdEquivProdArrow_apply, forall_and]] rw [Measure.pi_pi, Measure.compProd_apply_prod hdesignSet hmarkSet] simp_rw [pairLaw, Measure.compProd_apply_prod (hs' _) (ht' _)] simp only [markKernel] simp_rw [finProductKernel_apply, Measure.pi_pi] let X : Fin n → (Fin n → D) → ENNReal := fun i d => indicator (s i) (fun x => K x (t i)) (d i) have hXmeas : ∀ i, Measurable (X i) := fun i => ((K.measurable_coe (ht' i)).indicator (hs' i)).comp (measurable_pi_apply i) have hXindep : iIndepFun X designLaw := by have heval : iIndepFun (fun i (d : Fin n → D) => d i) designLaw := by simpa only [designLaw, id_eq] using (iIndepFun_pi (X := fun _ => id) (fun _ => measurable_id.aemeasurable)) change iIndepFun (fun i => (fun x => indicator (s i) (fun z => K z (t i)) x) ∘ fun d : Fin n → D => d i) designLaw exact heval.comp (fun i x => indicator (s i) (fun z => K z (t i)) x) (fun i => (K.measurable_coe (ht' i)).indicator (hs' i)) rw [← lintegral_indicator hdesignSet] change (∏ i, ∫⁻ x in s i, K x (t i) ∂Q) = ∫⁻ d, indicator (Set.univ.pi s) (fun d => ∏ i, K (d i) (t i)) d ∂designLaw rw [show (fun d => indicator (Set.univ.pi s) (fun d => ∏ i, K (d i) (t i)) d) = fun d => ∏ i, X i d by funext d by_cases hd : ∀ i, d i ∈ s i · rw [Set.indicator_of_mem (show d ∈ Set.univ.pi s from fun i _ => hd i)] exact Finset.prod_congr rfl fun i _ => by simp [X, hd i] · rw [Set.indicator_of_notMem (show d ∉ Set.univ.pi s by intro hmem exact hd fun i => hmem i (Set.mem_univ i))] push Not at hd obtain ⟨i, hi⟩ := hd symm exact Finset.prod_eq_zero (Finset.mem_univ i) (by simp [X, hi])] rw [lintegral_prod_eq_prod_lintegral_of_indepFun univ X hXindep hXmeas] apply Finset.prod_congr rfl intro i _ calc (∫⁻ x in s i, K x (t i) ∂Q) = ∫⁻ x, indicator (s i) (fun z => K z (t i)) x ∂Q := (lintegral_indicator (hs' i) _).symm _ = ∫⁻ d, X i d ∂designLaw := ((measurePreserving_eval (fun _ : Fin n => Q) i).lintegral_comp ((K.measurable_coe (ht' i)).indicator (hs' i))).symm
Causalean.Stat.Concentration.ConditionalBernstein.iid_joint_map_split · Causalean/Stat/Concentration/ConditionalBernstein/Disintegration.lean:23 · uses finProductKernel
1 supporting declaration (lemmas, instances)
Fibre 1 core · 8 supporting Fixing the complete design vector makes the outcome coordinates independent under the finite product kernel. ★ fibre_pair_tail_le

Conditional Bernstein bounds on a complete design fibre

Fixing the complete design vector makes the outcome coordinates independent under the finite product kernel. This module derives the centered Bernoulli summand data, bounds the sum of second moments by pMax * cellCount, and proves the two-sided count tail. No positive-count condition is imposed; zero-count cells have identically zero deviation.

theorem fibre_pair_tail_le reviewed
Causalean.Stat.Concentration.ConditionalBernstein

Fix a complete design vector, and draw the outcomes independently across coordinates, each from a Markov outcome kernel at its design entry. For a design cell and measurable bin, suppose the kernel probability of the bin is at most a nonnegative number pMax at every design entry in the cell and the tail parameter u is nonnegative. Then the probability that the joint count differs from its conditional mean by strictly more than √(2 · pMax · N · u) + u, where N is the number of design entries in the cell, is at most 2 exp(−u).

Formal statement
D :
Type u_1
shared
Y :
Type u_2
shared
C :
Type u_3
shared
n :
ℕ
shared
key :
D → C
shared
K :
Kernel D Y
shared
bin :
Set Y
shared
c :
C
shared
x :
Fin n → D
shared
hbin :
pMax u :
ℝ
hpMax :
0 ≤ pMax
hu :
0 ≤ u
hprob :
∀ i
if
key (x i) = c
then
binProbability K bin (x i) ≤ pMax
(finProductKernel n K x).real {y | bernsteinRadius (pMax * (cellCount key c x : ℝ)) u < |(jointCount key bin c x y : ℝ) - conditionalMean key K bin c x|}
≤ 2 * exp (-u)
Proof (Lean source)
theorem fibre_pair_tail_le (hbin : MeasurableSet bin) {pMax u : ℝ} (hpMax : 0 ≤ pMax) (hu : 0 ≤ u) (hprob : ∀ i, key (x i) = c → binProbability K bin (x i) ≤ pMax) : (finProductKernel n K x).real {y | bernsteinRadius (pMax * (cellCount key c x : ℝ)) u < |(jointCount key bin c x y : ℝ) - conditionalMean key K bin c x|} ≤ 2 * exp (-u) := by have hv : 0 ≤ pMax * (cellCount key c x : ℝ) := mul_nonneg hpMax (Nat.cast_nonneg _) simpa only [jointCount_sub_conditionalMean] using bernstein_sum_totalVariance_abs_gt hv hu (iIndepFun_centeredSummand key K c x hbin) (measurable_centeredSummand key K c x hbin) (integrable_centeredSummand key K c x hbin) (integrable_sq_centeredSummand key K c x hbin) (integral_centeredSummand key K c x hbin) (fun i => Filter.Eventually.of_forall (abs_centeredSummand_le_one key K c x i)) (sum_second_moments_le key K c x hbin hprob)
8 supporting declarations (lemmas, instances)
Integrated 1 core · 3 supporting The headline theorem bounds simultaneous cell/bin count deviations under the IID product of a design marginal attached to a measurable conditional outcome kernel. ★ iid_joint_simultaneous_tail_le

IID joint-law finite-partition conditional Bernstein histogram tails

The headline theorem bounds simultaneous cell/bin count deviations under the IID product of a design marginal attached to a measurable conditional outcome kernel. It first proves the conditional bound given the entire design vector, integrates that bound, and transports back to the IID law. The probability envelope need only hold almost everywhere under the design marginal. There is no lower-count hypothesis.

For all pairs, the radius is sqrt (2 * pMax * N_c * u) + u, and the total failure probability is at most 2 * card C * card B * exp (-u). A deterministic adapter permits division by the cell count only when a separate positive-count hypothesis is available.

theorem iid_joint_simultaneous_tail_le reviewed
Causalean.Stat.Concentration.ConditionalBernstein

Draw an IID sample of design/outcome pairs, each design from a probability law and each outcome from a Markov kernel at its design, and fix finitely many measurable design cells and finitely many measurable outcome bins. Suppose the kernel probability of every bin is at most a nonnegative number pMax at almost every design point and the tail parameter u is nonnegative. Then the probability that, for some cell and some bin, the joint count differs from its conditional mean given the designs by strictly more than √(2 · pMax · N_c · u) + u, where N_c is the number of sampled designs in the cell, is at most 2 · (number of cells) · (number of bins) · exp(−u).

Formal statement
D :
Type u_1
shared
Y :
Type u_2
shared
C :
Type u_3
shared
B :
Type u_4
shared
n :
ℕ
shared
key :
D → C
bins :
B → Set Y
hcell :
∀ c, MeasurableSet {d | key d = c}
hbins :
∀ b, MeasurableSet (bins b)
pMax u :
ℝ
hpMax :
0 ≤ pMax
hu :
0 ≤ u
henvelope :
∀ᵐ d ∂Q, ∀ c b, key d = c → binProbability K (bins b) d ≤ pMax
(Measure.pi (fun _ : Fin n => Q ⊗ₘ K)).real {z | ∃ c b, bernsteinRadius (pMax * (cellCount key c (fun i => (z i).1) : ℝ)) u < |(jointCount key (bins b) c (fun i => (z i).1) (fun i => (z i).2) : ℝ) - conditionalMean key K (bins b) c (fun i => (z i).1)|}
≤ 2 * (Fintype.card C : ℝ) * (Fintype.card B : ℝ) * exp (-u)
Proof (Lean source)
theorem iid_joint_simultaneous_tail_le [Fintype C] [Fintype B] (Q : Measure D) [IsProbabilityMeasure Q] (K : Kernel D Y) [IsMarkovKernel K] (key : D → C) (bins : B → Set Y) (hcell : ∀ c, MeasurableSet {d | key d = c}) (hbins : ∀ b, MeasurableSet (bins b)) {pMax u : ℝ} (hpMax : 0 ≤ pMax) (hu : 0 ≤ u) (henvelope : ∀ᵐ d ∂Q, ∀ c b, key d = c → binProbability K (bins b) d ≤ pMax) : (Measure.pi (fun _ : Fin n => Q ⊗ₘ K)).real {z | ∃ c b, bernsteinRadius (pMax * (cellCount key c (fun i => (z i).1) : ℝ)) u < |(jointCount key (bins b) c (fun i => (z i).1) (fun i => (z i).2) : ℝ) - conditionalMean key K (bins b) c (fun i => (z i).1)|} ≤ 2 * (Fintype.card C : ℝ) * (Fintype.card B : ℝ) * exp (-u) := by have hsplit : Measurable (fun z : Fin n → D × Y => (fun i => (z i).1, fun i => (z i).2)) := (measurable_pi_lambda _ (fun i => (measurable_pi_apply i).fst)).prodMk (measurable_pi_lambda _ (fun i => (measurable_pi_apply i).snd)) have hmap := Measure.map_apply hsplit (measurableSet_histogramBadEvent (n := n) key K bins hcell hbins pMax u) (μ := Measure.pi (fun _ : Fin n => Q ⊗ₘ K)) rw [iid_joint_map_split n Q K] at hmap have hreal := congrArg toReal hmap change (Measure.pi (fun _ : Fin n => Q) ⊗ₘ finProductKernel n K).real (histogramBadEvent key K bins pMax u) = (Measure.pi (fun _ : Fin n => Q ⊗ₘ K)).real {z | ∃ c b, bernsteinRadius (pMax * (cellCount key c (fun i => (z i).1) : ℝ)) u < |(jointCount key (bins b) c (fun i => (z i).1) (fun i => (z i).2) : ℝ) - conditionalMean key K (bins b) c (fun i => (z i).1)|} at hreal rw [← hreal] exact attached_simultaneous_tail_le Q K key bins hcell hbins hpMax hu henvelope
3 supporting declarations (lemmas, instances)
  • ae_design_vector_envelope theorem — An almost-everywhere conditional bin envelope under a design marginal also holds simultaneously at every coordinate of almost every IID design vector.
    D :
    Type u_1
    shared
    Y :
    Type u_2
    shared
    C :
    Type u_3
    shared
    B :
    Type u_4
    shared
    n :
    ℕ
    shared
    K :
    Kernel D Y
    key :
    D → C
    bins :
    B → Set Y
    pMax :
    ℝ
    henvelope :
    ∀ᵐ d ∂Q, ∀ c b, key d = c → binProbability K (bins b) d ≤ pMax
    ∀ᵐ x ∂Measure.pi (fun _ : Fin n => Q), ∀ c b i, key (x i)
    = c → binProbability K (bins b) (x i) ≤ pMax
    Proof (Lean source)
    theorem ae_design_vector_envelope (Q : Measure D) [IsProbabilityMeasure Q] (K : Kernel D Y) (key : D → C) (bins : B → Set Y) (pMax : ℝ) (henvelope : ∀ᵐ d ∂Q, ∀ c b, key d = c → binProbability K (bins b) d ≤ pMax) : ∀ᵐ x ∂Measure.pi (fun _ : Fin n => Q), ∀ c b i, key (x i) = c → binProbability K (bins b) (x i) ≤ pMax := by have hcoord (i : Fin n) : ∀ᵐ x ∂Measure.pi (fun _ : Fin n => Q), ∀ c b, key (x i) = c → binProbability K (bins b) (x i) ≤ pMax := (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin n => Q) (i := i)).eventually henvelope filter_upwards [(ae_all_iff).mpr hcoord] with x hx exact fun c b i => hx i c b
    Causalean.Stat.Concentration.ConditionalBernstein.ae_design_vector_envelope · Causalean/Stat/Concentration/ConditionalBernstein/Integrated.lean:27
  • attached_simultaneous_tail_le theorem — Under a probability design marginal and Markov outcome kernel, finite measurable cells and bins with an almost-everywhere nonnegative conditional bin envelope satisfy the simultaneous two-sided count bound under the retained-design law at nonnegative tail parameter.
    D :
    Type u_1
    shared
    Y :
    Type u_2
    shared
    C :
    Type u_3
    shared
    B :
    Type u_4
    shared
    n :
    ℕ
    shared
    key :
    D → C
    bins :
    B → Set Y
    hcell :
    ∀ c, MeasurableSet {d | key d = c}
    hbins :
    ∀ b, MeasurableSet (bins b)
    pMax u :
    ℝ
    hpMax :
    0 ≤ pMax
    hu :
    0 ≤ u
    henvelope :
    ∀ᵐ d ∂Q, ∀ c b, key d = c → binProbability K (bins b) d ≤ pMax
    (Measure.pi (fun _ : Fin n => Q) ⊗ₘ finProductKernel n K).real (histogramBadEvent key K bins pMax u)
    ≤ 2 * (Fintype.card C : ℝ) * (Fintype.card B : ℝ) * exp (-u)
    Proof (Lean source)
    theorem attached_simultaneous_tail_le [Fintype C] [Fintype B] (Q : Measure D) [IsProbabilityMeasure Q] (K : Kernel D Y) [IsMarkovKernel K] (key : D → C) (bins : B → Set Y) (hcell : ∀ c, MeasurableSet {d | key d = c}) (hbins : ∀ b, MeasurableSet (bins b)) {pMax u : ℝ} (hpMax : 0 ≤ pMax) (hu : 0 ≤ u) (henvelope : ∀ᵐ d ∂Q, ∀ c b, key d = c → binProbability K (bins b) d ≤ pMax) : (Measure.pi (fun _ : Fin n => Q) ⊗ₘ finProductKernel n K).real (histogramBadEvent key K bins pMax u) ≤ 2 * (Fintype.card C : ℝ) * (Fintype.card B : ℝ) * exp (-u) := by refine compProd_real_le_of_fibre_real_le (Measure.pi (fun _ : Fin n => Q)) (finProductKernel n K) (measurableSet_histogramBadEvent key K bins hcell hbins pMax u) (by positivity) ?_ filter_upwards [ae_design_vector_envelope Q K key bins pMax henvelope] with x hx exact fibre_simultaneous_tail_le key K bins hbins x hpMax hu hx
    Causalean.Stat.Concentration.ConditionalBernstein.attached_simultaneous_tail_le · Causalean/Stat/Concentration/ConditionalBernstein/Integrated.lean:41
  • normalized_deviation_le theorem — A count deviation bounded by its Bernstein radius in a cell of positive count gives the corresponding bound for the empirical bin proportion minus the conditional mean divided by that count.
    D :
    Type u_1
    shared
    Y :
    Type u_2
    shared
    C :
    Type u_3
    shared
    n :
    ℕ
    shared
    key :
    D → C
    K :
    Kernel D Y
    bin :
    Set Y
    c :
    C
    x :
    Fin n → D
    y :
    Fin n → Y
    pMax u :
    ℝ
    hcount :
    0 < cellCount key c x
    hdev :
    |(jointCount key bin c x y : ℝ) - conditionalMean key K bin c x|
    ≤ bernsteinRadius (pMax * (cellCount key c x : ℝ)) u
    |(jointCount key bin c x y : ℝ) / (cellCount key c x : ℝ)
    - conditionalMean key K bin c x / (cellCount key c x : ℝ)|
    ≤ bernsteinRadius (pMax * (cellCount key c x : ℝ)) u / (cellCount key c x : ℝ)
    Proof (Lean source)
    theorem normalized_deviation_le (key : D → C) (K : Kernel D Y) (bin : Set Y) (c : C) (x : Fin n → D) (y : Fin n → Y) (pMax u : ℝ) (hcount : 0 < cellCount key c x) (hdev : |(jointCount key bin c x y : ℝ) - conditionalMean key K bin c x| ≤ bernsteinRadius (pMax * (cellCount key c x : ℝ)) u) : |(jointCount key bin c x y : ℝ) / (cellCount key c x : ℝ) - conditionalMean key K bin c x / (cellCount key c x : ℝ)| ≤ bernsteinRadius (pMax * (cellCount key c x : ℝ)) u / (cellCount key c x : ℝ) := by have hpos : (0 : ℝ) < cellCount key c x := by exact_mod_cast hcount rw [← sub_div, abs_div, abs_of_pos hpos] exact div_le_div_of_nonneg_right hdev hpos.le
    Causalean.Stat.Concentration.ConditionalBernstein.normalized_deviation_le · Causalean/Stat/Concentration/ConditionalBernstein/Integrated.lean:123