Stat.Quantile
Quantile processes: empirical quantiles, Bahadur representations, and joint sample-quantile asymptotics.
EmpiricalCDF 6 core · 14 supporting This file defines the empirical cumulative distribution function of a real i.i.d. ★ cdfIF_variance★ empiricalCDF_isAsymLinear★ empiricalCDF_tendsto_inProb
Empirical Distribution Functions
This file defines the empirical cumulative distribution function of a real i.i.d. sample and its pointwise influence function. It proves the boundedness, mean-zero, variance, weak-law, and asymptotic-linearity facts that support sample-quantile and quantile-treatment-effect inference.
For a real threshold, the lower-ray indicator statistic assigns one to each real-valued observation no greater than that threshold and zero to every other observation.
For an independent and identically distributed real-valued sample and a real threshold, the empirical cumulative distribution function maps each nonnegative integer sample size and sample-space outcome to the average of the indicators that the first observations do not exceed that threshold.
For a measure on the real line and a real threshold, the pointwise influence function of the cumulative distribution function assigns to an observation the lower-ray indicator at that threshold minus the measure-assigned cumulative value at that threshold.
Variance of the empirical-cdf influence function. At a fixed threshold y, the population second moment of the cdf influence function equals F(y)(1 − F(y)), the Bernoulli variance of the indicator event {Z ≤ y}.
Formal statement
Proof (Lean source)
Asymptotic linearity of the empirical cdf. For an i.i.d. real sample S at a fixed point y, the empirical cdf F̂ₙ(y) is asymptotically linear at F(y) with influence function cdfIF P y and an identically-zero remainder.
Formal statement
Proof (Lean source)
Empirical-cdf consistency (WLLN). For an i.i.d. real sample S at a fixed point y, the empirical cdf F̂ₙ(y) converges to F(y) in probability.
Formal statement
Proof (Lean source)
14 supporting declarations (lemmas, instances)
-
cdfStat_eqlemma — The lower-ray indicator statistic at level y is the indicator function of the lower ray (-∞, y], taking the value one on that ray and zero off it.Proof (Lean source)
@[causal_defs_simps] lemma cdfStat_eq (y : ℝ) : cdfStat y = indicator (Iic y) (fun _ => (1 : ℝ)) := rfl -
measurable_cdfStatlemma — The lower-ray indicator is measurable.Proof (Lean source)
@[fun_prop] lemma measurable_cdfStat (y : ℝ) : Measurable (cdfStat y) := measurable_const.indicator measurableSet_Iic -
cdfStat_nonneglemma — The lower-ray indicator is nonnegative.Proof (Lean source)
lemma cdfStat_nonneg (y z : ℝ) : 0 ≤ cdfStat y z := by simp only [causal_defs_simps] by_cases h : z ∈ Iic y <;> simp [Set.indicator_of_mem, Set.indicator_of_notMem, h] -
cdfStat_le_onelemma — The lower-ray indicator is bounded above by one.Proof (Lean source)
lemma cdfStat_le_one (y z : ℝ) : cdfStat y z ≤ 1 := by simp only [causal_defs_simps] by_cases h : z ∈ Iic y <;> simp [Set.indicator_of_mem, Set.indicator_of_notMem, h] -
cdfStat_sqlemma — The indicator is idempotent: (1{z ≤ y})² = 1{z ≤ y}.Proof (Lean source)
lemma cdfStat_sq (y z : ℝ) : (cdfStat y z) ^ 2 = cdfStat y z := by simp only [causal_defs_simps] by_cases h : z ∈ Iic y <;> simp [Set.indicator_of_mem, Set.indicator_of_notMem, h] -
integrable_cdfStatlemma — cdfStat y is integrable (bounded by 1 on a finite measure).Proof (Lean source)
@[fun_prop] lemma integrable_cdfStat [IsProbabilityMeasure P] (y : ℝ) : Integrable (cdfStat y) P := by refine (integrable_const (1 : ℝ)).mono' (measurable_cdfStat y).aestronglyMeasurable ?_ filter_upwards with z rw [Real.norm_eq_abs, abs_of_nonneg (cdfStat_nonneg y z)] exact cdfStat_le_one y z -
integral_cdfStatlemma — The integral of the indicator statistic is the cdf value F(y).hypothesesy :ℝProof (Lean source)
lemma integral_cdfStat [IsProbabilityMeasure P] (y : ℝ) : ∫ z, cdfStat y z ∂P = cdf P y := by rw [cdf_eq_real] simp only [causal_defs_simps] rw [MeasureTheory.integral_indicator measurableSet_Iic, setIntegral_const] simp [measureReal_def] -
measurable_cdfIFlemma — The empirical-cdf influence function is measurable.Proof (Lean source)
@[fun_prop] lemma measurable_cdfIF (y : ℝ) : Measurable (cdfIF P y) := (measurable_cdfStat y).sub measurable_const -
cdfIF_mean_zerolemma — cdfIF has mean zero under P.Proof (Lean source)
lemma cdfIF_mean_zero [IsProbabilityMeasure P] (y : ℝ) : ∫ z, cdfIF P y z ∂P = 0 := by unfold cdfIF rw [integral_sub (integrable_cdfStat y) (integrable_const _), integral_cdfStat, integral_const, probReal_univ, one_smul, sub_self] -
abs_cdfIF_le_onelemma — cdfIF is bounded by 1 in absolute value.Proof (Lean source)
lemma abs_cdfIF_le_one [IsProbabilityMeasure P] (y z : ℝ) : |cdfIF P y z| ≤ 1 := by have hF0 : 0 ≤ cdf P y := by rw [cdf_eq_real]; exact measureReal_nonneg have hF1 : cdf P y ≤ 1 := by rw [cdf_eq_real]; exact measureReal_le_one unfold cdfIF by_cases hz : z ≤ y · have h1 : cdfStat y z = 1 := by simp only [causal_defs_simps]; rw [Set.indicator_of_mem (Set.mem_Iic.mpr hz)] rw [h1, abs_le]; constructor <;> linarith · have h0 : cdfStat y z = 0 := by simp only [causal_defs_simps] rw [Set.indicator_of_notMem (by simp only [Set.mem_Iic]; exact hz)] rw [h0, zero_sub, abs_neg, abs_of_nonneg hF0]; linarith -
cdfIF_sq_integrablelemma — cdfIF is square-integrable (it is bounded).Proof (Lean source)
@[fun_prop] lemma cdfIF_sq_integrable [IsProbabilityMeasure P] (y : ℝ) : Integrable (fun z => (cdfIF P y z) ^ 2) P := by refine (integrable_const (1 : ℝ)).mono' ((measurable_cdfIF y).pow_const 2).aestronglyMeasurable ?_ filter_upwards with z rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _), sq_le_one_iff_abs_le_one] exact abs_cdfIF_le_one y z -
isLittleOp_zerolemma — o_p-triviality of the zero sequence at the constant rate rₙ = 1.Proof (Lean source)
lemma isLittleOp_zero : IsLittleOp (fun _ (_ : Ω) => (0 : ℝ)) (fun _ => (1 : ℝ)) μ := by apply (Modes.isLittleOpF_iff_strict (fun _ => μ) (fun _ (_ : Ω) => (0 : ℝ)) atTop (fun _ => (1 : ℝ)) (Eventually.of_forall fun _ => zero_lt_one)).2 intro ε hε have hset : {ω : Ω | ε * (1 : ℝ) < ‖(0 : ℝ)‖} = (∅ : Set Ω) := by ext ω simp only [mul_one, norm_zero, Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false, not_lt] exact hε.le simpa only [hset, measure_empty] using (tendsto_const_nhds : Tendsto (fun _ : ℕ => (0 : ENNReal)) atTop (𝓝 0)) -
rescaledEmpiricalCDF_eq_normalizedSumlemma — Key identity. The rescaled empirical-cdf deviation equals the normalized influence-function sum: √n (F̂ₙ(y) − F(y)) = (1/√n) Σ cdfIF(Z_i).hypothesesProof (Lean source)
lemma rescaledEmpiricalCDF_eq_normalizedSum (S : IIDSample Ω ℝ μ P) (y : ℝ) (n : ℕ) (ω : Ω) : sqrt ((range n).card : ℝ) * (S.empiricalCDF y n ω - cdf P y) = (sqrt ((range n).card : ℝ))⁻¹ * ∑ i ∈ range n, cdfIF P y (S.Z i ω) := by rcases Nat.eq_zero_or_pos n with hn | hn · subst hn simp [IIDSample.empiricalCDF, IIDSample.sampleMean, smul_eq_mul] · have hcard : ((range n).card : ℝ) = (n : ℝ) := by rw [Finset.card_range] have hnpos : (0 : ℝ) < (n : ℝ) := by exact_mod_cast hn have hsum : ∑ i ∈ range n, cdfIF P y (S.Z i ω) = (∑ i ∈ range n, cdfStat y (S.Z i ω)) - (n : ℝ) * cdf P y := by simp only [cdfIF, Finset.sum_sub_distrib, Finset.sum_const, Finset.card_range, nsmul_eq_mul] rw [hcard, hsum] simp only [IIDSample.empiricalCDF, IIDSample.sampleMean, smul_eq_mul] set t := ∑ i ∈ range n, cdfStat y (S.Z i ω) with ht set r := sqrt (n : ℝ) with hrdef have hr2 : r * r = (n : ℝ) := by rw [hrdef]; exact Real.mul_self_sqrt hnpos.le have hrne : r ≠ 0 := by rw [hrdef]; exact (Real.sqrt_pos.mpr hnpos).ne' have hrr : r * r ≠ 0 := mul_ne_zero hrne hrne rw [← hr2] field_simp [hrne, hrr] -
empiricalCDF_tendsto_normaltheorem — Empirical-cdf central limit theorem. For an i.i.d. real sample and a threshold y, provided the rescaled empirical-cdf estimator $\sqrt n\,(\hat F_n(y)-F(y))$ is almost-everywhere measurable at every sample size, the rescaled deviation converges in distribution, as $n\to \infty$, to the centered Gaussian law with variance $F(y)(1-F(y))$, where $F$ is the population cdf and $\hat F_n$ the empirical cdf.hypothesesProof (Lean source)
theorem empiricalCDF_tendsto_normal (S : IIDSample Ω ℝ μ P) (y : ℝ) (hθn_meas : ∀ n : ℕ, AEMeasurable (IsAsymLinear.rescaledEstimator (S.empiricalCDF y) (cdf P y) (fun m => range m) n) μ) : Modes.TendstoInLaw (fun _ : ℕ => μ) (IsAsymLinear.rescaledEstimator (S.empiricalCDF y) (cdf P y) (fun m => range m)) atTop (gaussianMeasure 0 (cdf P y * (1 - cdf P y))) := by have h := (empiricalCDF_isAsymLinear S y).tendsto_normal (measurable_cdfIF y) hθn_meas rwa [cdfIF_variance] at h
Quantile 3 core · 7 supporting This file defines the lower quantile function of a real measure as the generalized inverse of its cumulative distribution function. ★ quantile_le_iff
Quantile Function
This file defines the lower quantile function of a real measure as the generalized inverse of its cumulative distribution function. It proves the basic order characterization that connects cumulative distribution functions and their quantiles away from the degenerate endpoints.
Given a measure on the real line and a real level, the super-level set of Mathlib's totalized cumulative-distribution function contains the real points where that function is at least the level.
Given a measure on the real line and a real level, the lower generalized inverse of Mathlib's totalized cdf is the infimum of its super-level set at that level.
Definition (Lean source)
Quantile / CDF Galois connection. For an interior probability level , the quantile of a real measure at level is at most a point exactly when the CDF has reached there.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
quantileSet_up_closedlemma — If a point belongs to a quantile super-level set and a second point is no smaller, then the second point also belongs to that set.hypothesesconclusionx' ∈ quantileSet μ τProof (Lean source)
lemma quantileSet_up_closed {τ x x' : ℝ} (hx : x ∈ quantileSet μ τ) (hxx' : x ≤ x') : x' ∈ quantileSet μ τ := le_trans hx (monotone_cdf μ hxx') -
bddBelow_quantileSetlemma — At a strictly positive level, the quantile super-level set of a real measure is bounded below.Proof (Lean source)
lemma bddBelow_quantileSet {τ : ℝ} (hτ : 0 < τ) : BddBelow (quantileSet μ τ) := by obtain ⟨N, hN⟩ := Filter.eventually_atBot.mp ((tendsto_cdf_atBot μ).eventually_lt_const hτ) refine ⟨N, fun s hs => ?_⟩ by_contra hlt push Not at hlt exact absurd hs (not_le.mpr (hN s hlt.le)) -
nonempty_quantileSetlemma — At a level strictly below one, the quantile super-level set of a real measure is nonempty.Proof (Lean source)
lemma nonempty_quantileSet {τ : ℝ} (hτ : τ < 1) : (quantileSet μ τ).Nonempty := by obtain ⟨N, hN⟩ := Filter.eventually_atTop.mp ((tendsto_cdf_atTop μ).eventually_const_lt hτ) exact ⟨N, (hN N le_rfl).le⟩ -
le_cdf_quantilelemma — Key membership lemma. At a level strictly below one, the CDF of a real measure at its lower quantile reaches that level.Proof (Lean source)
lemma le_cdf_quantile {τ : ℝ} (hτ1 : τ < 1) : τ ≤ cdf μ (quantile μ τ) := by set a := quantile μ τ with ha have hne : (quantileSet μ τ).Nonempty := nonempty_quantileSet hτ1 -- Every point strictly above the inf lies in the (up-closed) super-level set. have hgt : ∀ x, a < x → τ ≤ cdf μ x := by intro x hx obtain ⟨s, hs, hsx⟩ := exists_lt_of_csInf_lt hne hx exact quantileSet_up_closed hs hsx.le -- Right-continuity: cdf μ → cdf μ a along `𝓝[Ioi a] a`. have htends : Tendsto (cdf μ) (𝓝[Ioi a] a) (𝓝 (cdf μ a)) := ((cdf μ).right_continuous a).mono_left (nhdsWithin_mono a Ioi_subset_Ici_self) -- Along that filter we stay in the super-level set, so the limit dominates τ. have hev : ∀ᶠ x in 𝓝[Ioi a] a, τ ≤ cdf μ x := by filter_upwards [self_mem_nhdsWithin] with x hx using hgt x hx exact ge_of_tendsto htends hev -
le_cdf_of_quantile_lelemma — Galois connection (one direction). If the level is below one and its quantile is at most a point, then the CDF at that point has reached the level.Proof (Lean source)
lemma le_cdf_of_quantile_le {τ x : ℝ} (hτ1 : τ < 1) (hx : quantile μ τ ≤ x) : τ ≤ cdf μ x := le_trans (le_cdf_quantile hτ1) (monotone_cdf μ hx) -
quantile_le_of_le_cdflemma — Galois connection (other direction). If the level is positive and the CDF at a point reaches that level, then the quantile is at most that point.Proof (Lean source)
lemma quantile_le_of_le_cdf {τ x : ℝ} (hτ0 : 0 < τ) (hx : τ ≤ cdf μ x) : quantile μ τ ≤ x := csInf_le (bddBelow_quantileSet hτ0) hx -
quantile_monolemma — If the lower level is positive, the upper level is below one, and the lower level is at most the upper, then the corresponding quantiles of a real measure are ordered.hypothesesProof (Lean source)
lemma quantile_mono {τ τ' : ℝ} (hτ0 : 0 < τ) (hτ'1 : τ' < 1) (hττ' : τ ≤ τ') : quantile μ τ ≤ quantile μ τ' := quantile_le_of_le_cdf hτ0 (le_trans hττ' (le_cdf_quantile hτ'1))
EmpiricalQuantile 5 core · 4 supporting This file builds the sample quantile from the empirical measure of an i.i.d. ★ empiricalMeasure_cdf★ sampleQuantile_le_iff★ sampleQuantile_atom_bound
Empirical Measures and Sample Quantiles
This file builds the sample quantile from the empirical measure of an i.i.d.
real sample. The central definitions are IIDSample.empiricalMeasure, the
finite empirical probability measure, and IIDSample.sampleQuantile, the
generalized inverse of that measure's cdf.
The main structural results are the cdf bridge
IIDSample.empiricalMeasure_cdf, the switching relation
IIDSample.sampleQuantile_le_iff, monotonicity of IIDSample.empiricalCDF in
its real argument, and the atom bound IIDSample.sampleQuantile_atom_bound.
Together these deterministic facts feed the derived Bahadur representation for
the ordinary empirical sample quantile.
For an independent and identically distributed real-valued sample, a nonnegative integer sample size, and a sample-space outcome, the empirical measure is the sum of point masses at the first observed values, multiplied by the reciprocal of ; at sample size zero it is the zero measure.
cdf bridge. For a positive sample size , the cumulative distribution function of the empirical measure S.empiricalMeasure n ω built from an i.i.d. sample at outcome ω coincides pointwise, at every threshold y, with the empirical cdf S.empiricalCDF y n ω.
Formal statement
For an independent and identically distributed real-valued sample and a real quantile level, the sample quantile maps each nonnegative integer sample size and sample-space outcome to the lower generalized inverse, at that level, of the empirical cumulative distribution function.
Switching relation. For a positive sample size and an interior quantile level , the sample -quantile is at most a given point x exactly when is at most the empirical cdf at x.
Formal statement
Proof (Lean source)
Local atom bound. If the population cdf is continuous on a closed neighborhood of the target quantile, the sample size is positive, and the quantile level is interior, then almost surely, whenever the sample quantile lies in the open neighborhood, its empirical-cdf overshoot is at most one observation.
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
empiricalMeasure_isProbabilityMeasurelemma — For 0 < n the empirical measure is a probability measure.hypothesesconclusionIsProbabilityMeasure (S.empiricalMeasure n ω)Proof (Lean source)
lemma IIDSample.empiricalMeasure_isProbabilityMeasure (S : IIDSample Ω ℝ μ P) {n : ℕ} (hn : 0 < n) (ω : Ω) : IsProbabilityMeasure (S.empiricalMeasure n ω) := by constructor unfold IIDSample.empiricalMeasure rw [Measure.smul_apply, Measure.coe_finset_sum, Finset.sum_apply, smul_eq_mul] simp only [MeasureTheory.measure_univ, Finset.sum_const, Finset.card_range, nsmul_eq_mul, mul_one] rw [ENNReal.inv_mul_cancel] · exact_mod_cast hn.ne' · exact ENNReal.natCast_ne_top n -
empiricalMeasure_real_Iiclemma — The empirical measure and empirical CDF agree on lower rays: for an i.i.d. real sample, a positive sample size, an outcome, and a real threshold, the empirical mass of observations at or below the threshold equals the empirical CDF there.hypothesesProof (Lean source)
lemma IIDSample.empiricalMeasure_real_Iic (S : IIDSample Ω ℝ μ P) {n : ℕ} (_hn : 0 < n) (ω : Ω) (y : ℝ) : (S.empiricalMeasure n ω).real (Iic y) = S.empiricalCDF y n ω := by unfold IIDSample.empiricalMeasure IIDSample.empiricalCDF IIDSample.sampleMean rw [Measure.real, Measure.smul_apply, Measure.coe_finset_sum, Finset.sum_apply, smul_eq_mul] simp only [Measure.dirac_apply' _ measurableSet_Iic] rw [ENNReal.toReal_mul, ENNReal.toReal_inv, ENNReal.toReal_natCast] congr 1 rw [ENNReal.toReal_sum (fun i _ => by by_cases h : S.Z i ω ∈ Iic y <;> simp [Set.indicator_of_mem, Set.indicator_of_notMem, h])] apply Finset.sum_congr rfl intro i _ unfold cdfStat by_cases h : S.Z i ω ∈ Iic y · rw [Set.indicator_of_mem h, Set.indicator_of_mem h, Pi.one_apply, ENNReal.toReal_one] · rw [Set.indicator_of_notMem h, Set.indicator_of_notMem h, ENNReal.toReal_zero] -
measurable_sampleQuantilelemma — Measurability of the sample quantile. For a positive sample size and an interior quantile level, the sample quantile is measurable.hypothesesconclusionMeasurable (S.sampleQuantile τ n)Proof (Lean source)
@[fun_prop] lemma IIDSample.measurable_sampleQuantile (S : IIDSample Ω ℝ μ P) {n : ℕ} (hn : 0 < n) {τ : ℝ} (hτ0 : 0 < τ) (hτ1 : τ < 1) : Measurable (S.sampleQuantile τ n) := by apply measurable_of_Iic intro x have hpre : S.sampleQuantile τ n ⁻¹' Iic x = {ω | τ ≤ S.empiricalCDF x n ω} := by ext ω exact S.sampleQuantile_le_iff hn ω hτ0 hτ1 x rw [hpre] exact measurableSet_le measurable_const (S.measurable_sampleMean (measurable_cdfStat x) n) -
empiricalCDF_monotonelemma — The empirical cdf is monotone in its real argument y (a sum of monotone lower-ray indicators).hypothesesconclusionMonotone (fun y => S.empiricalCDF y n ω)Proof (Lean source)
lemma IIDSample.empiricalCDF_monotone (S : IIDSample Ω ℝ μ P) (n : ℕ) (ω : Ω) : Monotone (fun y => S.empiricalCDF y n ω) := by intro y y' hyy' unfold IIDSample.empiricalCDF IIDSample.sampleMean apply mul_le_mul_of_nonneg_left _ (by positivity) apply Finset.sum_le_sum intro i _ unfold cdfStat by_cases h : S.Z i ω ≤ y · rw [Set.indicator_of_mem (Set.mem_Iic.mpr h), Set.indicator_of_mem (Set.mem_Iic.mpr (h.trans hyy'))] · rw [Set.indicator_of_notMem (by simp only [Set.mem_Iic]; exact h)] exact cdfStat_nonneg y' _
SampleQuantile 4 core · 4 supporting This file develops the influence-function and asymptotic-normality layer for sample quantiles of an i.i.d. ★ QuantileRegularity★ isAsymLinear★ tendsto_normal
Sample Quantile Asymptotics
This file develops the influence-function and asymptotic-normality layer for sample quantiles of an i.i.d. real sample. It assumes the Bahadur representation as the regularity input and then derives the classical variance and Gaussian limit for the quantile estimator.
For a quantile index , a population quantile , and a density value , the sample-quantile influence function maps a real observation to .
Definition (Lean source)
Quantile-estimator regularity. Bundles the analytic and empirical-process hypotheses under which a quantile-estimator sequence is -asymptotically linear for the -quantile of with density : the level lies in the open unit interval , the density at the quantile is positive, is indeed the population -quantile, i.e. the cdf satisfies , the cdf is differentiable at with derivative , so that is the genuine asymptotic variance, and the rescaled estimator matches the normalized influence-function sum up to a term vanishing in probability — the Bahadur remainder.
Definition (Lean source)
Regularity implies asymptotic linearity. Given a QuantileRegularity witness h for the estimator sequence qn, the estimator is asymptotically linear at the quantile q₀ with influence function ψ_τ.
Formal statement
Proof (Lean source)
Sample-quantile asymptotic normality. Given a QuantileRegularity witness h for the estimator sequence qn — interior level , positive density at the population quantile , cdf identification, and the exposed Bahadur/Donsker remainder — provided the rescaled estimator is almost-everywhere measurable at each sample size and the normalized influence-function sum is almost-everywhere measurable at each sample size, then converges in distribution to the centered Gaussian law with variance .
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
measurable_quantileIFlemma — The sample-quantile influence function is measurable.Proof (Lean source)
@[fun_prop] lemma measurable_quantileIF (τ q₀ f₀ : ℝ) : Measurable (quantileIF τ q₀ f₀) := (measurable_const.sub (measurable_cdfStat q₀)).div_const f₀ -
quantileIF_mean_zerolemma — The quantile influence function has mean zero under P, given that q₀ is the population τ-quantile (F(q₀) = τ).hypothesesconclusion∫ z, quantileIF τ q₀ f₀ z ∂P = 0Proof (Lean source)
lemma quantileIF_mean_zero [IsProbabilityMeasure P] {τ q₀ f₀ : ℝ} (hcdf : cdf P q₀ = τ) : ∫ z, quantileIF τ q₀ f₀ z ∂P = 0 := by unfold quantileIF rw [integral_div, integral_sub (integrable_const _) (integrable_cdfStat q₀), integral_const, probReal_univ, one_smul, integral_cdfStat, hcdf, sub_self, zero_div] -
quantileIF_sq_integrablelemma — The quantile influence function is square-integrable (it is bounded).Proof (Lean source)
@[fun_prop] lemma quantileIF_sq_integrable [IsProbabilityMeasure P] {τ q₀ f₀ : ℝ} : Integrable (fun z => (quantileIF τ q₀ f₀ z) ^ 2) P := by refine (integrable_const (((|τ| + 1) / |f₀|) ^ 2)).mono' ((measurable_quantileIF τ q₀ f₀).pow_const 2).aestronglyMeasurable ?_ filter_upwards with z have hc0 : 0 ≤ cdfStat q₀ z := cdfStat_nonneg q₀ z have hc1 : cdfStat q₀ z ≤ 1 := cdfStat_le_one q₀ z have hnum : |τ - cdfStat q₀ z| ≤ |τ| + 1 := by rw [abs_le] refine ⟨?_, ?_⟩ · have := neg_abs_le τ; linarith · have := le_abs_self τ; linarith have hbound : |quantileIF τ q₀ f₀ z| ≤ (|τ| + 1) / |f₀| := by unfold quantileIF rw [abs_div, div_eq_mul_inv, div_eq_mul_inv] exact mul_le_mul_of_nonneg_right hnum (inv_nonneg.mpr (abs_nonneg _)) rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] calc (quantileIF τ q₀ f₀ z) ^ 2 = |quantileIF τ q₀ f₀ z| ^ 2 := (sq_abs _).symm _ ≤ ((|τ| + 1) / |f₀|) ^ 2 := by gcongr -
quantileIF_variancelemma — Variance of the quantile influence function. Provided q₀ is the population τ-quantile, i.e. the population cdf satisfies $F(q_0)=\tau$, the second moment of the influence function $\psi_\tau$ under the population measure equals $\tau(1-\tau)/f_0^2$, the classical sample-quantile asymptotic variance.hypothesesconclusion∫ z, (quantileIF τ q₀ f₀ z) ^ 2 ∂P = τ * (1 - τ) / f₀ ^ 2Proof (Lean source)
lemma quantileIF_variance [IsProbabilityMeasure P] {τ q₀ f₀ : ℝ} (hcdf : cdf P q₀ = τ) : ∫ z, (quantileIF τ q₀ f₀ z) ^ 2 ∂P = τ * (1 - τ) / f₀ ^ 2 := by have hstat : Integrable (cdfStat q₀) P := integrable_cdfStat q₀ have hexpand : (fun z => (quantileIF τ q₀ f₀ z) ^ 2) = (fun z => (τ ^ 2 - 2 * τ * cdfStat q₀ z + cdfStat q₀ z) / f₀ ^ 2) := by funext z unfold quantileIF rw [div_pow] congr 1 rw [show (τ - cdfStat q₀ z) ^ 2 = τ ^ 2 - 2 * τ * cdfStat q₀ z + (cdfStat q₀ z) ^ 2 from by ring, cdfStat_sq] rw [hexpand, integral_div] have h1 : Integrable (fun z => τ ^ 2 - 2 * τ * cdfStat q₀ z) P := (integrable_const (τ ^ 2)).sub (hstat.const_mul (2 * τ)) have hinner : ∫ z, (τ ^ 2 - 2 * τ * cdfStat q₀ z + cdfStat q₀ z) ∂P = τ - τ ^ 2 := by rw [integral_add h1 hstat, integral_sub (integrable_const _) (hstat.const_mul (2 * τ)), integral_const_mul] simp only [integral_cdfStat, integral_const, probReal_univ, one_smul] rw [hcdf]; ring rw [hinner]; congr 1; ring
CdfConvergence 5 core · 12 supporting This module proves Pólya's theorem for real probability measures: weak convergence to a continuous distribution function gives uniform CDF convergence. ★ tendstoUniformly_cdf_of_tendsto★ tendsto_quantile_of_tendsto★ quantile_gaussianReal_zero
CDF and quantile convergence
This module proves Pólya's theorem for real probability measures: weak convergence to a
continuous distribution function gives uniform CDF convergence. It then derives convergence of
the existing lower generalized-inverse quantile, and identifies the quantile of every centered
nondegenerate Gaussian by the standard-normal probit.
Pólya's theorem. Given weak convergence of real probability measures to a law with a continuous cumulative distribution function, their CDFs converge uniformly on the real line.
Formal statement
Proof (Lean source)
Given two probability measures on the real line, their Kolmogorov CDF distance is the supremum of absolute CDF differences over all real thresholds.
Definition (Lean source)
Given a real-valued function and a reference point, strict increase at that point means every lower point has a smaller value and every higher point has a larger value.
Definition (Lean source)
Given weak convergence of real probability measures, an interior quantile level, a continuous limit CDF, and strict increase of that CDF at its lower quantile, the lower quantiles converge.
Formal statement
Proof (Lean source)
Given a positive Gaussian variance and an interior probability level, the centered Gaussian lower quantile is its standard deviation times the standard-normal probit.
Formal statement
Proof (Lean source)
12 supporting declarations (lemmas, instances)
-
measure_singleton_eq_zero_of_continuousAt_cdftheorem — Given a probability measure on the real line, if its cumulative distribution function is continuous at a threshold, the measure assigns zero probability to that threshold.hypothesesconclusionμ {t} = 0Proof (Lean source)
theorem measure_singleton_eq_zero_of_continuousAt_cdf (μ : Measure ℝ) [IsProbabilityMeasure μ] {t : ℝ} (hcont : ContinuousAt (cdf μ) t) : μ {t} = 0 := by rw [← measure_cdf μ, StieltjesFunction.measure_singleton, hcont.continuousWithinAt.leftLim_eq, sub_self, ENNReal.ofReal_zero] -
tendsto_cdf_at_of_tendstotheorem — Given weak convergence of real probability measures and continuity of the limit CDF at a threshold, the approximating CDF values converge at that threshold.hypothesesProof (Lean source)
theorem tendsto_cdf_at_of_tendsto {ι : Type*} {l : Filter ι} {νs : ι → ProbabilityMeasure ℝ} {ν : ProbabilityMeasure ℝ} (hν : Tendsto νs l (𝓝 ν)) {t : ℝ} (hcont : ContinuousAt (cdf (ν : Measure ℝ)) t) : Tendsto (fun i ↦ cdf (νs i : Measure ℝ) t) l (𝓝 (cdf (ν : Measure ℝ) t)) := by have hnull : ν (frontier (Iic t)) = 0 := by rw [frontier_Iic] exact (ProbabilityMeasure.null_iff_toMeasure_null ν {t}).2 (measure_singleton_eq_zero_of_continuousAt_cdf _ hcont) have h := ProbabilityMeasure.tendsto_measure_of_null_frontier_of_tendsto hν hnull simpa only [Function.comp_def, cdf_eq_real, ProbabilityMeasure.measureReal_eq_coe_coeFn] using ((NNReal.continuous_coe.tendsto (ν (Iic t))).comp h) -
tendstoUniformly_of_monotone_of_tendsto_attheorem — Given a family of monotone functions whose values stay between zero and one, a continuous monotone limit with limits zero and one at the two tails, and pointwise convergence to that limit, the convergence is uniform on the real line.hypothesesι :G :ℝ → ℝhF :∀ i, Monotone (F i)hF0 :∀ i x, 0 ≤ F i xhF1 :∀ i x, F i x ≤ 1hGmono :Monotone GhGcont :hpoint :∀ t, Tendsto (fun i ↦ F i t) l (𝓝 (G t))conclusionTendstoUniformly F G lProof (Lean source)
theorem tendstoUniformly_of_monotone_of_tendsto_at {ι : Type*} {l : Filter ι} {F : ι → ℝ → ℝ} {G : ℝ → ℝ} (hF : ∀ i, Monotone (F i)) (hF0 : ∀ i x, 0 ≤ F i x) (hF1 : ∀ i x, F i x ≤ 1) (hGmono : Monotone G) (hGcont : Continuous G) (hGbot : Tendsto G atBot (𝓝 0)) (hGtop : Tendsto G atTop (𝓝 1)) (hpoint : ∀ t, Tendsto (fun i ↦ F i t) l (𝓝 (G t))) : TendstoUniformly F G l := by exact tendstoUniformly_of_monotone_of_tendsto_at_of_bounds hF hF0 hF1 hGmono hGcont hGbot hGtop hpoint -
cdfKolmogorov_nonnegtheorem — Given two probability measures on the real line, their Kolmogorov CDF distance is nonnegative.Proof (Lean source)
theorem cdfKolmogorov_nonneg (μ ν : ProbabilityMeasure ℝ) : 0 ≤ cdfKolmogorov μ ν := by have hb : BddAbove (range fun t : ℝ ↦ |cdf (μ : Measure ℝ) t - cdf (ν : Measure ℝ) t|) := by refine ⟨1, ?_⟩ rintro _ ⟨t, rfl⟩ rw [abs_le] constructor <;> linarith [cdf_nonneg (μ : Measure ℝ) t, cdf_le_one (μ : Measure ℝ) t, cdf_nonneg (ν : Measure ℝ) t, cdf_le_one (ν : Measure ℝ) t] exact (abs_nonneg (cdf (μ : Measure ℝ) 0 - cdf (ν : Measure ℝ) 0)).trans (le_ciSup hb 0) -
cdfKolmogorov_le_onetheorem — Given two probability measures on the real line, their Kolmogorov CDF distance is at most one.Proof (Lean source)
theorem cdfKolmogorov_le_one (μ ν : ProbabilityMeasure ℝ) : cdfKolmogorov μ ν ≤ 1 := by refine ciSup_le fun t ↦ ?_ rw [abs_le] constructor <;> linarith [cdf_nonneg (μ : Measure ℝ) t, cdf_le_one (μ : Measure ℝ) t, cdf_nonneg (ν : Measure ℝ) t, cdf_le_one (ν : Measure ℝ) t] -
tendsto_cdfKolmogorov_of_tendstotheorem — Given weak convergence of each of two families of real probability measures to the same law whose CDF is continuous, their Kolmogorov CDF distance converges to zero.hypothesesconclusionTendsto (fun i ↦ cdfKolmogorov (νs i) (νs' i)) l (𝓝 0)Proof (Lean source)
theorem tendsto_cdfKolmogorov_of_tendsto {ι : Type*} {l : Filter ι} {νs νs' : ι → ProbabilityMeasure ℝ} {ν : ProbabilityMeasure ℝ} (hν : Tendsto νs l (𝓝 ν)) (hν' : Tendsto νs' l (𝓝 ν)) (hcont : Continuous (cdf (ν : Measure ℝ))) : Tendsto (fun i ↦ cdfKolmogorov (νs i) (νs' i)) l (𝓝 0) := by rw [Metric.tendsto_nhds] intro ε hε let η := ε / 4 have hη : 0 < η := div_pos hε (by norm_num) have h4η : 4 * η = ε := by dsimp [η]; ring have hu := Metric.tendstoUniformly_iff.1 (tendstoUniformly_cdf_of_tendsto hν hcont) have hu' := Metric.tendstoUniformly_iff.1 (tendstoUniformly_cdf_of_tendsto hν' hcont) filter_upwards [hu η hη, hu' η hη] with i hi hi' have hbound : cdfKolmogorov (νs i) (νs' i) ≤ 2 * η := by refine ciSup_le fun t ↦ ?_ calc |cdf (νs i : Measure ℝ) t - cdf (νs' i : Measure ℝ) t| = dist (cdf (νs i : Measure ℝ) t) (cdf (νs' i : Measure ℝ) t) := (Real.dist_eq _ _).symm _ ≤ dist (cdf (νs i : Measure ℝ) t) (cdf (ν : Measure ℝ) t) + dist (cdf (ν : Measure ℝ) t) (cdf (νs' i : Measure ℝ) t) := dist_triangle _ _ _ _ = dist (cdf (ν : Measure ℝ) t) (cdf (νs i : Measure ℝ) t) + dist (cdf (ν : Measure ℝ) t) (cdf (νs' i : Measure ℝ) t) := by rw [dist_comm (cdf (νs i : Measure ℝ) t)] _ ≤ 2 * η := by linarith [hi t, hi' t] rw [Real.dist_eq, sub_zero, abs_of_nonneg (cdfKolmogorov_nonneg _ _)] linarith -
cdf_quantile_eqtheorem — Given a real probability measure, an interior quantile level, and continuity of its CDF at the lower quantile, the CDF at that quantile equals the requested level.hypothesesμ :β :ℝhβ0 :0 < βhβ1 :β < 1hcont :Proof (Lean source)
theorem cdf_quantile_eq (μ : Measure ℝ) [IsProbabilityMeasure μ] {β : ℝ} (hβ0 : 0 < β) (hβ1 : β < 1) (hcont : ContinuousAt (cdf μ) (quantile μ β)) : cdf μ (quantile μ β) = β := by apply le_antisymm · by_contra hle have hβq : β < cdf μ (quantile μ β) := lt_of_not_ge hle have hev : ∀ᶠ x in 𝓝 (quantile μ β), β < cdf μ x := hcont.eventually_const_lt hβq obtain ⟨x, hxq, hβx⟩ := ((frequently_lt_nhds (quantile μ β)).and_eventually hev).exists have hqx : quantile μ β ≤ x := (quantile_le_iff hβ0 hβ1).2 hβx.le exact (not_le_of_gt hxq) hqx · exact le_cdf_quantile hβ1 -
eventually_quantile_mem_of_brackettheorem — Given a family of real probability measures, an interior quantile level, a positive radius, and eventual CDF brackets below and above that level, the corresponding lower quantiles eventually lie in the closed ball with that radius.hypotheses∀ i, IsProbabilityMeasure (μs i)β q ε :ℝhβ0 :0 < βhβ1 :β < 1hε :0 < εhleft :∀ᶠ i in l, cdf (μs i) (q - ε) < βhright :∀ᶠ i in l, β < cdf (μs i) (q + ε)conclusion∀ᶠ i in l, quantile (μs i) β ∈ closedBall q εProof (Lean source)
theorem eventually_quantile_mem_of_bracket {ι : Type*} {l : Filter ι} {μs : ι → Measure ℝ} [∀ i, IsProbabilityMeasure (μs i)] {β q ε : ℝ} (hβ0 : 0 < β) (hβ1 : β < 1) (hε : 0 < ε) (hleft : ∀ᶠ i in l, cdf (μs i) (q - ε) < β) (hright : ∀ᶠ i in l, β < cdf (μs i) (q + ε)) : ∀ᶠ i in l, quantile (μs i) β ∈ closedBall q ε := by filter_upwards [hleft, hright] with i hi_left hi_right have hεnonneg : 0 ≤ ε := hε.le have hlo : q - ε < quantile (μs i) β := by by_contra h have hβleft : β ≤ cdf (μs i) (q - ε) := (quantile_le_iff hβ0 hβ1).1 (le_of_not_gt h) exact (not_le_of_gt hi_left) hβleft have hhi : quantile (μs i) β ≤ q + ε := (quantile_le_iff hβ0 hβ1).2 hi_right.le rw [Metric.mem_closedBall, Real.dist_eq, abs_le] constructor <;> linarith [hεnonneg] -
tendsto_quantile_of_tendstoUniformlytheorem — Given an interior quantile level, uniform convergence of approximating CDFs, continuity of the limiting CDF at its lower quantile, and strict increase there, the lower quantiles converge to the limiting lower quantile.hypothesesProof (Lean source)
theorem tendsto_quantile_of_tendstoUniformly {ι : Type*} {l : Filter ι} {μs : ι → Measure ℝ} [∀ i, IsProbabilityMeasure (μs i)] {μ : Measure ℝ} [IsProbabilityMeasure μ] {β : ℝ} (hβ0 : 0 < β) (hβ1 : β < 1) (hunif : TendstoUniformly (fun i ↦ cdf (μs i)) (cdf μ) l) (hcont : ContinuousAt (cdf μ) (quantile μ β)) (hstrict : StrictlyIncreasingAt (cdf μ) (quantile μ β)) : Tendsto (fun i ↦ quantile (μs i) β) l (𝓝 (quantile μ β)) := by rw [Metric.tendsto_nhds] intro ε hε have hcdf : cdf μ (quantile μ β) = β := cdf_quantile_eq μ hβ0 hβ1 hcont have hlimit_left : cdf μ (quantile μ β - ε / 2) < β := by have h := hstrict.1 (quantile μ β - ε / 2) (by linarith) simpa only [hcdf] using h have hlimit_right : β < cdf μ (quantile μ β + ε / 2) := by have h := hstrict.2 (quantile μ β + ε / 2) (by linarith) simpa only [hcdf] using h have hu := Metric.tendstoUniformly_iff.1 hunif have hleft : ∀ᶠ i in l, cdf (μs i) (quantile μ β - ε / 2) < β := by have hgap : 0 < β - cdf μ (quantile μ β - ε / 2) := sub_pos.mpr hlimit_left filter_upwards [hu _ hgap] with i hi have hdist := hi (quantile μ β - ε / 2) rw [Real.dist_eq, abs_lt] at hdist linarith have hright : ∀ᶠ i in l, β < cdf (μs i) (quantile μ β + ε / 2) := by have hgap : 0 < cdf μ (quantile μ β + ε / 2) - β := sub_pos.mpr hlimit_right filter_upwards [hu _ hgap] with i hi have hdist := hi (quantile μ β + ε / 2) rw [Real.dist_eq, abs_lt] at hdist linarith have hbracket := eventually_quantile_mem_of_bracket (μs := μs) hβ0 hβ1 (half_pos hε) hleft hright filter_upwards [hbracket] with i hi rw [Metric.mem_closedBall] at hi linarith -
cdf_gaussianReal_zerotheorem — Given a positive Gaussian variance and a real threshold, the CDF of the centered Gaussian is the standard-normal CDF at the threshold divided by its standard deviation.hypothesesconclusionProof (Lean source)
theorem cdf_gaussianReal_zero {v : NNReal} (hv : 0 < v) (x : ℝ) : cdf (gaussianReal 0 v) x = stdNormalCDF (x / sqrt (v : ℝ)) := by have hvR : 0 < (v : ℝ) := by exact_mod_cast hv have hs : 0 < sqrt (v : ℝ) := Real.sqrt_pos.2 hvR rw [cdf_eq_real, gaussianReal_eq_map_std] rw [MeasureTheory.map_measureReal_apply (f := fun z : ℝ => sqrt (v : ℝ) * z + 0) (continuous_const.mul continuous_id |>.add continuous_const).measurable measurableSet_Iic] rw [show (fun z : ℝ => sqrt (v : ℝ) * z + 0) ⁻¹' Iic x = Iic (x / sqrt (v : ℝ)) by ext z simp only [Set.mem_preimage, Set.mem_Iic, add_zero] simpa only [mul_comm] using (le_div_iff₀ hs : z ≤ x / sqrt (v : ℝ) ↔ z * sqrt (v : ℝ) ≤ x).symm] rw [← cdf_eq_real] rfl -
continuous_cdf_gaussianReal_zerotheorem — Given a positive Gaussian variance, the CDF of the centered Gaussian is continuous.Proof (Lean source)
theorem continuous_cdf_gaussianReal_zero {v : NNReal} (hv : 0 < v) : Continuous (cdf (gaussianReal 0 v)) := by rw [show cdf (gaussianReal 0 v) = stdNormalCDF ∘ (fun x : ℝ => x / sqrt (v : ℝ)) by funext x exact cdf_gaussianReal_zero hv x] exact Causalean.Mathlib.stdNormalCDF_continuous.comp (continuous_id.div_const _) -
strictMono_cdf_gaussianReal_zerotheorem — Given a positive Gaussian variance, the CDF of the centered Gaussian is strictly increasing.Proof (Lean source)
theorem strictMono_cdf_gaussianReal_zero {v : NNReal} (hv : 0 < v) : StrictMono (cdf (gaussianReal 0 v)) := by have hvR : 0 < (v : ℝ) := by exact_mod_cast hv have hs : 0 < sqrt (v : ℝ) := Real.sqrt_pos.2 hvR rw [show cdf (gaussianReal 0 v) = stdNormalCDF ∘ (fun x : ℝ => x / sqrt (v : ℝ)) by funext x exact cdf_gaussianReal_zero hv x] exact Causalean.Mathlib.stdNormalCDF_strictMono.comp (strictMono_id.div_const hs)
FiniteMassTransport 2 core · 5 supporting This module extends the compact-support probability quantile/CDF identity to positive finite measures normalized to probability laws, with an explicit interval-length penalty for unequal total masses. ★ finite_mass_quantile_transport_le★ finite_mass_quantile_transport_eq_of_mass_eq
Unequal finite-mass quantile transport
This module extends the compact-support probability quantile/CDF identity to positive finite measures normalized to probability laws, with an explicit interval-length penalty for unequal total masses.
Two finite measures with an ordered common compact interval, positive masses, and concentration on that interval have smaller-mass-scaled normalized quantile cost bounded by raw CDF distance plus interval length times their mass difference.
Formal statement
Proof (Lean source)
Two finite measures with an ordered common compact interval, equal positive mass, and concentration on that interval have a mass-scaled normalized quantile cost equal to their raw CDF distance.
Formal statement
Proof (Lean source)
5 supporting declarations (lemmas, instances)
-
min_mul_abs_div_sub_div_lelemma — Positive total masses and their nonnegative bounded cumulative mass values give a normalized discrepancy times the smaller mass bounded by the raw discrepancy plus the mass mismatch.hypothesesp q x y :ℝhp :0 < phq :0 < qhx :0 ≤ xhxp :x ≤ phy :0 ≤ yhyq :y ≤ qconclusionmin p q * |x / p - y / q| ≤ |x - y| + |p - q|Proof (Lean source)
lemma min_mul_abs_div_sub_div_le {p q x y : ℝ} (hp : 0 < p) (hq : 0 < q) (hx : 0 ≤ x) (hxp : x ≤ p) (hy : 0 ≤ y) (hyq : y ≤ q) : min p q * |x / p - y / q| ≤ |x - y| + |p - q| := by /- Split on `p ≤ q`. In that branch rewrite `p*(x/p-y/q) = (x-y)+(q-p)*(y/q)` and use `0 ≤ y/q ≤ 1`. The other branch is symmetric. -/ have hp0 : p ≠ 0 := ne_of_gt hp have hq0 : q ≠ 0 := ne_of_gt hq have hydiv : 0 ≤ y / q ∧ y / q ≤ 1 := ⟨div_nonneg hy hq.le, (div_le_one hq).2 hyq⟩ have hxdiv : 0 ≤ x / p ∧ x / p ≤ 1 := ⟨div_nonneg hx hp.le, (div_le_one hp).2 hxp⟩ rcases le_total p q with hpq | hqp · rw [min_eq_left hpq] have hid : p * (x / p - y / q) = (x - y) + (q - p) * (y / q) := by field_simp ring calc p * |x / p - y / q| = |p * (x / p - y / q)| := by rw [abs_mul, abs_of_pos hp] _ = |(x - y) + (q - p) * (y / q)| := by rw [hid] _ ≤ |x - y| + |(q - p) * (y / q)| := abs_add_le _ _ _ ≤ |x - y| + |p - q| := by have h : |(q - p) * (y / q)| ≤ |p - q| := by rw [abs_mul, abs_of_nonneg (sub_nonneg.mpr hpq), abs_of_nonneg hydiv.1, abs_sub_comm] simpa [abs_of_nonneg (sub_nonneg.mpr hpq)] using mul_le_of_le_one_right (sub_nonneg.mpr hpq) hydiv.2 linarith · rw [min_eq_right hqp] have hid : q * (x / p - y / q) = (x - y) - (p - q) * (x / p) := by field_simp ring calc q * |x / p - y / q| = |q * (x / p - y / q)| := by rw [abs_mul, abs_of_pos hq] _ = |(x - y) - (p - q) * (x / p)| := by rw [hid] _ ≤ |x - y| + |(p - q) * (x / p)| := by simpa [sub_eq_add_neg] using (abs_add_le (x - y) (-((p - q) * (x / p)))) _ ≤ |x - y| + |p - q| := by have h : |(p - q) * (x / p)| ≤ |p - q| := by rw [abs_mul, abs_of_nonneg (sub_nonneg.mpr hqp), abs_of_nonneg hxdiv.1] simpa [abs_of_nonneg (sub_nonneg.mpr hqp)] using mul_le_of_le_one_right (sub_nonneg.mpr hqp) hxdiv.2 linarith -
min_mul_integral_abs_div_sub_div_lelemma — An ordered interval, positive masses, bounded cumulative functions, and integrability of both discrepancies give the integrated normalized discrepancy bound with a mass-mismatch penalty.hypothesesa b p q :ℝF G :ℝ → ℝhab :a ≤ bhp :0 < phq :0 < qhF :∀ t ∈ Icc a b, 0 ≤ F t ∧ F t ≤ phG :∀ t ∈ Icc a b, 0 ≤ G t ∧ G t ≤ qhnorm :IntervalIntegrable (fun t => |F t / p - G t / q|) volume a bhraw :IntervalIntegrable (fun t => |F t - G t|) volume a bconclusionmin p q * (∫ t in a..b, |F t / p - G t / q|)≤ (∫ t in a..b, |F t - G t|) + (b - a) * |p - q|Proof (Lean source)
lemma min_mul_integral_abs_div_sub_div_le {a b p q : ℝ} {F G : ℝ → ℝ} (hab : a ≤ b) (hp : 0 < p) (hq : 0 < q) (hF : ∀ t ∈ Icc a b, 0 ≤ F t ∧ F t ≤ p) (hG : ∀ t ∈ Icc a b, 0 ≤ G t ∧ G t ≤ q) (hnorm : IntervalIntegrable (fun t => |F t / p - G t / q|) volume a b) (hraw : IntervalIntegrable (fun t => |F t - G t|) volume a b) : min p q * (∫ t in a..b, |F t / p - G t / q|) ≤ (∫ t in a..b, |F t - G t|) + (b - a) * |p - q| := by /- Integrate the preceding pointwise bound with `integral_mono_on`; `intervalIntegral.integral_const` gives exactly `(b-a)*|p-q|`. -/ have hconst : IntervalIntegrable (fun _ : ℝ => |p - q|) volume a b := intervalIntegrable_const have hleft : IntervalIntegrable (fun t => min p q * |F t / p - G t / q|) volume a b := hnorm.const_mul _ have hright : IntervalIntegrable (fun t => |F t - G t| + |p - q|) volume a b := hraw.add hconst have hmono := intervalIntegral.integral_mono_on hab hleft hright (fun t ht => min_mul_abs_div_sub_div_le hp hq (hF t ht).1 (hF t ht).2 (hG t ht).1 (hG t ht).2) rw [intervalIntegral.integral_const_mul, intervalIntegral.integral_add hraw hconst, intervalIntegral.integral_const] at hmono simpa only [smul_eq_mul] using hmono -
cdf_normalize_eq_divlemma — A finite measure with positive total mass has a normalized CDF equal to raw cumulative mass divided by total mass.hypothesesProof (Lean source)
lemma cdf_normalize_eq_div (μ : FiniteMeasure ℝ) (hp : 0 < (μ.mass : ℝ)) (t : ℝ) : cdf (μ.normalize : Measure ℝ) t = ((μ : Measure ℝ) (Iic t)).toReal / (μ.mass : ℝ) := by /- Use `cdf_eq_real` and `FiniteMeasure.normalize_eq_of_nonzero`, then convert the finite-measure values from `ℝ≥0` to `ℝ`. -/ have hne : μ ≠ 0 := by intro h simp [h] at hp rw [ProbabilityTheory.cdf_eq_real] rw [Measure.real, μ.toMeasure_normalize_eq_of_nonzero hne, Measure.smul_apply] change (((μ.mass⁻¹ : NNReal) : ENNReal) * (μ : Measure ℝ) (Iic t)).toReal = _ rw [ENNReal.toReal_mul] simp [inv_mul_eq_div] -
normalize_support_Icclemma — A finite measure with positive total mass concentrated on a closed interval has a normalized probability law concentrated on the same interval.hypothesesconclusion(μ.normalize : Measure ℝ) (Icc a b)ᶜ = 0Proof (Lean source)
lemma normalize_support_Icc (μ : FiniteMeasure ℝ) {a b : ℝ} (hp : 0 < (μ.mass : ℝ)) (hμ : (μ : Measure ℝ) (Icc a b)ᶜ = 0) : (μ.normalize : Measure ℝ) (Icc a b)ᶜ = 0 := by /- Apply `FiniteMeasure.normalize_eq_of_nonzero` to the complement. -/ have hne : μ ≠ 0 := by intro h simp [h] at hp rw [μ.toMeasure_normalize_eq_of_nonzero hne, Measure.smul_apply] simp [hμ] -
intervalIntegrable_abs_raw_cdf_sublemma — Two finite measures have an integrable raw cumulative-mass difference on the given finite interval.hypothesesμ ν :a b :ℝProof (Lean source)
lemma intervalIntegrable_abs_raw_cdf_sub (μ ν : FiniteMeasure ℝ) (a b : ℝ) : IntervalIntegrable (fun t : ℝ => |((μ : Measure ℝ) (Iic t)).toReal - ((ν : Measure ℝ) (Iic t)).toReal|) volume a b := by /- Each raw cumulative mass is monotone and bounded by the finite total mass; monotone real functions are measurable and bounded on `Icc a b`. -/ have hμ : Monotone (fun t : ℝ => ((μ : Measure ℝ) (Iic t)).toReal) := by intro s t hst exact ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono (Iic_subset_Iic.mpr hst)) have hν : Monotone (fun t : ℝ => ((ν : Measure ℝ) (Iic t)).toReal) := by intro s t hst exact ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono (Iic_subset_Iic.mpr hst)) exact (hμ.intervalIntegrable.sub hν.intervalIntegrable).abs
Pushforward 2 core · 8 supporting This module proves that applying a measurable Lipschitz transformation to two compactly supported real probability laws cannot increase their shared-uniform quantile transport cost by more than the Lipschitz factor. ★ quantile_pushforward_lipschitzOn★ quantile_pushforward_lipschitz
Lipschitz pushforwards of one-dimensional quantile transport
This module proves that applying a measurable Lipschitz transformation to two compactly supported real probability laws cannot increase their shared-uniform quantile transport cost by more than the Lipschitz factor. The proof works through arbitrary couplings, so it applies unchanged to atomic laws and to decreasing transformations.
Two probability laws concentrated on an ordered common closed interval, and a measurable transformation with a Lipschitz factor that is nonnegative and controls the transformation on that interval, have image quantile transport cost at most that factor times their source cost. This conclusion allows atoms and decreasing transformations.
Formal statement
Proof (Lean source)
Two probability laws concentrated on an ordered common closed interval, and a measurable globally Lipschitz transformation, have image quantile transport cost at most the global Lipschitz factor times their source cost.
Formal statement
Proof (Lean source)
8 supporting declarations (lemmas, instances)
-
coupling_abs_cost_integrablelemma — Two probability laws concentrated on the common closed interval from a to b and a coupling of them have an integrable absolute coordinate difference.hypothesesconclusionIntegrable (fun z : ℝ × ℝ => |z.1 - z.2|) πProof (Lean source)
lemma coupling_abs_cost_integrable (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {a b : ℝ} (hμ : μ (Icc a b)ᶜ = 0) (hν : ν (Icc a b)ᶜ = 0) {π : Measure (ℝ × ℝ)} (hπ : IsCoupling π μ ν) : Integrable (fun z : ℝ × ℝ => |z.1 - z.2|) π := by letI : IsProbabilityMeasure π := hπ.isProbabilityMeasure have h₁ : ∀ᵐ z ∂π, z.1 ∈ Icc a b := by have hh : ∀ᵐ x ∂μ, x ∈ Icc a b := by rw [ae_iff] exact hμ rw [← hπ.map_fst] at hh exact (ae_map_iff measurable_fst.aemeasurable measurableSet_Icc).mp hh have h₂ : ∀ᵐ z ∂π, z.2 ∈ Icc a b := by have hh : ∀ᵐ x ∂ν, x ∈ Icc a b := by rw [ae_iff] exact hν rw [← hπ.map_snd] at hh exact (ae_map_iff measurable_snd.aemeasurable measurableSet_Icc).mp hh apply Integrable.of_bound (by fun_prop) (b - a) filter_upwards [h₁, h₂] with z hz₁ hz₂ rw [Real.norm_eq_abs, abs_abs] exact abs_le.mpr ⟨by linarith [hz₁.1, hz₂.2], by linarith [hz₁.2, hz₂.1]⟩ -
cdf_distance_le_threshold_disagreementlemma — Two probability laws, a coupling of them, and a threshold have a CDF difference at that threshold bounded by the coupling's expected lower-ray-indicator disagreement.hypothesesProof (Lean source)
lemma cdf_distance_le_threshold_disagreement (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {π : Measure (ℝ × ℝ)} (hπ : IsCoupling π μ ν) (t : ℝ) : |cdf μ t - cdf ν t| ≤ ∫ z : ℝ × ℝ, |(if z.1 ≤ t then (1 : ℝ) else 0) - (if z.2 ≤ t then 1 else 0)| ∂π := by letI : IsProbabilityMeasure π := hπ.isProbabilityMeasure have hind (ρ : Measure ℝ) [IsProbabilityMeasure ρ] : (∫ x : ℝ, (if x ≤ t then (1 : ℝ) else 0) ∂ρ) = cdf ρ t := by have heq : (fun x : ℝ => if x ≤ t then (1 : ℝ) else 0) = (Iic t).indicator (fun _ => (1 : ℝ)) := by funext x simp [indicator, Set.mem_Iic] rw [heq, integral_indicator measurableSet_Iic, setIntegral_const, cdf_eq_real] simp [measureReal_def] have hm : Measurable (fun x : ℝ => if x ≤ t then (1 : ℝ) else 0) := by convert (measurable_const.indicator measurableSet_Iic : Measurable ((Iic t).indicator (fun _ : ℝ => (1 : ℝ)))) using 1 funext x by_cases hx : x ≤ t <;> simp [indicator, hx] have h₁ : Integrable (fun z : ℝ × ℝ => if z.1 ≤ t then (1 : ℝ) else 0) π := by apply Integrable.of_bound (hm.comp measurable_fst).aestronglyMeasurable 1 filter_upwards with z change ‖if z.1 ≤ t then (1 : ℝ) else 0‖ ≤ 1 split_ifs <;> norm_num have h₂ : Integrable (fun z : ℝ × ℝ => if z.2 ≤ t then (1 : ℝ) else 0) π := by apply Integrable.of_bound (hm.comp measurable_snd).aestronglyMeasurable 1 filter_upwards with z change ‖if z.2 ≤ t then (1 : ℝ) else 0‖ ≤ 1 split_ifs <;> norm_num have hμ' : (∫ z : ℝ × ℝ, (if z.1 ≤ t then (1 : ℝ) else 0) ∂π) = cdf μ t := by calc _ = ∫ x : ℝ, (if x ≤ t then (1 : ℝ) else 0) ∂μ := by rw [← hπ.map_fst, integral_map measurable_fst.aemeasurable hm.aestronglyMeasurable] _ = cdf μ t := hind μ have hν' : (∫ z : ℝ × ℝ, (if z.2 ≤ t then (1 : ℝ) else 0) ∂π) = cdf ν t := by calc _ = ∫ x : ℝ, (if x ≤ t then (1 : ℝ) else 0) ∂ν := by rw [← hπ.map_snd, integral_map measurable_snd.aemeasurable hm.aestronglyMeasurable] _ = cdf ν t := hind ν rw [← hμ', ← hν', ← integral_sub h₁ h₂] exact abs_integral_le_integral_abs -
coupling_indicator_integral_eq_costlemma — Two probability laws concentrated on the ordered common closed interval from a to b and a coupling have integrated lower-ray disagreement equal to expected absolute coordinate distance.hypothesesμ ν :a b :ℝhab :a ≤ bhμ :μ (Icc a b)ᶜ = 0hν :ν (Icc a b)ᶜ = 0π :Measure (ℝ × ℝ)hπ :IsCoupling π μ νconclusion(∫ t in a..b, ∫ z : ℝ × ℝ, |(if z.1 ≤ t then (1 : ℝ) else 0) - (if z.2 ≤ t then 1 else 0)| ∂π)= ∫ z : ℝ × ℝ, |z.1 - z.2| ∂πProof (Lean source)
lemma coupling_indicator_integral_eq_cost (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {a b : ℝ} (hab : a ≤ b) (hμ : μ (Icc a b)ᶜ = 0) (hν : ν (Icc a b)ᶜ = 0) {π : Measure (ℝ × ℝ)} (hπ : IsCoupling π μ ν) : (∫ t in a..b, ∫ z : ℝ × ℝ, |(if z.1 ≤ t then (1 : ℝ) else 0) - (if z.2 ≤ t then 1 else 0)| ∂π) = ∫ z : ℝ × ℝ, |z.1 - z.2| ∂π := by letI : IsProbabilityMeasure π := hπ.isProbabilityMeasure let ρ : Measure ℝ := volume.restrict (Ioc a b) haveI : IsFiniteMeasure ρ := by dsimp [ρ] exact isFiniteMeasure_restrict.mpr measure_Ioc_lt_top.ne let k : ℝ → (ℝ × ℝ) → ℝ := fun t z => |(if z.1 ≤ t then (1 : ℝ) else 0) - (if z.2 ≤ t then 1 else 0)| have hk : Integrable (fun p : ℝ × (ℝ × ℝ) => k p.1 p.2) (ρ.prod π) := by have h₁ : Measurable (fun p : ℝ × (ℝ × ℝ) => if p.2.1 ≤ p.1 then (1 : ℝ) else 0) := by exact measurable_const.ite (measurableSet_le measurable_snd.fst measurable_fst) measurable_const have h₂ : Measurable (fun p : ℝ × (ℝ × ℝ) => if p.2.2 ≤ p.1 then (1 : ℝ) else 0) := by exact measurable_const.ite (measurableSet_le measurable_snd.snd measurable_fst) measurable_const have hm : Measurable (fun p : ℝ × (ℝ × ℝ) => k p.1 p.2) := by simpa [k, Real.norm_eq_abs] using (h₁.sub h₂).norm apply Integrable.of_bound hm.aestronglyMeasurable 1 filter_upwards with p change ‖|(if p.2.1 ≤ p.1 then (1 : ℝ) else 0) - (if p.2.2 ≤ p.1 then 1 else 0)|‖ ≤ 1 split_ifs <;> norm_num have hswap : (∫ t in a..b, ∫ z : ℝ × ℝ, k t z ∂π) = ∫ z : ℝ × ℝ, (∫ t in a..b, k t z) ∂π := by simp_rw [intervalIntegral.integral_of_le hab] simpa only [ρ] using (integral_integral_swap (f := k) hk) have h₁ : ∀ᵐ z ∂π, z.1 ∈ Icc a b := by have hh : ∀ᵐ x ∂μ, x ∈ Icc a b := by rw [ae_iff] exact hμ rw [← hπ.map_fst] at hh exact (ae_map_iff measurable_fst.aemeasurable measurableSet_Icc).mp hh have h₂ : ∀ᵐ z ∂π, z.2 ∈ Icc a b := by have hh : ∀ᵐ x ∂ν, x ∈ Icc a b := by rw [ae_iff] exact hν rw [← hπ.map_snd] at hh exact (ae_map_iff measurable_snd.aemeasurable measurableSet_Icc).mp hh change (∫ t in a..b, ∫ z : ℝ × ℝ, k t z ∂π) = ∫ z : ℝ × ℝ, |z.1 - z.2| ∂π rw [hswap] apply integral_congr_ae filter_upwards [h₁, h₂] with z hz₁ hz₂ exact (abs_sub_eq_integral_Icc_indicator hz₁ hz₂).symm -
cdf_distance_le_coupling_costtheorem — Two probability laws concentrated on the ordered common closed interval from a to b and a coupling have integrated CDF distance no larger than the coupling's expected absolute coordinate distance.hypothesesμ ν :a b :ℝhab :a ≤ bhμ :μ (Icc a b)ᶜ = 0hν :ν (Icc a b)ᶜ = 0π :Measure (ℝ × ℝ)hπ :IsCoupling π μ νProof (Lean source)
theorem cdf_distance_le_coupling_cost (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {a b : ℝ} (hab : a ≤ b) (hμ : μ (Icc a b)ᶜ = 0) (hν : ν (Icc a b)ᶜ = 0) {π : Measure (ℝ × ℝ)} (hπ : IsCoupling π μ ν) : (∫ t in a..b, |cdf μ t - cdf ν t|) ≤ ∫ z : ℝ × ℝ, |z.1 - z.2| ∂π := by letI : IsProbabilityMeasure π := hπ.isProbabilityMeasure let ρ : Measure ℝ := volume.restrict (Ioc a b) haveI : IsFiniteMeasure ρ := by dsimp [ρ] exact isFiniteMeasure_restrict.mpr measure_Ioc_lt_top.ne let k : ℝ → (ℝ × ℝ) → ℝ := fun t z => |(if z.1 ≤ t then (1 : ℝ) else 0) - (if z.2 ≤ t then 1 else 0)| have hk : Integrable (fun p : ℝ × (ℝ × ℝ) => k p.1 p.2) (ρ.prod π) := by have h₁ : Measurable (fun p : ℝ × (ℝ × ℝ) => if p.2.1 ≤ p.1 then (1 : ℝ) else 0) := by exact measurable_const.ite (measurableSet_le measurable_snd.fst measurable_fst) measurable_const have h₂ : Measurable (fun p : ℝ × (ℝ × ℝ) => if p.2.2 ≤ p.1 then (1 : ℝ) else 0) := by exact measurable_const.ite (measurableSet_le measurable_snd.snd measurable_fst) measurable_const have hm : Measurable (fun p : ℝ × (ℝ × ℝ) => k p.1 p.2) := by simpa [k, Real.norm_eq_abs] using (h₁.sub h₂).norm apply Integrable.of_bound hm.aestronglyMeasurable 1 filter_upwards with p change ‖|(if p.2.1 ≤ p.1 then (1 : ℝ) else 0) - (if p.2.2 ≤ p.1 then 1 else 0)|‖ ≤ 1 split_ifs <;> norm_num have hg : IntervalIntegrable (fun t : ℝ => ∫ z : ℝ × ℝ, k t z ∂π) volume a b := by apply (intervalIntegrable_iff_integrableOn_Ioc_of_le hab).2 change Integrable (fun t : ℝ => ∫ z : ℝ × ℝ, k t z ∂π) ρ exact hk.integral_prod_left calc (∫ t in a..b, |cdf μ t - cdf ν t|) ≤ ∫ t in a..b, ∫ z : ℝ × ℝ, k t z ∂π := by apply intervalIntegral.integral_mono hab (intervalIntegrable_abs_cdf_sub μ ν a b) hg intro t exact cdf_distance_le_threshold_disagreement μ ν hπ t _ = ∫ z : ℝ × ℝ, |z.1 - z.2| ∂π := coupling_indicator_integral_eq_cost μ ν hab hμ hν hπ -
quantile_cost_le_coupling_costtheorem — Two probability laws concentrated on the ordered common closed interval from a to b and a coupling have shared-uniform quantile cost no larger than the coupling's expected absolute coordinate distance.hypothesesμ ν :a b :ℝhab :a ≤ bhμ :μ (Icc a b)ᶜ = 0hν :ν (Icc a b)ᶜ = 0π :Measure (ℝ × ℝ)hπ :IsCoupling π μ νProof (Lean source)
theorem quantile_cost_le_coupling_cost (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {a b : ℝ} (hab : a ≤ b) (hμ : μ (Icc a b)ᶜ = 0) (hν : ν (Icc a b)ᶜ = 0) {π : Measure (ℝ × ℝ)} (hπ : IsCoupling π μ ν) : (∫ u in (0 : ℝ)..1, |quantile μ u - quantile ν u|) ≤ ∫ z : ℝ × ℝ, |z.1 - z.2| ∂π := by rw [quantile_transport_eq_cdf_distance μ ν hab hμ hν] exact cdf_distance_le_coupling_cost μ ν hab hμ hν hπ -
map_pair_isCouplinglemma — A measurable transformation sends a coupling of two real laws to a coupling of their transformed laws by acting on both coordinates.hypothesesconclusionIsCoupling (π.map (fun z : ℝ × ℝ => (f z.1, f z.2))) (μ.map f) (ν.map f)Proof (Lean source)
lemma map_pair_isCoupling (μ ν : Measure ℝ) (f : ℝ → ℝ) (hf : Measurable f) {π : Measure (ℝ × ℝ)} (hπ : IsCoupling π μ ν) : IsCoupling (π.map (fun z : ℝ × ℝ => (f z.1, f z.2))) (μ.map f) (ν.map f) := by letI : IsProbabilityMeasure π := hπ.isProbabilityMeasure have hp : Measurable (fun z : ℝ × ℝ => (f z.1, f z.2)) := (hf.comp measurable_fst).prodMk (hf.comp measurable_snd) refine ⟨Measure.isProbabilityMeasure_map hp.aemeasurable, ?_, ?_⟩ · calc (π.map (fun z : ℝ × ℝ => (f z.1, f z.2))).map fst = π.map (f ∘ fst) := by rw [Measure.map_map measurable_fst hp]; rfl _ = μ.map f := by rw [← hπ.map_fst, Measure.map_map hf measurable_fst] · calc (π.map (fun z : ℝ × ℝ => (f z.1, f z.2))).map snd = π.map (f ∘ snd) := by rw [Measure.map_map measurable_snd hp]; rfl _ = ν.map f := by rw [← hπ.map_snd, Measure.map_map hf measurable_snd] -
map_supported_in_lipschitz_rangelemma — A law concentrated on the ordered interval from a to b, mapped by a measurable transformation with a Lipschitz factor that is nonnegative and controls the transformation on that interval, is concentrated on the corresponding bounded image interval.hypothesesμ :Measure ℝa b L :ℝhab :a ≤ bhμ :μ (Icc a b)ᶜ = 0hL :0 ≤ Lf :ℝ → ℝhf :hLip :∀ x ∈ Icc a b, ∀ y ∈ Icc a b, |f x - f y| ≤ L * |x - y|conclusion(μ.map f) (Icc (f a - L * (b - a)) (f a + L * (b - a)))ᶜ = 0Proof (Lean source)
lemma map_supported_in_lipschitz_range (μ : Measure ℝ) {a b L : ℝ} (hab : a ≤ b) (hμ : μ (Icc a b)ᶜ = 0) (hL : 0 ≤ L) (f : ℝ → ℝ) (hf : Measurable f) (hLip : ∀ x ∈ Icc a b, ∀ y ∈ Icc a b, |f x - f y| ≤ L * |x - y|) : (μ.map f) (Icc (f a - L * (b - a)) (f a + L * (b - a)))ᶜ = 0 := by let J := Icc (f a - L * (b - a)) (f a + L * (b - a)) have hpre : f ⁻¹' Jᶜ ⊆ (Icc a b)ᶜ := by intro x hx hxab have hax := hLip x hxab a ⟨le_refl a, hab⟩ have hdist : |x - a| ≤ b - a := by rw [abs_of_nonneg (sub_nonneg.mpr hxab.1)] linarith [hxab.2] have hbound : |f x - f a| ≤ L * (b - a) := hax.trans (mul_le_mul_of_nonneg_left hdist hL) have hj : f x ∈ J := by dsimp [J] have hh := abs_le.mp hbound exact ⟨by linarith [hh.1], by linarith [hh.2]⟩ exact hx hj change (μ.map f) Jᶜ = 0 rw [Measure.map_apply hf measurableSet_Icc.compl] exact measure_mono_null hpre hμ -
mapped_coupling_cost_lelemma — A coupling of two probability laws concentrated on the interval from a to b, mapped by a measurable transformation with a Lipschitz factor that controls the transformation there, has image absolute cost at most that factor times its source cost.hypothesesμ ν :a b L :ℝhμ :μ (Icc a b)ᶜ = 0hν :ν (Icc a b)ᶜ = 0f :ℝ → ℝhf :hLip :∀ x ∈ Icc a b, ∀ y ∈ Icc a b, |f x - f y| ≤ L * |x - y|π :Measure (ℝ × ℝ)hπ :IsCoupling π μ νconclusion(∫ z : ℝ × ℝ, |z.1 - z.2| ∂(π.map (fun z : ℝ × ℝ => (f z.1, f z.2))))≤ L * ∫ z : ℝ × ℝ, |z.1 - z.2| ∂πProof (Lean source)
lemma mapped_coupling_cost_le (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {a b L : ℝ} (hμ : μ (Icc a b)ᶜ = 0) (hν : ν (Icc a b)ᶜ = 0) (f : ℝ → ℝ) (hf : Measurable f) (hLip : ∀ x ∈ Icc a b, ∀ y ∈ Icc a b, |f x - f y| ≤ L * |x - y|) {π : Measure (ℝ × ℝ)} (hπ : IsCoupling π μ ν) : (∫ z : ℝ × ℝ, |z.1 - z.2| ∂(π.map (fun z : ℝ × ℝ => (f z.1, f z.2)))) ≤ L * ∫ z : ℝ × ℝ, |z.1 - z.2| ∂π := by letI : IsProbabilityMeasure π := hπ.isProbabilityMeasure have hp : Measurable (fun z : ℝ × ℝ => (f z.1, f z.2)) := (hf.comp measurable_fst).prodMk (hf.comp measurable_snd) have h₁ : ∀ᵐ z ∂π, z.1 ∈ Icc a b := by have hh : ∀ᵐ x ∂μ, x ∈ Icc a b := by rw [ae_iff]; exact hμ rw [← hπ.map_fst] at hh exact (ae_map_iff measurable_fst.aemeasurable measurableSet_Icc).mp hh have h₂ : ∀ᵐ z ∂π, z.2 ∈ Icc a b := by have hh : ∀ᵐ x ∂ν, x ∈ Icc a b := by rw [ae_iff]; exact hν rw [← hπ.map_snd] at hh exact (ae_map_iff measurable_snd.aemeasurable measurableSet_Icc).mp hh have hle : ∀ᵐ z ∂π, |f z.1 - f z.2| ≤ L * |z.1 - z.2| := by filter_upwards [h₁, h₂] with z hz₁ hz₂ exact hLip z.1 hz₁ z.2 hz₂ have hsrc := coupling_abs_cost_integrable μ ν hμ hν hπ have hrhs : Integrable (fun z : ℝ × ℝ => L * |z.1 - z.2|) π := hsrc.const_mul L have hlhs : Integrable (fun z : ℝ × ℝ => |f z.1 - f z.2|) π := by apply hrhs.mono' · exact ((hf.comp measurable_fst).sub (hf.comp measurable_snd)).norm.aestronglyMeasurable · filter_upwards [hle] with z hz rw [Real.norm_eq_abs, abs_abs] exact hz rw [integral_map hp.aemeasurable (by fun_prop : AEStronglyMeasurable (fun z : ℝ × ℝ => |z.1 - z.2|) (π.map (fun z : ℝ × ℝ => (f z.1, f z.2))))] calc (∫ z : ℝ × ℝ, |f z.1 - f z.2| ∂π) ≤ ∫ z : ℝ × ℝ, L * |z.1 - z.2| ∂π := integral_mono_ae hlhs hrhs hle _ = L * ∫ z : ℝ × ℝ, |z.1 - z.2| ∂π := by rw [integral_const_mul]
QuantileBand 4 core · 2 supporting This module inverts a uniform empirical-CDF band through the lower generalized inverse. ★ quantileBand_coverage
Simultaneous quantile bands by CDF inversion
This module inverts a uniform empirical-CDF band through the lower generalized
inverse. Its headline confidence band is data-computable: on every covered
sample path, the unknown population quantile at an interior level τ lies
between the sample quantiles at τ - ε and τ + ε. The reverse inclusion of
the sample quantile between shifted population quantiles is retained as a
supporting lemma.
Given a population law, a band radius, and a quantile level, the supporting population-quantile band is the interval from the population quantile at τ - ε to the population quantile at τ + ε.
Given an i.i.d. real sample, a band radius, a sample size, an outcome, and a quantile level, the data-computable quantile confidence band is the interval between the sample quantiles at τ - ε and τ + ε.
Given an i.i.d. real sample, a confidence level, and a sample size, the simultaneous quantile-band coverage event consists of outcomes whose data-computable band contains the population quantile at every level for which both shifted sample-quantile levels are interior.
Definition (Lean source)
Simultaneous data-computable quantile confidence band from VC--McDiarmid. Given an i.i.d. real sample, a positive sample size, and a confidence level between zero and one, with probability at least 1 - α, every unknown population quantile whose VC--McDiarmid-shifted level remains in (0,1) lies between the corresponding lower and upper sample quantiles.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
sampleQuantile_mem_populationQuantileBand_of_cdfBandtheorem — Quantile-band inversion. Given an i.i.d. real sample, a nonnegative uniform-CDF radius, a positive sample size, an outcome, and a quantile level whose lower and upper shifts are interior, if the population CDF lies in the radius-ε empirical band at every threshold, then the sample quantile lies between the population quantiles at τ - ε and τ + ε.hypothesesS :IIDSample Ω ℝ μ Pε :ℝhε :0 ≤ εn :ℕhn :0 < nω :Ωτ :ℝhτ_lower :0 < τ - εhτ_upper :τ + ε < 1hband :∀ x : ℝ, cdf P x ∈ Icc (S.empiricalCDF x n ω - ε) (S.empiricalCDF x n ω + ε)conclusionS.sampleQuantile τ n ω ∈ populationQuantileBand P ε τProof (Lean source)
theorem IIDSample.sampleQuantile_mem_populationQuantileBand_of_cdfBand (S : IIDSample Ω ℝ μ P) [IsProbabilityMeasure P] {ε : ℝ} (hε : 0 ≤ ε) {n : ℕ} (hn : 0 < n) (ω : Ω) {τ : ℝ} (hτ_lower : 0 < τ - ε) (hτ_upper : τ + ε < 1) (hband : ∀ x : ℝ, cdf P x ∈ Icc (S.empiricalCDF x n ω - ε) (S.empiricalCDF x n ω + ε)) : S.sampleQuantile τ n ω ∈ populationQuantileBand P ε τ := by have hτ0 : 0 < τ := lt_of_lt_of_le hτ_lower (by linarith) have hτ1 : τ < 1 := lt_of_le_of_lt (by linarith) hτ_upper let qhat := S.sampleQuantile τ n ω have hFn_qhat : τ ≤ S.empiricalCDF qhat n ω := (S.sampleQuantile_le_iff hn ω hτ0 hτ1 qhat).mp le_rfl have hband_qhat := hband qhat have hpop_qhat : τ - ε ≤ cdf P qhat := by exact le_trans (by linarith [hFn_qhat]) hband_qhat.1 have hlower : quantile P (τ - ε) ≤ qhat := quantile_le_of_le_cdf hτ_lower hpop_qhat let qupper := quantile P (τ + ε) have hpop_upper : τ + ε ≤ cdf P qupper := le_cdf_quantile hτ_upper have hband_upper := hband qupper have hFn_upper : τ ≤ S.empiricalCDF qupper n ω := by linarith [hpop_upper, hband_upper.2] have hupper : qhat ≤ quantile P (τ + ε) := by change S.sampleQuantile τ n ω ≤ qupper exact (S.sampleQuantile_le_iff hn ω hτ0 hτ1 qupper).mpr hFn_upper exact ⟨hlower, hupper⟩ -
quantile_mem_quantileBand_of_cdfBandtheorem — Data-computable quantile-band inversion. Given an i.i.d. real sample, a nonnegative uniform-CDF radius, a positive sample size, an outcome, and a quantile level whose lower and upper shifts are interior, if the population CDF lies in the radius-ε empirical band at every threshold, then the population quantile at τ lies between the sample quantiles at τ - ε and τ + ε.hypothesesS :IIDSample Ω ℝ μ Pε :ℝhε :0 ≤ εn :ℕhn :0 < nω :Ωτ :ℝhτ_lower :0 < τ - εhτ_upper :τ + ε < 1hband :∀ x : ℝ, cdf P x ∈ Icc (S.empiricalCDF x n ω - ε) (S.empiricalCDF x n ω + ε)conclusionquantile P τ ∈ S.quantileBand ε n ω τProof (Lean source)
theorem IIDSample.quantile_mem_quantileBand_of_cdfBand (S : IIDSample Ω ℝ μ P) [IsProbabilityMeasure P] {ε : ℝ} (hε : 0 ≤ ε) {n : ℕ} (hn : 0 < n) (ω : Ω) {τ : ℝ} (hτ_lower : 0 < τ - ε) (hτ_upper : τ + ε < 1) (hband : ∀ x : ℝ, cdf P x ∈ Icc (S.empiricalCDF x n ω - ε) (S.empiricalCDF x n ω + ε)) : quantile P τ ∈ S.quantileBand ε n ω τ := by have hτ0 : 0 < τ := lt_of_lt_of_le hτ_lower (by linarith) have hτ1 : τ < 1 := lt_of_le_of_lt (by linarith) hτ_upper let q := quantile P τ have hpop_q : τ ≤ cdf P q := le_cdf_quantile hτ1 have hband_q := hband q have hemp_q : τ - ε ≤ S.empiricalCDF q n ω := by linarith [hpop_q, hband_q.2] have hlower : S.sampleQuantile (τ - ε) n ω ≤ q := (S.sampleQuantile_le_iff hn ω hτ_lower (by linarith) q).mpr hemp_q let qhat := S.sampleQuantile (τ + ε) n ω have hemp_qhat : τ + ε ≤ S.empiricalCDF qhat n ω := (S.sampleQuantile_le_iff hn ω (by linarith) hτ_upper qhat).mp le_rfl have hband_qhat := hband qhat have hpop_qhat : τ ≤ cdf P qhat := by linarith [hemp_qhat, hband_qhat.1] have hupper : q ≤ S.sampleQuantile (τ + ε) n ω := by change quantile P τ ≤ qhat exact quantile_le_of_le_cdf hτ0 hpop_qhat exact ⟨hlower, hupper⟩
SampleQuantileJoint 6 core · 7 supporting This file packages coordinatewise Bahadur representations into vector asymptotic linearity and proves weak convergence to a supplied probability law whose characteristic function has the required quadratic exponential fo ★ quantileIF_cross★ sampleQuantileVec_isAsymLinearVec★ sampleQuantileVec_tendsto_of_charFun
Characteristic-Function Limit of a Quantile Vector
This file packages coordinatewise Bahadur representations into vector asymptotic linearity and proves weak convergence to a supplied probability law whose characteristic function has the required quadratic exponential form. It also computes the pairwise quantile influence-function cross-moments.
For a nonnegative integer specifying a finite collection of coordinates and a real-valued vector indexed by those coordinates, the Euclidean representation of that vector is the corresponding point of the -dimensional Euclidean space.
For a nonnegative integer specifying a finite collection of quantile coordinates and coordinatewise quantile levels, population quantiles, and density values, the joint quantile influence function maps each real-valued observation to the Euclidean vector whose th coordinate is .
Definition (Lean source)
For a measurable sample space carrying a measure, a population measure on the real line, a nonnegative integer specifying a finite collection of quantile coordinates, an independent and identically distributed real-valued sample from that population, and a vector of quantile levels, the sample-quantile vector maps every nonnegative integer sample size and sample-space outcome to the Euclidean vector of the corresponding coordinatewise sample quantiles.
Covariance entry. Given qⱼ is the population τⱼ-quantile: and qₗ is the population τₗ-quantile: , the cross-moment of the two quantile influence functions and under the population measure equals .
Proof (Lean source)
The sample-quantile vector is asymptotically linear with the joint influence function ψ. Given a SampleQuantileReg regularity bundle at every coordinate j: interior level , positive density at the population quantile , cdf identification, differentiability of the population cdf, and cdf continuity on a positive-radius neighborhood of each target quantile, the vector of sample -quantiles is jointly asymptotically linear at the vector of population quantiles, with influence function the joint quantile influence function .
Formal statement
Proof (Lean source)
Sample-quantile vector convergence from a target characteristic function. Given an i.i.d. real sample, a SampleQuantileReg bundle at every coordinate, a candidate target probability law, the identity equating its characteristic function to the quadratic exponential determined by the joint influence function, and almost-everywhere measurability of each rescaled estimator, the laws of the rescaled sample-quantile vectors converge weakly to that target.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
measurable_quantileIFVeclemma — The joint quantile influence function is measurable.Proof (Lean source)
@[fun_prop] lemma measurable_quantileIFVec (τ q f : Fin k → ℝ) : Measurable (quantileIFVec τ q f) := by unfold quantileIFVec eucl refine ((EuclideanSpace.equiv (Fin k) ℝ).symm.continuous.measurable).comp ?_ exact measurable_pi_lambda _ (fun j => measurable_quantileIF (τ j) (q j) (f j)) -
norm_sq_eucllemma — Euclidean norm of a packed vector, squared, is the coordinatewise sum of squares.Proof (Lean source)
lemma norm_sq_eucl (v : Fin k → ℝ) : ‖eucl v‖ ^ 2 = ∑ j, (v j) ^ 2 := by rw [EuclideanSpace.norm_eq, Real.sq_sqrt (Finset.sum_nonneg fun j _ => sq_nonneg _)] refine Finset.sum_congr rfl fun j _ => ?_ rw [Real.norm_eq_abs, sq_abs] rfl -
norm_eucl_le_sum_abslemma — The Euclidean norm of a packed vector is bounded by the ℓ¹ norm of its coordinates: ‖eucl v‖ ≤ ∑ j, |v j|.Proof (Lean source)
lemma norm_eucl_le_sum_abs (v : Fin k → ℝ) : ‖eucl v‖ ≤ ∑ j, |v j| := by have hnonneg : 0 ≤ ∑ j, |v j| := Finset.sum_nonneg fun j _ => abs_nonneg _ have hsq : ‖eucl v‖ ^ 2 ≤ (∑ j, |v j|) ^ 2 := by rw [norm_sq_eucl] have hle : ∑ j, (v j) ^ 2 ≤ (∑ j, |v j|) ^ 2 := by rw [sq, Finset.sum_mul_sum] refine Finset.sum_le_sum fun j _ => ?_ calc (v j) ^ 2 = |v j| * |v j| := by rw [sq, ← abs_mul_abs_self] _ ≤ ∑ i, |v j| * |v i| := by refine Finset.single_le_sum (f := fun i => |v j| * |v i|) (fun i _ => mul_nonneg (abs_nonneg _) (abs_nonneg _)) (Finset.mem_univ j) exact hle exact le_of_pow_le_pow_left₀ (by norm_num) hnonneg hsq -
isLittleOp_finset_sum_onelemma — A finite sum of o_p(1) sequences is o_p(1).hypothesesconclusionIsLittleOp (fun n ω => ∑ i ∈ s, g i n ω) (fun _ => (1 : ℝ)) μProof (Lean source)
lemma isLittleOp_finset_sum_one {ι : Type*} (s : Finset ι) (g : ι → ℕ → Ω → ℝ) (h : ∀ i ∈ s, IsLittleOp (g i) (fun _ => (1 : ℝ)) μ) : IsLittleOp (fun n ω => ∑ i ∈ s, g i n ω) (fun _ => (1 : ℝ)) μ := by classical induction s using Finset.induction_on with | empty => simpa using isLittleOp_zero (μ := μ) | insert a s has ih => have ha := h a (Finset.mem_insert_self a s) have hs := ih (fun i hi => h i (Finset.mem_insert_of_mem hi)) have hadd := IsLittleOp.add_one ha hs simpa [Finset.sum_insert has] using hadd -
isLittleOp_of_abs_le_const_mul_onelemma — Domination: if |Xn| ≤ C·|Yn| with Yn o_p(1) and C > 0, then Xn is o_p(1).hypothesesconclusionIsLittleOp X (fun _ => (1 : ℝ)) μProof (Lean source)
lemma isLittleOp_of_abs_le_const_mul_one {X Y : ℕ → Ω → ℝ} {C : ℝ} (hC : 0 < C) (hY : IsLittleOp Y (fun _ => (1 : ℝ)) μ) (hbound : ∀ n ω, |X n ω| ≤ C * |Y n ω|) : IsLittleOp X (fun _ => (1 : ℝ)) μ := IsLittleOp.of_abs_le_const_mul_one hC hY hbound -
isLittleOp_abslemma — The absolute value of an o_p(1) sequence is o_p(1) (the threshold events coincide).hypotheseshR :IsLittleOp R (fun _ => (1 : ℝ)) μconclusionIsLittleOp (fun n ω => |R n ω|) (fun _ => (1 : ℝ)) μProof (Lean source)
lemma isLittleOp_abs {R : ℕ → Ω → ℝ} (hR : IsLittleOp R (fun _ => (1 : ℝ)) μ) : IsLittleOp (fun n ω => |R n ω|) (fun _ => (1 : ℝ)) μ := by refine IsLittleOp.of_abs_le_const_mul_one (C := 1) one_pos hR ?_ intro n ω simp
Transport 1 core · 9 supporting This module proves the atom-valid one-dimensional identity between the absolute-distance cost of the shared-uniform quantile coupling and the integrated absolute difference of two CDFs on a common compact interval. ★ quantile_transport_eq_cdf_distance
One-dimensional quantile transport and CDF distance
This module proves the atom-valid one-dimensional identity between the absolute-distance cost of the shared-uniform quantile coupling and the integrated absolute difference of two CDFs on a common compact interval. It also exposes the support, integrability, threshold-kernel, and Tonelli facts used by that identity.
Two probability laws, an ordered common compact interval, and concentration of both laws on that interval give the identity between shared-uniform quantile transport cost and integrated CDF distance.
Formal statement
Proof (Lean source)
9 supporting declarations (lemmas, instances)
-
quantile_mem_Icc_aelemma — A probability law concentrated on a closed interval has a quantile in that interval at almost every interior level.hypothesesconclusion∀ᵐ u ∂unifOI, quantile μ u ∈ Icc a bProof (Lean source)
lemma quantile_mem_Icc_ae (μ : Measure ℝ) [IsProbabilityMeasure μ] {a b : ℝ} (hμ : μ (Icc a b)ᶜ = 0) : ∀ᵐ u ∂unifOI, quantile μ u ∈ Icc a b := by /- Pull back the conull interval along `quantile_map_uniform μ`; use `aemeasurable_quantile_unifOI` to identify the preimage measure. -/ have h : ∀ᵐ x ∂μ, x ∈ Icc a b := by rw [ae_iff] exact hμ rw [← quantile_map_uniform μ] at h exact (ae_map_iff (aemeasurable_quantile_unifOI μ) measurableSet_Icc).mp h -
intervalIntegrable_abs_cdf_sublemma — Two probability laws have an absolute CDF difference integrable over the given finite interval.hypothesesμ ν :a b :ℝconclusionProof (Lean source)
lemma intervalIntegrable_abs_cdf_sub (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (a b : ℝ) : IntervalIntegrable (fun t : ℝ => |cdf μ t - cdf ν t|) volume a b := by /- Monotonicity gives measurability of each CDF; `cdf_nonneg` and `cdf_le_one` bound the integrand by one on the finite interval. -/ apply (intervalIntegrable_iff).2 apply Measure.integrableOn_of_bounded (M := 1) (by simp only [uIoc]; exact measure_Ioc_lt_top.ne) · simpa only [Real.norm_eq_abs, Pi.sub_apply] using (((monotone_cdf μ).measurable.sub (monotone_cdf ν).measurable).norm).aestronglyMeasurable · filter_upwards with t rw [Real.norm_eq_abs, abs_abs] have hμ := cdf_nonneg μ t have hν := cdf_nonneg ν t have hμ' := cdf_le_one μ t have hν' := cdf_le_one ν t exact abs_le.mpr ⟨by linarith, by linarith⟩ -
intervalIntegrable_abs_quantile_sublemma — Two probability laws concentrated on one closed interval have an integrable absolute quantile difference over the unit interval.hypothesesμ ν :a b :ℝhμ :μ (Icc a b)ᶜ = 0hν :ν (Icc a b)ᶜ = 0conclusionProof (Lean source)
lemma intervalIntegrable_abs_quantile_sub (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {a b : ℝ} (hμ : μ (Icc a b)ᶜ = 0) (hν : ν (Icc a b)ᶜ = 0) : IntervalIntegrable (fun u : ℝ => |quantile μ u - quantile ν u|) volume 0 1 := by /- Combine `aemeasurable_quantile_unifOI` with `quantile_mem_Icc_ae`; the distance is bounded by `b-a` almost everywhere. -/ have hmeas : AEStronglyMeasurable (fun u : ℝ => |quantile μ u - quantile ν u|) unifOI := by simpa only [Real.norm_eq_abs, Pi.sub_apply] using (((aemeasurable_quantile_unifOI μ).sub (aemeasurable_quantile_unifOI ν)).norm).aestronglyMeasurable have hbound : ∀ᵐ u ∂unifOI, ‖|quantile μ u - quantile ν u|‖ ≤ b - a := by filter_upwards [quantile_mem_Icc_ae μ hμ, quantile_mem_Icc_ae ν hν] with u hu hv rw [Real.norm_eq_abs, abs_abs] exact abs_le.mpr ⟨by linarith [hu.1, hv.2], by linarith [hu.2, hv.1]⟩ have hrest : volume.restrict (Ioc (0 : ℝ) 1) = unifOI := by rw [unifOI, restrict_Ioo_eq_restrict_Ioc] apply (intervalIntegrable_iff_integrableOn_Ioc_of_le (by norm_num : (0 : ℝ) ≤ 1)).2 change Integrable (fun u : ℝ => |quantile μ u - quantile ν u|) (volume.restrict (Ioc (0 : ℝ) 1)) rw [hrest] exact Integrable.of_bound hmeas (b - a) hbound -
threshold_indicator_integral_eq_cdf_distancelemma — Two probability laws and a threshold have a mean lower-ray indicator disagreement equal to the absolute difference of their CDFs there.hypothesesμ ν :t :ℝProof (Lean source)
lemma threshold_indicator_integral_eq_cdf_distance (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (t : ℝ) : (∫ u in (0 : ℝ)..1, |(if quantile μ u ≤ t then (1 : ℝ) else 0) - (if quantile ν u ≤ t then 1 else 0)|) = |cdf μ t - cdf ν t| := by /- On (0,1), `quantile_le_iff` turns both predicates into `u ≤ cdf _ t`. Their symmetric difference is the interval between the two CDF values, including its right endpoint; that endpoint has zero Lebesgue measure. Use `cdf_nonneg` and `cdf_le_one`. -/ have hcongr : (∫ u in (0 : ℝ)..1, |(if quantile μ u ≤ t then (1 : ℝ) else 0) - (if quantile ν u ≤ t then 1 else 0)|) = ∫ u in (0 : ℝ)..1, |(if u ≤ cdf μ t then (1 : ℝ) else 0) - (if u ≤ cdf ν t then 1 else 0)| := by apply intervalIntegral.integral_congr_Ioo_of_le (by norm_num : (0 : ℝ) ≤ 1) intro u hu change |(if quantile μ u ≤ t then (1 : ℝ) else 0) - (if quantile ν u ≤ t then 1 else 0)| = |(if u ≤ cdf μ t then (1 : ℝ) else 0) - (if u ≤ cdf ν t then 1 else 0)| simp only [quantile_le_iff hu.1 hu.2] rw [hcongr] exact integral_abs_cut_indicators (cdf μ t) (cdf ν t) (cdf_nonneg μ t) (cdf_le_one μ t) (cdf_nonneg ν t) (cdf_le_one ν t) -
indicator_kernel_integrablelemma — Two probability laws and a finite interval give an integrable lower-ray disagreement kernel under the product of the uniform-level law and restricted Lebesgue measure.hypothesesμ ν :a b :ℝconclusionIntegrable (fun z : ℝ × ℝ => |(if quantile μ z.1 ≤ z.2 then (1 : ℝ) else 0) - (if quantile ν z.1 ≤ z.2 then 1 else 0)|) (unifOI.prod (volume.restrict (Ioc a b)))Proof (Lean source)
lemma indicator_kernel_integrable (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {a b : ℝ} : Integrable (fun z : ℝ × ℝ => |(if quantile μ z.1 ≤ z.2 then (1 : ℝ) else 0) - (if quantile ν z.1 ≤ z.2 then 1 else 0)|) (unifOI.prod (volume.restrict (Ioc a b))) := by /- Pull a.e. measurability of each quantile on `unifOI` to the product; comparisons with the measurable second projection are a.e. measurable. The kernel is bounded by one, and the product measure is finite. -/ let ρ : Measure (ℝ × ℝ) := unifOI.prod (volume.restrict (Ioc a b)) haveI : IsFiniteMeasure (volume.restrict (Ioc a b)) := isFiniteMeasure_restrict.mpr measure_Ioc_lt_top.ne haveI : IsFiniteMeasure ρ := by dsimp [ρ]; infer_instance have hm : AEStronglyMeasurable (fun z : ℝ × ℝ => quantile μ z.1) ρ := (aemeasurable_quantile_unifOI μ).comp_fst |>.aestronglyMeasurable have hn : AEStronglyMeasurable (fun z : ℝ × ℝ => quantile ν z.1) ρ := (aemeasurable_quantile_unifOI ν).comp_fst |>.aestronglyMeasurable have ht : AEStronglyMeasurable (fun z : ℝ × ℝ => z.2) ρ := measurable_snd.aestronglyMeasurable have hc : AEStronglyMeasurable (fun _ : ℝ × ℝ => (1 : ℝ)) ρ := aestronglyMeasurable_const have hμ : AEStronglyMeasurable (fun z : ℝ × ℝ => if quantile μ z.1 ≤ z.2 then (1 : ℝ) else 0) ρ := by convert hc.indicator₀ (nullMeasurableSet_le hm.aemeasurable ht.aemeasurable) using 1 ext z simp [indicator] have hν : AEStronglyMeasurable (fun z : ℝ × ℝ => if quantile ν z.1 ≤ z.2 then (1 : ℝ) else 0) ρ := by convert hc.indicator₀ (nullMeasurableSet_le hn.aemeasurable ht.aemeasurable) using 1 ext z simp [indicator] have hk : AEStronglyMeasurable (fun z : ℝ × ℝ => |(if quantile μ z.1 ≤ z.2 then (1 : ℝ) else 0) - (if quantile ν z.1 ≤ z.2 then 1 else 0)|) ρ := by simpa only [Real.norm_eq_abs, Pi.sub_apply] using (hμ.sub hν).norm exact Integrable.of_bound hk 1 (by filter_upwards with z split_ifs <;> norm_num) -
indicator_integral_swaplemma — Two probability laws and an ordered finite interval have equal iterated lower-ray disagreement integrals in either order.hypothesesProof (Lean source)
lemma indicator_integral_swap (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {a b : ℝ} (hab : a ≤ b) : (∫ u in (0 : ℝ)..1, ∫ t in a..b, |(if quantile μ u ≤ t then (1 : ℝ) else 0) - (if quantile ν u ≤ t then 1 else 0)|) = ∫ t in a..b, ∫ u in (0 : ℝ)..1, |(if quantile μ u ≤ t then (1 : ℝ) else 0) - (if quantile ν u ≤ t then 1 else 0)| := by /- Write both interval integrals as set integrals on `Ioc`, identify the first factor with `unifOI`, then use `integral_integral_swap` with `indicator_kernel_integrable`. -/ have hrest : volume.restrict (Ioc (0 : ℝ) 1) = unifOI := by rw [unifOI, restrict_Ioo_eq_restrict_Ioc] simp_rw [intervalIntegral.integral_of_le hab, intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1)] rw [hrest] exact integral_integral_swap (indicator_kernel_integrable μ ν) -
abs_sub_eq_integral_Icc_indicatorlemma — Two points in a common closed interval have a distance equal to the integral of their lower-ray indicator disagreement.hypothesesa b x y :ℝhx :x ∈ Icc a bhy :y ∈ Icc a bconclusion|x - y| = ∫ t in a..b, |(if x ≤ t then (1 : ℝ) else 0) - (if y ≤ t then 1 else 0)|Proof (Lean source)
lemma abs_sub_eq_integral_Icc_indicator {a b x y : ℝ} (hx : x ∈ Icc a b) (hy : y ∈ Icc a b) : |x - y| = ∫ t in a..b, |(if x ≤ t then (1 : ℝ) else 0) - (if y ≤ t then 1 else 0)| := by /- Split on `x ≤ y`. In the first branch the integrand is the indicator of `Ico x y`; in the second it is the indicator of `Ico y x`. Restrict to `Ioc a b`, then use `Real.volume_Ioc` (or the equal-volume half-open variant). Endpoint choices do not change the integral. -/ by_cases hxy : x ≤ y · have heq : ∀ᵐ t ∂volume, |(if x ≤ t then (1 : ℝ) else 0) - (if y ≤ t then 1 else 0)| = (Ioc x y).indicator (fun _ => (1 : ℝ)) t := by filter_upwards [volume.ae_ne x, volume.ae_ne y] with t htx hty have hxt' : x < t ↔ x ≤ t := by constructor · exact le_of_lt · intro h exact lt_of_le_of_ne h (Ne.symm htx) have hyt' : t ≤ y ↔ t < y := by constructor · intro h exact lt_of_le_of_ne h hty · exact le_of_lt by_cases hxt : x ≤ t <;> by_cases hyt : y ≤ t <;> simp_all [indicator, Set.mem_Ioc, not_le] <;> grind rw [intervalIntegral.integral_congr_ae (heq.mono fun t ht _ => ht)] rw [intervalIntegral.integral_of_le (le_trans hx.1 hx.2)] rw [setIntegral_indicator measurableSet_Ioc] have hs : Ioc a b ∩ Ioc x y = Ioc x y := by ext t simp only [Set.mem_inter_iff, Set.mem_Ioc] constructor · exact right · intro ht exact ⟨⟨lt_of_le_of_lt hx.1 ht.1, ht.2.trans hy.2⟩, ht⟩ rw [hs, setIntegral_const] simp [measureReal_def, Real.volume_Ioc, ENNReal.toReal_ofReal (sub_nonneg.mpr hxy), abs_of_nonpos (sub_nonpos.mpr hxy)] · have hyx : y ≤ x := le_of_not_ge hxy have heq : ∀ᵐ t ∂volume, |(if x ≤ t then (1 : ℝ) else 0) - (if y ≤ t then 1 else 0)| = (Ioc y x).indicator (fun _ => (1 : ℝ)) t := by filter_upwards [volume.ae_ne x, volume.ae_ne y] with t htx hty have hxt' : y < t ↔ y ≤ t := by constructor · exact le_of_lt · intro h exact lt_of_le_of_ne h (Ne.symm hty) have hyt' : t ≤ x ↔ t < x := by constructor · intro h exact lt_of_le_of_ne h htx · exact le_of_lt by_cases hxt : x ≤ t <;> by_cases hyt : y ≤ t <;> simp_all [indicator, Set.mem_Ioc, not_le] <;> grind rw [intervalIntegral.integral_congr_ae (heq.mono fun t ht _ => ht)] rw [intervalIntegral.integral_of_le (le_trans hx.1 hx.2)] rw [setIntegral_indicator measurableSet_Ioc] have hs : Ioc a b ∩ Ioc y x = Ioc y x := by ext t simp only [Set.mem_inter_iff, Set.mem_Ioc] constructor · exact right · intro ht exact ⟨⟨lt_of_le_of_lt hy.1 ht.1, ht.2.trans hx.2⟩, ht⟩ rw [hs, setIntegral_const] simp [measureReal_def, Real.volume_Ioc, ENNReal.toReal_ofReal (sub_nonneg.mpr hyx), abs_of_nonneg (sub_nonneg.mpr hyx)] -
quantile_cost_eq_indicator_integrallemma — Two probability laws concentrated on one closed interval have a quantile cost equal to the iterated lower-ray indicator integral.hypothesesμ ν :a b :ℝhμ :μ (Icc a b)ᶜ = 0hν :ν (Icc a b)ᶜ = 0Proof (Lean source)
lemma quantile_cost_eq_indicator_integral (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {a b : ℝ} (hμ : μ (Icc a b)ᶜ = 0) (hν : ν (Icc a b)ᶜ = 0) : (∫ u in (0 : ℝ)..1, |quantile μ u - quantile ν u|) = ∫ u in (0 : ℝ)..1, ∫ t in a..b, |(if quantile μ u ≤ t then (1 : ℝ) else 0) - (if quantile ν u ≤ t then 1 else 0)| := by /- Apply the preceding pointwise identity on the intersection of `quantile_mem_Icc_ae μ hμ` and `quantile_mem_Icc_ae ν hν`. Convert `unifOI` to the interval restriction on `Ioc 0 1` as in `intervalIntegrable_abs_quantile_sub`, then use `intervalIntegral.integral_congr_ae`. -/ have hrest : volume.restrict (Ioc (0 : ℝ) 1) = unifOI := by rw [unifOI, restrict_Ioo_eq_restrict_Ioc] apply intervalIntegral.integral_congr_ae_restrict simp only [uIoc_of_le (by norm_num : (0 : ℝ) ≤ 1)] rw [hrest] filter_upwards [quantile_mem_Icc_ae μ hμ, quantile_mem_Icc_ae ν hν] with u hu hv exact abs_sub_eq_integral_Icc_indicator hu hv -
indicator_integral_eq_cdf_distancelemma — Two probability laws and an ordered closed interval give an iterated quantile-indicator integral equal to their integrated CDF distance.hypothesesProof (Lean source)
lemma indicator_integral_eq_cdf_distance (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] {a b : ℝ} (hab : a ≤ b) : (∫ u in (0 : ℝ)..1, ∫ t in a..b, |(if quantile μ u ≤ t then (1 : ℝ) else 0) - (if quantile ν u ≤ t then 1 else 0)|) = ∫ t in a..b, |cdf μ t - cdf ν t| := by calc _ = ∫ t in a..b, ∫ u in (0 : ℝ)..1, |(if quantile μ u ≤ t then (1 : ℝ) else 0) - (if quantile ν u ≤ t then 1 else 0)| := indicator_integral_swap μ ν hab _ = ∫ t in a..b, |cdf μ t - cdf ν t| := by apply intervalIntegral.integral_congr intro t _ exact threshold_indicator_integral_eq_cdf_distance μ ν t
VCMcDiarmidRadius 4 core · 1 supporting This module calibrates both proved branches of the VC--McDiarmid bound. ★ empiricalCDF_vc_mcdiarmid_radius
Confidence radii for the VC--McDiarmid empirical-CDF bound
This module calibrates both proved branches of the VC--McDiarmid bound. When its threshold condition holds, the large-deviation branch supplies the smaller square-root radius; otherwise the globally valid VC radius is used.
For a confidence level and a sample size, the globally valid VC--McDiarmid radius is sqrt (32 * log (8 * (m+1) / α) / m).
For a confidence level and a sample size, the radius calibrated from the large-threshold VC--McDiarmid branch is sqrt (8 * log (1 / α) / m).
For a confidence level and a sample size, the VC--McDiarmid confidence radius is the minimum of the globally valid radius and the large-threshold radius when the latter satisfies its validity condition, and is the global radius otherwise.
Definition (Lean source)
Given a population probability law, a positive sample size, and a confidence level between zero and one, the probability that the empirical CDF exceeds the automatically selected vcMcDiarmidRadius α m is at most α. This radius comes from the proved VC--McDiarmid bound, not the sharp DKW--Massart inequality.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
vcMcDiarmidRadius_nonneglemma — For a confidence level and a sample size, the selected VC--McDiarmid confidence radius is nonnegative.Proof (Lean source)
lemma vcMcDiarmidRadius_nonneg (α : ℝ) (m : ℕ) : 0 ≤ vcMcDiarmidRadius α m := by unfold vcMcDiarmidRadius vcMcDiarmidLargeRadius vcMcDiarmidGlobalRadius split · exact le_min (Real.sqrt_nonneg _) (Real.sqrt_nonneg _) · exact Real.sqrt_nonneg _
CDFBand 3 core · 4 supporting This module turns the product-law VC--McDiarmid deviation inequality into a confidence band on the sample space of an arbitrary IIDSample. ★ cdfBand_coverage
Uniform empirical-CDF confidence bands
This module turns the product-law VC--McDiarmid deviation inequality into a
confidence band on the sample space of an arbitrary IIDSample. The band is
centered at the empirical CDF and covers the population CDF simultaneously at
every real threshold. Its radius is more conservative than the sharp
Dvoretzky--Kiefer--Wolfowitz--Massart radius.
Given an i.i.d. real sample, a confidence level, a sample size, an outcome, and a threshold, the empirical-CDF confidence band is the empirical-CDF interval of radius vcMcDiarmidRadius α n, clipped to the CDF range [0,1].
Definition (Lean source)
Given an i.i.d. real sample, a confidence level, and a sample size, the simultaneous CDF-band coverage event consists of outcomes for which the population CDF belongs to the empirical band at every real threshold.
Uniform CDF confidence band from a VC--McDiarmid bound. Given an i.i.d. real sample, a positive sample size, and a confidence level between zero and one, the data-dependent VC--McDiarmid-radius band covers the population CDF simultaneously at every real threshold with probability at least 1 - α.
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
empiricalCDF_eq_empiricalCDFVeclemma — The empirical CDF of the first n observations is the vector empirical CDF of the finite-prefix map.hypothesesconclusionS.empiricalCDF x n ω = empiricalCDFVec (fun i : Fin n => S.Z i ω) xProof (Lean source)
lemma IIDSample.empiricalCDF_eq_empiricalCDFVec (S : IIDSample Ω ℝ μ P) (n : ℕ) (ω : Ω) (x : ℝ) : S.empiricalCDF x n ω = empiricalCDFVec (fun i : Fin n => S.Z i ω) x := by unfold IIDSample.empiricalCDF IIDSample.sampleMean empiricalCDFVec congr 1 exact (Fin.sum_univ_eq_sum_range (fun i => cdfStat x (S.Z i ω)) n).symm -
abs_empiricalCDFVec_sub_cdf_le_onelemma — For a population probability law, a finite sample vector, and a real threshold, the absolute empirical-CDF error is at most one.hypothesesconclusion|empiricalCDFVec z x - cdf P x| ≤ 1Proof (Lean source)
lemma abs_empiricalCDFVec_sub_cdf_le_one {n : ℕ} (P : Measure ℝ) [IsProbabilityMeasure P] (z : Fin n → ℝ) (x : ℝ) : |empiricalCDFVec z x - cdf P x| ≤ 1 := by have hsum0 : 0 ≤ ∑ i : Fin n, cdfStat x (z i) := Finset.sum_nonneg fun i _ => cdfStat_nonneg x (z i) have hsum1 : (∑ i : Fin n, cdfStat x (z i)) ≤ n := by calc (∑ i : Fin n, cdfStat x (z i)) ≤ ∑ _i : Fin n, (1 : ℝ) := Finset.sum_le_sum fun i _ => cdfStat_le_one x (z i) _ = n := by simp have he0 : 0 ≤ empiricalCDFVec z x := by simp only [empiricalCDFVec] positivity have he1 : empiricalCDFVec z x ≤ 1 := by by_cases hn : n = 0 · subst n simp [empiricalCDFVec] · rw [empiricalCDFVec, inv_mul_le_iff₀ (by positivity)] simpa using hsum1 have hP0 := cdf_nonneg P x have hP1 := cdf_le_one P x rw [abs_le] constructor <;> linarith -
abs_empiricalCDFVec_sub_cdf_le_uniformCDFDeviationlemma — For a population probability law, a finite sample vector, and a real threshold, the pointwise absolute empirical-CDF error is at most the uniform CDF deviation.hypothesesconclusionProof (Lean source)
lemma abs_empiricalCDFVec_sub_cdf_le_uniformCDFDeviation {n : ℕ} (P : Measure ℝ) [IsProbabilityMeasure P] (z : Fin n → ℝ) (x : ℝ) : |empiricalCDFVec z x - cdf P x| ≤ uniformCDFDeviation P z := by have hbdd : BddAbove (range fun y : ℝ => |empiricalCDFVec z y - cdf P y|) := by refine ⟨1, ?_⟩ rintro _ ⟨y, rfl⟩ exact abs_empiricalCDFVec_sub_cdf_le_one P z y exact le_csSup hbdd ⟨x, rfl⟩ -
mem_cdfBand_of_prefix_not_badlemma — If a finite sample vector is outside the VC--McDiarmid bad set, its empirical band contains the population CDF at every threshold.hypothesesconclusioncdf P x ∈ S.cdfBand α n ω xProof (Lean source)
lemma IIDSample.mem_cdfBand_of_prefix_not_bad (S : IIDSample Ω ℝ μ P) [IsProbabilityMeasure P] {α : ℝ} {n : ℕ} {ω : Ω} (hgood : (fun i : Fin n => S.Z i ω) ∉ fixedCDFBadSet P (vcMcDiarmidRadius α n)) : ∀ x : ℝ, cdf P x ∈ S.cdfBand α n ω x := by intro x have hdev : uniformCDFDeviation P (fun i : Fin n => S.Z i ω) ≤ vcMcDiarmidRadius α n := by simpa [fixedCDFBadSet] using hgood have habs : |S.empiricalCDF x n ω - cdf P x| ≤ vcMcDiarmidRadius α n := by rw [S.empiricalCDF_eq_empiricalCDFVec n ω x] exact (abs_empiricalCDFVec_sub_cdf_le_uniformCDFDeviation P _ x).trans hdev rw [abs_le] at habs change max 0 (S.empiricalCDF x n ω - vcMcDiarmidRadius α n) ≤ cdf P x ∧ cdf P x ≤ min 1 (S.empiricalCDF x n ω + vcMcDiarmidRadius α n) constructor · exact max_le (cdf_nonneg P x) (by linarith [habs.1]) · exact le_min (cdf_le_one P x) (by linarith [habs.2])
GlivenkoCantelliRate 3 core · 4 supporting This module derives expectation and convergence-in-probability consequences of the proved finite-sample VC--McDiarmid inequality. ★ integral_uniformCDFDeviation_le_radius_add★ integral_uniformCDFDeviation_le_radius_add★ cdfStat_glivenkoCantelli
Quantitative Glivenko--Cantelli bounds from VC--McDiarmid
This module derives expectation and convergence-in-probability consequences of
the proved finite-sample VC--McDiarmid inequality. The expectation statement is
written through vcMcDiarmidRadius, so changes to the upstream VC constant
propagate without duplicating a numeric tail formula here.
Integrated VC--McDiarmid expectation bound. Given a population probability law, a positive sample size, and a confidence level between zero and one, the expected uniform empirical-CDF deviation is at most the VC--McDiarmid radius plus α.
Formal statement
Proof (Lean source)
For an i.i.d. real sample, a positive sample size, and a confidence level between zero and one, the expected uniform empirical-CDF deviation of its first n observations is at most the VC--McDiarmid radius plus α.
Formal statement
Proof (Lean source)
Quantitative Glivenko--Cantelli for lower rays. Given an i.i.d. real sample, the lower-ray indicator class is Glivenko--Cantelli: for every positive tolerance, the probability that some empirical CDF value differs from its population value by at least that tolerance tends to zero.
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
uniformCDFDeviation_nonneglemma — For a population probability law and a finite sample vector, the uniform empirical-CDF deviation is nonnegative.hypothesesconclusion0 ≤ uniformCDFDeviation P zProof (Lean source)
lemma uniformCDFDeviation_nonneg {n : ℕ} (P : Measure ℝ) [IsProbabilityMeasure P] (z : Fin n → ℝ) : 0 ≤ uniformCDFDeviation P z := by exact (abs_nonneg (empiricalCDFVec z 0 - cdf P 0)).trans (abs_empiricalCDFVec_sub_cdf_le_uniformCDFDeviation P z 0) -
uniformCDFDeviation_le_onelemma — For a population probability law and a finite sample vector, the uniform empirical-CDF deviation is at most one.hypothesesconclusionuniformCDFDeviation P z ≤ 1Proof (Lean source)
lemma uniformCDFDeviation_le_one {n : ℕ} (P : Measure ℝ) [IsProbabilityMeasure P] (z : Fin n → ℝ) : uniformCDFDeviation P z ≤ 1 := by unfold uniformCDFDeviation apply csSup_le (range_nonempty _) rintro _ ⟨x, rfl⟩ exact abs_empiricalCDFVec_sub_cdf_le_one P z x -
integrable_uniformCDFDeviationlemma — The uniform empirical-CDF deviation is integrable under every finite product of a population probability law.hypothesesn :ℕP :conclusionProof (Lean source)
@[fun_prop] lemma integrable_uniformCDFDeviation {n : ℕ} (P : Measure ℝ) [IsProbabilityMeasure P] : Integrable (uniformCDFDeviation (m := n) P) (Measure.pi (fun _ : Fin n => P)) := by refine (integrable_const (1 : ℝ)).mono' (measurable_uniformCDFDeviation P).aestronglyMeasurable ?_ filter_upwards with z rw [Real.norm_eq_abs, abs_of_nonneg (uniformCDFDeviation_nonneg P z)] exact uniformCDFDeviation_le_one P z -
integral_uniformCDFDeviation_le_vc_ratetheorem — Given an i.i.d. real sample and a positive sample size, its expected uniform empirical-CDF deviation is at most the VC--McDiarmid radius at confidence 1/n, plus 1/n.hypothesesconclusion∫ ω, uniformCDFDeviation P (fun i : Fin n => S.Z i ω) ∂μ≤ vcMcDiarmidRadius (n : ℝ)⁻¹ n + (n : ℝ)⁻¹Proof (Lean source)
theorem IIDSample.integral_uniformCDFDeviation_le_vc_rate (S : IIDSample Ω ℝ μ P) [IsProbabilityMeasure P] {n : ℕ} (hn : 0 < n) : ∫ ω, uniformCDFDeviation P (fun i : Fin n => S.Z i ω) ∂μ ≤ vcMcDiarmidRadius (n : ℝ)⁻¹ n + (n : ℝ)⁻¹ := by have hnR : 0 < (n : ℝ) := Nat.cast_pos.mpr hn exact S.integral_uniformCDFDeviation_le_radius_add hn (inv_pos.mpr hnR) ((inv_le_one₀ hnR).mpr (by exact_mod_cast hn))
KolmogorovSmirnov 10 core · 4 supporting This module scales the uniform empirical-CDF deviation by the square root of the sample size to obtain the two-sided Kolmogorov--Smirnov statistic and its upper and lower one-sided variants. ★ ksStatistic_tail_at★ ksStatistic_tail★ ksUpperStatistic_tail★ ksStatistic_tail
Finite-sample Kolmogorov--Smirnov bounds
This module scales the uniform empirical-CDF deviation by the square root of
the sample size to obtain the two-sided Kolmogorov--Smirnov statistic and its
upper and lower one-sided variants. For finite sample vectors, all three have
finite-sample tail bounds inherited from the proved VC--McDiarmid radius
theorem. The two-sided and upper bounds are also transported to an arbitrary
IIDSample sample space; this file does not provide the parallel transported
lower bound.
Given a population law and a finite sample vector, the two-sided Kolmogorov--Smirnov statistic is the square root of the sample size times the uniform absolute empirical-CDF deviation.
Definition (Lean source)
Given a population law and a finite sample vector, the upper one-sided Kolmogorov--Smirnov statistic is the square root of the sample size times the supremum of empirical CDF minus population CDF.
Definition (Lean source)
Given a population law and a finite sample vector, the lower one-sided Kolmogorov--Smirnov statistic is the square root of the sample size times the supremum of population CDF minus empirical CDF.
Definition (Lean source)
Given an i.i.d. real sample, a sample size, and an outcome, the sample's two-sided Kolmogorov--Smirnov statistic applies KSStatistic to the first n observations.
Definition (Lean source)
Given an i.i.d. real sample, a sample size, and an outcome, the sample's upper one-sided Kolmogorov--Smirnov statistic applies KSUpperStatistic to the first n observations.
Definition (Lean source)
Given an i.i.d. real sample, a sample size, and an outcome, the sample's lower one-sided Kolmogorov--Smirnov statistic applies KSLowerStatistic to the first n observations.
Definition (Lean source)
KS tail at an arbitrary threshold. Given a population probability law, a positive sample size, and a positive threshold, the product-law probability that the two-sided KS statistic exceeds t is at most 8 * (n+1) * exp (-t² / 32).
Formal statement
Proof (Lean source)
Finite-sample KS tail bound from VC--McDiarmid. Given a population probability law, a positive sample size, and a confidence level between zero and one, the product-law probability that the two-sided KS statistic exceeds the VC--McDiarmid critical value is at most α.
Formal statement
Proof (Lean source)
One-sided finite-sample KS tail bound from VC--McDiarmid. Given a population probability law, a positive sample size, and a confidence level between zero and one, the product-law probability that the upper one-sided KS statistic exceeds the VC--McDiarmid critical value is at most α.
Formal statement
Proof (Lean source)
For an i.i.d. real sample, a positive sample size, and a confidence level between zero and one, the probability that its KS statistic exceeds the VC--McDiarmid critical value is at most α.
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
ksUpperStatistic_tail_attheorem — Given a population probability law, a positive sample size, and a positive threshold, the product-law probability that the upper one-sided KS statistic exceeds t is at most 8 * (n+1) * exp (-t² / 32).hypothesesconclusion(Measure.pi (fun _ : Fin n => P)) {z | t < KSUpperStatistic P z}Proof (Lean source)
theorem ksUpperStatistic_tail_at (P : Measure ℝ) [IsProbabilityMeasure P] {n : ℕ} (hn : 0 < n) {t : ℝ} (ht : 0 < t) : (Measure.pi (fun _ : Fin n => P)) {z | t < KSUpperStatistic P z} ≤ ofReal (8 * ((n : ℝ) + 1) * exp (-(t ^ 2) / 32)) := by have hnR : 0 < (n : ℝ) := Nat.cast_pos.mpr hn have hsqrt : 0 < sqrt (n : ℝ) := Real.sqrt_pos.2 hnR have hsqrt_sq : sqrt (n : ℝ) ^ 2 = n := Real.sq_sqrt hnR.le have hset : {z : Fin n → ℝ | t < KSUpperStatistic P z} = upperCDFBadSet P (t / sqrt n) := by ext z change t < sqrt (n : ℝ) * upperCDFDeviation P z ↔ t / sqrt (n : ℝ) < upperCDFDeviation P z constructor · intro h rw [div_lt_iff₀ hsqrt] simpa [mul_comm] using h · intro h rw [div_lt_iff₀ hsqrt] at h simpa [mul_comm] using h rw [hset] have hmain := empiricalCDF_vc_mcdiarmid_upper P hn (div_pos ht hsqrt) convert hmain using 1 congr 3 field_simp [hsqrt.ne'] exact congrArg (fun x : ℝ => -x) hsqrt_sq -
ksLowerStatistic_tail_attheorem — Given a population probability law, a positive sample size, and a positive threshold, the product-law probability that the lower one-sided KS statistic exceeds t is at most 8 * (n+1) * exp (-t² / 32).hypothesesconclusion(Measure.pi (fun _ : Fin n => P)) {z | t < KSLowerStatistic P z}Proof (Lean source)
theorem ksLowerStatistic_tail_at (P : Measure ℝ) [IsProbabilityMeasure P] {n : ℕ} (hn : 0 < n) {t : ℝ} (ht : 0 < t) : (Measure.pi (fun _ : Fin n => P)) {z | t < KSLowerStatistic P z} ≤ ofReal (8 * ((n : ℝ) + 1) * exp (-(t ^ 2) / 32)) := by have hnR : 0 < (n : ℝ) := Nat.cast_pos.mpr hn have hsqrt : 0 < sqrt (n : ℝ) := Real.sqrt_pos.2 hnR have hsqrt_sq : sqrt (n : ℝ) ^ 2 = n := Real.sq_sqrt hnR.le have hset : {z : Fin n → ℝ | t < KSLowerStatistic P z} = lowerCDFBadSet P (t / sqrt n) := by ext z change t < sqrt (n : ℝ) * lowerCDFDeviation P z ↔ t / sqrt (n : ℝ) < lowerCDFDeviation P z constructor · intro h rw [div_lt_iff₀ hsqrt] simpa [mul_comm] using h · intro h rw [div_lt_iff₀ hsqrt] at h simpa [mul_comm] using h rw [hset] have hmain := empiricalCDF_vc_mcdiarmid_lower P hn (div_pos ht hsqrt) convert hmain using 1 congr 3 field_simp [hsqrt.ne'] exact congrArg (fun x : ℝ => -x) hsqrt_sq -
ksLowerStatistic_tailtheorem — Given a population probability law, a positive sample size, and a confidence level between zero and one, the product-law probability that the lower one-sided KS statistic exceeds the VC--McDiarmid critical value is at most α.hypothesesconclusion≤ ofReal αProof (Lean source)
theorem ksLowerStatistic_tail (P : Measure ℝ) [IsProbabilityMeasure P] {n : ℕ} (hn : 0 < n) {α : ℝ} (hα : 0 < α) (hα_one : α ≤ 1) : (Measure.pi (fun _ : Fin n => P)) {z | sqrt n * vcMcDiarmidRadius α n < KSLowerStatistic P z} ≤ ofReal α := by have hsqrt : 0 < sqrt (n : ℝ) := Real.sqrt_pos.2 (Nat.cast_pos.mpr hn) calc (Measure.pi (fun _ : Fin n => P)) {z | sqrt n * vcMcDiarmidRadius α n < KSLowerStatistic P z} ≤ (Measure.pi (fun _ : Fin n => P)) (fixedCDFBadSet P (vcMcDiarmidRadius α n)) := by apply measure_mono intro z hz change sqrt (n : ℝ) * vcMcDiarmidRadius α n < sqrt (n : ℝ) * lowerCDFDeviation P z at hz change vcMcDiarmidRadius α n < uniformCDFDeviation P z exact ((mul_lt_mul_iff_of_pos_left hsqrt).mp hz).trans_le (lowerCDFDeviation_le_uniformCDFDeviation P z) _ ≤ ofReal α := empiricalCDF_vc_mcdiarmid_radius P hn hα hα_one -
ksUpperStatistic_tailtheorem — For an i.i.d. real sample, a positive sample size, and a confidence level between zero and one, the probability that its upper one-sided KS statistic exceeds the VC--McDiarmid critical value is at most α.Proof (Lean source)
theorem IIDSample.ksUpperStatistic_tail (S : IIDSample Ω ℝ μ P) [IsProbabilityMeasure P] {n : ℕ} (hn : 0 < n) {α : ℝ} (hα : 0 < α) (hα_one : α ≤ 1) : μ {ω | sqrt n * vcMcDiarmidRadius α n < S.ksUpperStatistic n ω} ≤ ofReal α := by let sampleVec : Ω → (Fin n → ℝ) := fun ω i => S.Z i ω calc μ {ω | sqrt n * vcMcDiarmidRadius α n < S.ksUpperStatistic n ω} ≤ μ (sampleVec ⁻¹' fixedCDFBadSet P (vcMcDiarmidRadius α n)) := by apply measure_mono intro ω hω have hsqrt : 0 < sqrt (n : ℝ) := Real.sqrt_pos.2 (Nat.cast_pos.mpr hn) change sqrt (n : ℝ) * vcMcDiarmidRadius α n < sqrt (n : ℝ) * upperCDFDeviation P (sampleVec ω) at hω change vcMcDiarmidRadius α n < uniformCDFDeviation P (sampleVec ω) exact ((mul_lt_mul_iff_of_pos_left hsqrt).mp hω).trans_le (upperCDFDeviation_le_uniformCDFDeviation P (sampleVec ω)) _ = (Measure.pi (fun _ : Fin n => P)) (fixedCDFBadSet P (vcMcDiarmidRadius α n)) := by rw [← iidSample_finN_pushforward S n, Measure.map_apply (iidSample_finN_measurable S n) (measurableSet_fixedCDFBadSet P _)] _ ≤ ofReal α := empiricalCDF_vc_mcdiarmid_radius P hn hα hα_one
VCMcDiarmid 5 core · 3 supporting This module proves a distribution-free finite-sample exponential bound for the uniform empirical-CDF deviation under a canonical iid product law. ★ empiricalCDF_vc_mcdiarmid_large
A VC--McDiarmid bound for uniform empirical-CDF deviation
This module proves a distribution-free finite-sample exponential bound for the
uniform empirical-CDF deviation under a canonical iid product law. Real lower
half-lines have at most n+1 traces on an n-point sample. Finite-pattern
Rademacher control, symmetrization, and McDiarmid's inequality therefore give
the following distribution-free VC bound
8 * (n+1) * exp (-n * ε^2 / 32).
The module also provides upper and lower one-sided forms. The sharp
Dvoretzky--Kiefer--Wolfowitz--Massart bound 2 * exp (-2 * n * ε^2) remains
outside its scope.
For a population law on the real line and a finite sample vector, the upper one-sided empirical-CDF deviation is the supremum of the empirical CDF minus the population CDF over all real thresholds.
Definition (Lean source)
For a population law on the real line and a finite sample vector, the lower one-sided empirical-CDF deviation is the supremum of the population CDF minus the empirical CDF over all real thresholds.
Definition (Lean source)
For a population law and a deviation threshold, the upper one-sided empirical-CDF bad set contains the sample vectors whose upper deviation is greater than that threshold.
Definition (Lean source)
For a population law and a deviation threshold, the lower one-sided empirical-CDF bad set contains the sample vectors whose lower deviation is greater than that threshold.
Definition (Lean source)
Given a population probability law, a positive sample size, a positive threshold, and the large-threshold condition, the uniform empirical-CDF tail is at most exp (-n * ε² / 8).
Formal statement
Proof (Lean source)
3 supporting declarations (lemmas, instances)
-
empiricalCDF_vc_mcdiarmidtheorem — Given an arbitrary population probability law on the real line, a positive sample size, and a positive deviation threshold, the product-law probability that the empirical CDF differs uniformly from the population CDF by more than that threshold is at most 8 * (n+1) * exp (-n * ε² / 32).hypothesesconclusion(Measure.pi (fun _ : Fin n => ρ)) (fixedCDFBadSet ρ ε)Proof (Lean source)
theorem empiricalCDF_vc_mcdiarmid (ρ : Measure ℝ) [IsProbabilityMeasure ρ] {n : ℕ} (hn : 0 < n) {ε : ℝ} (hε : 0 < ε) : (Measure.pi (fun _ : Fin n => ρ)) (fixedCDFBadSet ρ ε) ≤ ofReal (8 * ((n : ℝ) + 1) * exp (-((n : ℝ) * ε ^ 2) / 32)) := by apply (ENNReal.toReal_le_toReal (measure_ne_top _ _) ENNReal.ofReal_ne_top).1 rw [ENNReal.toReal_ofReal] · exact empiricalCDF_vc_mcdiarmid_toReal ρ hn hε · positivity -
empiricalCDF_vc_mcdiarmid_uppertheorem — Given an arbitrary population probability law on the real line, a positive sample size, and a positive deviation threshold, the product-law probability that the empirical CDF exceeds the population CDF somewhere by more than that threshold is at most 8 * (n+1) * exp (-n * ε² / 32).hypothesesconclusion(Measure.pi (fun _ : Fin n => ρ)) (upperCDFBadSet ρ ε)Proof (Lean source)
theorem empiricalCDF_vc_mcdiarmid_upper (ρ : Measure ℝ) [IsProbabilityMeasure ρ] {n : ℕ} (hn : 0 < n) {ε : ℝ} (hε : 0 < ε) : (Measure.pi (fun _ : Fin n => ρ)) (upperCDFBadSet ρ ε) ≤ ofReal (8 * ((n : ℝ) + 1) * exp (-((n : ℝ) * ε ^ 2) / 32)) := by have hmono : (Measure.pi (fun _ : Fin n => ρ)) (upperCDFBadSet ρ ε) ≤ (Measure.pi (fun _ : Fin n => ρ)) (fixedCDFBadSet ρ ε) := by apply measure_mono intro x hx change ε < upperCDFDeviation ρ x at hx change ε < uniformCDFDeviation ρ x exact hx.trans_le (upperCDFDeviation_le_uniformCDFDeviation ρ x) exact hmono.trans (empiricalCDF_vc_mcdiarmid ρ hn hε) -
empiricalCDF_vc_mcdiarmid_lowertheorem — Given an arbitrary population probability law on the real line, a positive sample size, and a positive deviation threshold, the product-law probability that the population CDF exceeds the empirical CDF somewhere by more than that threshold is at most 8 * (n+1) * exp (-n * ε² / 32).hypothesesconclusion(Measure.pi (fun _ : Fin n => ρ)) (lowerCDFBadSet ρ ε)Proof (Lean source)
theorem empiricalCDF_vc_mcdiarmid_lower (ρ : Measure ℝ) [IsProbabilityMeasure ρ] {n : ℕ} (hn : 0 < n) {ε : ℝ} (hε : 0 < ε) : (Measure.pi (fun _ : Fin n => ρ)) (lowerCDFBadSet ρ ε) ≤ ofReal (8 * ((n : ℝ) + 1) * exp (-((n : ℝ) * ε ^ 2) / 32)) := by have hmono : (Measure.pi (fun _ : Fin n => ρ)) (lowerCDFBadSet ρ ε) ≤ (Measure.pi (fun _ : Fin n => ρ)) (fixedCDFBadSet ρ ε) := by apply measure_mono intro x hx change ε < lowerCDFDeviation ρ x at hx change ε < uniformCDFDeviation ρ x exact hx.trans_le (lowerCDFDeviation_le_uniformCDFDeviation ρ x) exact hmono.trans (empiricalCDF_vc_mcdiarmid ρ hn hε)