Stat.Quantile

Quantile processes: empirical quantiles, Bahadur representations, and joint sample-quantile asymptotics.

Sample­Quantile­Bahadur 7 core · 15 supporting · 3 submodules This umbrella module re-exports the derived Bahadur representation for the ordinary empirical sample quantile.
Empirical­CDF 7 core · 12 supporting This file defines the empirical cumulative distribution function of a real i.i.d. ★ cdfIF_variance★ empiricalCDF_isAsymLinear★ empiricalCDF_tendsto_normal★ 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.

def cdfStat reviewed
Causalean.Stat

The indicator statistic 1{· ≤ y} : ℝ → ℝ of the lower-ray event.

Definition (Lean source)
noncomputable def cdfStat (y : ℝ) : ℝ → ℝ := indicator (Iic y) (fun _ => (1 : ℝ))
def empiricalCDF reviewed
Causalean.Stat.IIDSample

The empirical cumulative distribution function F̂ₙ(y) = (1/n) Σ_{i<n} 1{Z_i ≤ y}, the sampleMean of cdfStat y.

Definition (Lean source)
noncomputable def IIDSample.empiricalCDF (S : IIDSample Ω ℝ μ P) (y : ℝ) : ℕ → Ω → ℝ := S.sampleMean (cdfStat y)
Causalean.Stat.IIDSample.empiricalCDF · Causalean/Stat/Quantile/EmpiricalCDF.lean:92 · uses IIDSample
def cdfIF reviewed
Causalean.Stat

The fixed-y influence function of the empirical cdf: cdfIF P y z = 1{z ≤ y} − F(y).

Definition (Lean source)
noncomputable def cdfIF (P : Measure ℝ) (y : ℝ) : ℝ → ℝ := fun z => cdfStat y z - cdf P y
lemma cdfIF_variance reviewed
Causalean.Stat

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
∫ z, (cdfIF P y z) ^ 2 ∂P = cdf P y * (1 - cdf P y)
Proof (Lean source)
lemma cdfIF_variance [IsProbabilityMeasure P] (y : ℝ) : ∫ z, (cdfIF P y z) ^ 2 ∂P = cdf P y * (1 - cdf P y) := by have hstat_int : Integrable (cdfStat y) P := integrable_cdfStat y -- `(1{·} − F)² = 1{·} − 2F·1{·} + F²` via idempotence of the indicator. have hexpand : (fun z => (cdfIF P y z) ^ 2) = (fun z => cdfStat y z - 2 * cdf P y * cdfStat y z + (cdf P y) ^ 2) := by funext z simp only [cdfIF] rw [show (cdfStat y z - cdf P y) ^ 2 = (cdfStat y z) ^ 2 - 2 * cdf P y * cdfStat y z + (cdf P y) ^ 2 from by ring, cdfStat_sq y z] have h1 : Integrable (fun z => cdfStat y z - 2 * cdf P y * cdfStat y z) P := hstat_int.sub (hstat_int.const_mul (2 * cdf P y)) rw [hexpand, integral_add h1 (integrable_const _), integral_sub hstat_int (hstat_int.const_mul (2 * cdf P y)), integral_const_mul] simp only [integral_cdfStat, integral_const, probReal_univ, one_smul] ring
Causalean.Stat.cdfIF_variance · Causalean/Stat/Quantile/EmpiricalCDF.lean:139 · uses cdfIF
lemma empiricalCDF_isAsymLinear reviewed
Causalean.Stat

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
S :
IIDSample Ω ℝ μ P
y :
IsAsymLinear (S.empiricalCDF y) (cdf P y) (cdfIF P y) S (fun m => range m) where mean_zero
Proof (Lean source)
lemma empiricalCDF_isAsymLinear (S : IIDSample Ω ℝ μ P) (y : ℝ) : IsAsymLinear (S.empiricalCDF y) (cdf P y) (cdfIF P y) S (fun m => range m) where mean_zero := cdfIF_mean_zero y finite_var := cdfIF_sq_integrable y remainder := by have hzero : (fun 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 ω)) = (fun _ _ => (0 : ℝ)) := by funext n ω; rw [rescaledEmpiricalCDF_eq_normalizedSum S y n ω, sub_self] simpa only [hzero] using (isLittleOp_zero : IsLittleOp (fun _ (_ : Ω) => (0 : ℝ)) (fun _ => (1 : ℝ)) μ)
theorem empiricalCDF_tendsto_normal reviewed
Causalean.Stat

Empirical-cdf central limit theorem. For an i.i.d. real sample and a threshold y, provided the rescaled empirical-cdf estimator n(F^n(y)F(y))\sqrt n\,(\hat F_n(y)-F(y)) is almost-everywhere measurable at every sample size, the rescaled deviation converges in distribution, as nn\to \infty, to the centered Gaussian law with variance F(y)(1F(y))F(y)(1-F(y)), where FF is the population cdf and F^n\hat F_n the empirical cdf.

Formal statement
S :
IIDSample Ω ℝ μ P
y :
hθn_meas :
∀ n : ℕ,
AEMeasurable (IsAsymLinear.rescaledEstimator (S.empiricalCDF y) (cdf P y) (fun m => range m) n) μ
Tendsto_dist (IsAsymLinear.rescaledEstimator (S.empiricalCDF y) (cdf P y) (fun m => range m)) (gaussianMeasure 0 (cdf P y * (1 - cdf P y))) μ hθn_meas
Proof (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) μ) : Tendsto_dist (IsAsymLinear.rescaledEstimator (S.empiricalCDF y) (cdf P y) (fun m => range m)) (gaussianMeasure 0 (cdf P y * (1 - cdf P y))) μ hθn_meas := by have h := (empiricalCDF_isAsymLinear S y).tendsto_normal (measurable_cdfIF y) hθn_meas rwa [cdfIF_variance] at h
theorem empiricalCDF_tendsto_inProb reviewed
Causalean.Stat

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
S :
IIDSample Ω ℝ μ P
y :
Tendsto_inProb (S.empiricalCDF y) (fun _ => cdf P y) μ
Proof (Lean source)
theorem empiricalCDF_tendsto_inProb (S : IIDSample Ω ℝ μ P) (y : ℝ) : Tendsto_inProb (S.empiricalCDF y) (fun _ => cdf P y) μ := by have h := S.sampleMean_tendsto_inProb (measurable_cdfStat y) (integrable_cdfStat y) rw [integral_cdfStat] at h exact h
12 supporting declarations (lemmas, instances)
Sample­Quantile 5 core · 3 supporting This file develops the influence-function and asymptotic-normality layer for sample quantiles of an i.i.d. ★ quantileIF_variance★ 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.

def quantileIF reviewed
Causalean.Stat

The sample-quantile influence function ψ_τ(z) = (τ − 1{z ≤ q₀}) / f₀.

Definition (Lean source)
noncomputable def quantileIF (τ q₀ f₀ : ℝ) : ℝ → ℝ := fun z => (τ - cdfStat q₀ z) / f₀
lemma quantileIF_variance reviewed
Causalean.Stat

Variance of the quantile influence function. Provided q₀ is the population τ-quantile, i.e. the population cdf satisfies F(q0)=τF(q_0)=\tau, the second moment of the influence function ψτ\psi_\tau under the population measure equals τ(1τ)/f02\tau(1-\tau)/f_0^2, the classical sample-quantile asymptotic variance.

Formal statement
τ q₀ f₀ :
hcdf :
cdf P q₀ = τ
∫ z, (quantileIF τ q₀ f₀ z) ^ 2 ∂P = τ * (1 - τ) / f₀ ^ 2
Proof (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
Causalean.Stat.quantileIF_variance · Causalean/Stat/Quantile/SampleQuantile.lean:109 · uses quantileIF
structure QuantileRegularity reviewed
Causalean.Stat

Quantile-estimator regularity. Bundles the analytic and empirical-process hypotheses under which a quantile-estimator sequence q^nq̂_n is n\sqrt n-asymptotically linear for the τ\tau-quantile q0q_0 of PP with density f0f_0: the level lies in the open unit interval τ(0,1)\tau \in (0,1), the density at the quantile is positive, q0q_0 is indeed the population τ\tau-quantile, i.e. the cdf satisfies F(q0)=τF(q_0) = \tau, the cdf is differentiable at q0q_0 with derivative f0f_0, so that τ(1τ)/f02\tau(1-\tau)/f_0^2 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)
S :
IIDSample Ω ℝ μ P
qn :
ℕ → Ω → ℝ
τ q₀ f₀ :
tau_pos :
0 < τ
tau_lt_one :
τ < 1
density_pos :
0 < f₀
cdf_eq :
cdf P q₀ = τ
hasDeriv :
HasDerivAt (fun y => cdf P y) f₀ q₀
bahadur :
IsLittleOp (fun n ω => sqrt ((range n).card : ℝ) * (qn n ω - q₀) - (sqrt ((range n).card : ℝ))⁻¹ * ∑ i ∈ range n, quantileIF τ q₀ f₀ (S.Z i ω)) (fun _ => (1 : ℝ)) μ
Causalean.Stat.QuantileRegularity · Causalean/Stat/Quantile/SampleQuantile.lean:137 · uses IIDSample
lemma isAsymLinear reviewed
Causalean.Stat.QuantileRegularity

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
S :
IIDSample Ω ℝ μ P
qn :
ℕ → Ω → ℝ
τ q₀ f₀ :
h :
QuantileRegularity S qn τ q₀ f₀
IsAsymLinear qn q₀ (quantileIF τ q₀ f₀) S (fun m => range m) where mean_zero
Proof (Lean source)
lemma QuantileRegularity.isAsymLinear {S : IIDSample Ω ℝ μ P} {qn : ℕ → Ω → ℝ} {τ q₀ f₀ : ℝ} (h : QuantileRegularity S qn τ q₀ f₀) : IsAsymLinear qn q₀ (quantileIF τ q₀ f₀) S (fun m => range m) where mean_zero := quantileIF_mean_zero h.cdf_eq finite_var := quantileIF_sq_integrable remainder := h.bahadur
theorem tendsto_normal reviewed
Causalean.Stat.QuantileRegularity

Sample-quantile asymptotic normality. Given a QuantileRegularity witness h for the estimator sequence qn — interior level τ(0,1)\tau\in(0,1), positive density f0f_0 at the population quantile q0q_0, 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 n(q^nq0)\sqrt n\,(\hat q_n-q_0) converges in distribution to the centered Gaussian law with variance τ(1τ)/f02\tau(1-\tau)/f_0^2.

Formal statement
S :
IIDSample Ω ℝ μ P
qn :
ℕ → Ω → ℝ
τ q₀ f₀ :
h :
QuantileRegularity S qn τ q₀ f₀
hθn_meas :
∀ n : ℕ, AEMeasurable (IsAsymLinear.rescaledEstimator qn q₀ (fun m => range m) n) μ
_hSum_meas :
∀ n : ℕ,
AEMeasurable (IsAsymLinear.normalizedSum S (quantileIF τ q₀ f₀) (fun m => range m) n) μ
Tendsto_dist (IsAsymLinear.rescaledEstimator qn q₀ (fun m => range m)) (gaussianMeasure 0 (τ * (1 - τ) / f₀ ^ 2)) μ hθn_meas
Proof (Lean source)
theorem QuantileRegularity.tendsto_normal {S : IIDSample Ω ℝ μ P} {qn : ℕ → Ω → ℝ} {τ q₀ f₀ : ℝ} (h : QuantileRegularity S qn τ q₀ f₀) (hθn_meas : ∀ n : ℕ, AEMeasurable (IsAsymLinear.rescaledEstimator qn q₀ (fun m => range m) n) μ) (_hSum_meas : ∀ n : ℕ, AEMeasurable (IsAsymLinear.normalizedSum S (quantileIF τ q₀ f₀) (fun m => range m) n) μ) : Tendsto_dist (IsAsymLinear.rescaledEstimator qn q₀ (fun m => range m)) (gaussianMeasure 0 (τ * (1 - τ) / f₀ ^ 2)) μ hθn_meas := by have hAL := h.isAsymLinear.tendsto_normal (measurable_quantileIF τ q₀ f₀) hθn_meas rwa [quantileIF_variance h.cdf_eq] at hAL
3 supporting declarations (lemmas, instances)
Empirical­Quantile 5 core · 3 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.

def empiricalMeasure reviewed
Causalean.Stat.IIDSample

The empirical measure νₙ = (1/n) Σ_{i<n} δ_{Zᵢ} of an i.i.d. sample.

Definition (Lean source)
noncomputable def IIDSample.empiricalMeasure (S : IIDSample Ω ℝ μ P) (n : ℕ) (ω : Ω) : Measure ℝ := (n : ℝ≥0∞)⁻¹ • ∑ i ∈ range n, Measure.dirac (S.Z i ω)
Causalean.Stat.IIDSample.empiricalMeasure · Causalean/Stat/Quantile/EmpiricalQuantile.lean:57 · uses IIDSample
lemma empiricalMeasure_cdf reviewed
Causalean.Stat.IIDSample

cdf bridge. For a positive sample size nn, 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
S :
IIDSample Ω ℝ μ P
n :
hn :
0 < n
ω :
Ω
y :
cdf (S.empiricalMeasure n ω) y = S.empiricalCDF y n ω
Proof (Lean source)
lemma IIDSample.empiricalMeasure_cdf (S : IIDSample Ω ℝ μ P) {n : ℕ} (hn : 0 < n) (ω : Ω) (y : ℝ) : cdf (S.empiricalMeasure n ω) y = S.empiricalCDF y n ω := by haveI := S.empiricalMeasure_isProbabilityMeasure hn ω rw [cdf_eq_real, S.empiricalMeasure_real_Iic hn ω y]
def sampleQuantile reviewed
Causalean.Stat.IIDSample

The sample τ-quantile q̂ₙ(τ) = quantile νₙ τ, the generalized inverse of the empirical cdf.

Definition (Lean source)
noncomputable def IIDSample.sampleQuantile (S : IIDSample Ω ℝ μ P) (τ : ℝ) : ℕ → Ω → ℝ := fun n ω => quantile (S.empiricalMeasure n ω) τ
Causalean.Stat.IIDSample.sampleQuantile · Causalean/Stat/Quantile/EmpiricalQuantile.lean:106 · uses IIDSample
lemma sampleQuantile_le_iff reviewed
Causalean.Stat.IIDSample

Switching relation. For a positive sample size nn and an interior quantile level τ(0,1)\tau\in(0,1), the sample τ\tau-quantile q^n(τ)\hat q_n(\tau) is at most a given point x exactly when τ\tau is at most the empirical cdf at x.

Formal statement
S :
IIDSample Ω ℝ μ P
n :
hn :
0 < n
ω :
Ω
τ :
hτ0 :
0 < τ
hτ1 :
τ < 1
x :
S.sampleQuantile τ n ω ≤ x ↔ τ ≤ S.empiricalCDF x n ω
Proof (Lean source)
lemma IIDSample.sampleQuantile_le_iff (S : IIDSample Ω ℝ μ P) {n : ℕ} (hn : 0 < n) (ω : Ω) {τ : ℝ} (hτ0 : 0 < τ) (hτ1 : τ < 1) (x : ℝ) : S.sampleQuantile τ n ω ≤ x ↔ τ ≤ S.empiricalCDF x n ω := by haveI := S.empiricalMeasure_isProbabilityMeasure hn ω rw [IIDSample.sampleQuantile, quantile_le_iff hτ0 hτ1, S.empiricalMeasure_cdf hn ω]
lemma sampleQuantile_atom_bound reviewed
Causalean.Stat.IIDSample

Atom bound. If the population cdf FF is continuous, i.e. the population is atomless, the sample size nn is positive, and the quantile level τ\tau is interior, 0<τ<10<\tau<1, then almost surely the empirical cdf evaluated at the sample τ\tau-quantile q^n(τ)\hat q_n(\tau) deviates from τ\tau by at most 1/n1/n.

Formal statement
S :
IIDSample Ω ℝ μ P
hcont :
Continuous (fun y => cdf P y)
n :
hn :
0 < n
τ :
hτ0 :
0 < τ
hτ1 :
τ < 1
∀ᵐ ω ∂μ, |S.empiricalCDF (S.sampleQuantile τ n ω) n ω - τ| ≤ (n : ℝ)⁻¹
Proof (Lean source)
lemma IIDSample.sampleQuantile_atom_bound [IsProbabilityMeasure μ] (S : IIDSample Ω ℝ μ P) (hcont : Continuous (fun y => cdf P y)) {n : ℕ} (hn : 0 < n) {τ : ℝ} (hτ0 : 0 < τ) (hτ1 : τ < 1) : ∀ᵐ ω ∂μ, |S.empiricalCDF (S.sampleQuantile τ n ω) n ω - τ| ≤ (n : ℝ)⁻¹ := by -- `P` is atomless: `Continuous (cdf P)` ⇒ no jumps ⇒ every singleton is null. haveI hP : IsProbabilityMeasure P := by rw [← S.law] exact isProbabilityMeasure_map (S.meas 0).aemeasurable haveI hPna : NullSingletonClass P := by refine ⟨fun x => ?_⟩ have heq : P = (cdf P).measure := (measure_cdf P).symm rw [heq, StieltjesFunction.measure_singleton, ContinuousWithinAt.leftLim_eq (hcont.continuousWithinAt), sub_self, ENNReal.ofReal_zero] -- Each coordinate has law `P`. have hlaw : ∀ i : ℕ, μ.map (S.Z i) = P := fun i => (S.identDist i).map_eq.symm.trans S.law -- Pairwise a.s. distinctness: `μ{Zᵢ = Zⱼ} = 0` for `i ≠ j` (independence + atomless law). have hpair : ∀ i j : ℕ, i ≠ j → μ {ω | S.Z i ω = S.Z j ω} = 0 := by intro i j hij have hind : IndepFun (S.Z i) (S.Z j) μ := S.indep.indepFun hij have hmeas : MeasurableSet {p : ℝ × ℝ | p.1 = p.2} := measurableSet_eq_fun measurable_fst measurable_snd have hpre : {ω | S.Z i ω = S.Z j ω} = (fun ω => (S.Z i ω, S.Z j ω)) ⁻¹' {p : ℝ × ℝ | p.1 = p.2} := rfl rw [hpre, ← Measure.map_apply ((S.meas i).prodMk (S.meas j)) hmeas, (indepFun_iff_map_prod_eq_prod_map_map (S.meas i).aemeasurable (S.meas j).aemeasurable).mp hind, hlaw i, hlaw j, Measure.measure_prod_null hmeas] refine Filter.Eventually.of_forall (fun x => ?_) have hsing : (Prod.mk x ⁻¹' {p : ℝ × ℝ | p.1 = p.2}) = {x} := by ext y; simp [eq_comm] simp [hsing, measure_singleton] -- Assemble into one a.s. tie-free event on `range n`. have hae : ∀ᵐ ω ∂μ, ∀ i ∈ (Finset.range n : Set ℕ), ∀ j ∈ (Finset.range n : Set ℕ), i ≠ j → S.Z i ω ≠ S.Z j ω := by rw [ae_ball_iff (Set.to_countable _)] intro i _ rw [ae_ball_iff (Set.to_countable _)] intro j _ by_cases hij : i = j · exact ae_of_all _ (fun ω hne => absurd hij hne) · rw [ae_iff] have heqset : {ω | ¬ (i ≠ j → S.Z i ω ≠ S.Z j ω)} = {ω | S.Z i ω = S.Z j ω} := by ext ω; simp [hij] rw [heqset, hpair i j hij] -- The empirical-cdf sum counts the sample points below the threshold. have hcard : ∀ (x : ℝ) (ω : Ω), ∑ i ∈ Finset.range n, cdfStat x (S.Z i ω) = (((Finset.range n).filter (fun i => S.Z i ω ≤ x)).card : ℝ) := by intro x ω rw [Finset.card_filter] push_cast refine Finset.sum_congr rfl (fun i _ => ?_) unfold cdfStat by_cases h : S.Z i ω ≤ x · rw [Set.indicator_of_mem (Set.mem_Iic.mpr h)]; simp [h] · rw [Set.indicator_of_notMem (by simpa using h)]; simp [h] have hnR : (0 : ℝ) < (n : ℝ) := by exact_mod_cast hn filter_upwards [hae] with ω haeω set q := S.sampleQuantile τ n ω with hq -- LOWER bound `τ ≤ F̂ₙ(q)` is deterministic (switching at `x = q`, reflexivity). have hlower : τ ≤ S.empiricalCDF q n ω := (S.sampleQuantile_le_iff hn ω hτ0 hτ1 q).mp (le_refl q) -- Strict switching: any `x < q` has `F̂ₙ(x) < τ`. have hstrict : ∀ x : ℝ, x < q → S.empiricalCDF x n ω < τ := by intro x hx by_contra hcon push_neg at hcon exact absurd ((S.sampleQuantile_le_iff hn ω hτ0 hτ1 x).mpr hcon) (not_le.mpr hx) -- Abbreviations for the three counts. set Cle : ℝ → Finset ℕ := fun x => (Finset.range n).filter (fun i => S.Z i ω ≤ x) with hCle set Clt : Finset ℕ := (Finset.range n).filter (fun i => S.Z i ω < q) with hClt set Ceq : Finset ℕ := (Finset.range n).filter (fun i => S.Z i ω = q) with hCeq -- `F̂ₙ(x) = (Cle x).card / n`. have hFcard : ∀ x : ℝ, S.empiricalCDF x n ω = (n : ℝ)⁻¹ * ((Cle x).card : ℝ) := by intro x rw [IIDSample.empiricalCDF, IIDSample.sampleMean, hcard x ω] -- `Cle q = Clt ∪ Ceq`, disjointly: `Zᵢ ≤ q ↔ Zᵢ < q ∨ Zᵢ = q`. have hdisj : Disjoint Clt Ceq := by rw [hClt, hCeq, Finset.disjoint_filter] intro i _ hlt heq; exact absurd heq (ne_of_lt hlt) have hunion : Cle q = Clt ∪ Ceq := by rw [hCle, hClt, hCeq, ← Finset.filter_or] refine filter_congr (fun i _ => ?_) exact ⟨fun h => h.lt_or_eq, fun h => h.elim le_of_lt le_of_eq⟩ have hcountsplit : (Cle q).card = Clt.card + Ceq.card := by rw [hunion, Finset.card_union_of_disjoint hdisj] -- Tie-free ⇒ at most one index equals `q`. have hCeq_le : Ceq.card ≤ 1 := by rw [Finset.card_le_one] intro a ha b hb rw [hCeq, mem_filter] at ha hb by_contra hab exact haeω a (by simpa using ha.1) b (by simpa using hb.1) hab (ha.2.trans hb.2.symm) -- Strict part: `(Clt.card : ℝ) ≤ n·τ`, via a threshold `x < q` with `Cle x = Clt`. have hClt_le : (Clt.card : ℝ) ≤ (n : ℝ) * τ := by rcases Finset.eq_empty_or_nonempty Clt with hempty | hne · rw [hempty, Finset.card_empty, cast_zero]; positivity · -- `m = max{Zᵢ : Zᵢ < q}`; choose threshold `x = m < q`, then `Cle m = Clt`. set T : Finset ℝ := Clt.image (fun i => S.Z i ω) with hT have hTne : T.Nonempty := hne.image _ set m : ℝ := T.max' hTne with hm have hmlt : m < q := by obtain ⟨a, haT, ham⟩ := Finset.mem_image.mp (T.max'_mem hTne) rw [hClt, mem_filter] at haT rw [hm, ← ham]; exact haT.2 have hCleq : Cle m = Clt := by rw [hCle, hClt] refine filter_congr (fun i hi => ?_) constructor · intro hle; exact lt_of_le_of_lt hle hmlt · intro hlt refine Finset.le_max' T _ ?_ rw [hT] exact Finset.mem_image.mpr ⟨i, by rw [hClt, mem_filter]; exact ⟨hi, hlt⟩, rfl⟩ have hlt2 : S.empiricalCDF m n ω < τ := hstrict m hmlt rw [hFcard m, hCleq] at hlt2 -- `(n)⁻¹ * card < τ` ⟹ `card < n·τ`. have hkey := (inv_mul_lt_iff₀ hnR).mp hlt2 linarith [hkey] -- Combine: `n·F̂ₙ(q) = (Cle q).card ≤ n·τ + 1`, so `F̂ₙ(q) ≤ τ + 1/n`. have hupper : S.empiricalCDF q n ω ≤ τ + (n : ℝ)⁻¹ := by rw [hFcard q, hcountsplit] push_cast rw [mul_add] have h1 : (n : ℝ)⁻¹ * (Clt.card : ℝ) ≤ τ := by rw [inv_mul_le_iff₀ hnR]; linarith [hClt_le] have h2 : (n : ℝ)⁻¹ * (Ceq.card : ℝ) ≤ (n : ℝ)⁻¹ := by have : (Ceq.card : ℝ) ≤ 1 := by exact_mod_cast hCeq_le nlinarith [inv_nonneg.mpr hnR.le, this] linarith rw [abs_le] exact ⟨by linarith [inv_nonneg.mpr hnR.le], by linarith⟩
Causalean.Stat.IIDSample.sampleQuantile_atom_bound · Causalean/Stat/Quantile/EmpiricalQuantile.lean:141 · uses IIDSample , empiricalCDF , sampleQuantile
3 supporting declarations (lemmas, instances)
  • empiricalMeasure_isProbabilityMeasure lemma — For 0 < n the empirical measure is a probability measure.
    S :
    IIDSample Ω ℝ μ P
    n :
    hn :
    0 < n
    ω :
    Ω
    IsProbabilityMeasure (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
    Causalean.Stat.IIDSample.empiricalMeasure_isProbabilityMeasure · Causalean/Stat/Quantile/EmpiricalQuantile.lean:62
  • empiricalMeasure_real_Iic lemma — The empirical measure of the lower ray Iic y is F̂ₙ(y) (as ℝ).
    S :
    IIDSample Ω ℝ μ P
    n :
    _hn :
    0 < n
    ω :
    Ω
    y :
    (S.empiricalMeasure n ω).real (Iic y) = S.empiricalCDF y n ω
    Proof (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]
    Causalean.Stat.IIDSample.empiricalMeasure_real_Iic · Causalean/Stat/Quantile/EmpiricalQuantile.lean:75
  • empiricalCDF_monotone lemma — The empirical cdf is monotone in its real argument y (a sum of monotone lower-ray indicators).
    S :
    IIDSample Ω ℝ μ P
    n :
    ω :
    Ω
    Monotone (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' _
    Causalean.Stat.IIDSample.empiricalCDF_monotone · Causalean/Stat/Quantile/EmpiricalQuantile.lean:123
Quantile 3 core · 7 supporting This file defines the lower quantile function of a real probability 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 probability 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.

def quantileSet reviewed
Causalean.Stat

The defining super-level set of the cdf, {x | τ ≤ cdf μ x}.

Definition (Lean source)
def quantileSet (τ : ℝ) : Set ℝ := {x : ℝ | τ ≤ cdf μ x}
Causalean.Stat.quantileSet · Causalean/Stat/Quantile/Quantile.lean:45
def quantile reviewed
Causalean.Stat

The (lower) quantile function: the left-continuous generalized inverse of the cdf, quantile μ τ = inf {x : ℝ | τ ≤ cdf μ x}.

Definition (Lean source)
noncomputable def quantile (τ : ℝ) : ℝ := sInf (quantileSet μ τ)
theorem quantile_le_iff reviewed
Causalean.Stat

Quantile / cdf Galois connection. For an interior probability level τ(0,1)\tau\in(0,1), the quantile of a real measure at level τ\tau is at most a point x exactly when τ\tau is at most the cdf of that measure at x.

Formal statement
τ x :
hτ0 :
0 < τ
hτ1 :
τ < 1
quantile μ τ ≤ x ↔ τ ≤ cdf μ x
Proof (Lean source)
theorem quantile_le_iff {τ x : ℝ} (hτ0 : 0 < τ) (hτ1 : τ < 1) : quantile μ τ ≤ x ↔ τ ≤ cdf μ x := ⟨le_cdf_of_quantile_le hτ1, quantile_le_of_le_cdf hτ0⟩
Causalean.Stat.quantile_le_iff · Causalean/Stat/Quantile/Quantile.lean:106 · uses quantile
7 supporting declarations (lemmas, instances)
  • quantileSet_up_closed lemma — The super-level set is up-closed (monotonicity of the cdf).
    τ x x' :
    hx :
    x ∈ quantileSet μ τ
    hxx' :
    x ≤ x'
    x' ∈ quantileSet μ τ
    Proof (Lean source)
    lemma quantileSet_up_closed {τ x x' : ℝ} (hx : x ∈ quantileSet μ τ) (hxx' : x ≤ x') : x' ∈ quantileSet μ τ := le_trans hx (monotone_cdf μ hxx')
    Causalean.Stat.quantileSet_up_closed · Causalean/Stat/Quantile/Quantile.lean:54
  • bddBelow_quantileSet lemma — For 0 < τ, the super-level set is bounded below: since cdf μ → 0 at -∞, any point where the cdf already drops below τ is a lower bound.
    τ :
    :
    0 < τ
    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_neg at hlt exact absurd hs (not_le.mpr (hN s hlt.le))
    Causalean.Stat.bddBelow_quantileSet · Causalean/Stat/Quantile/Quantile.lean:59
  • nonempty_quantileSet lemma — For τ < 1, the super-level set is nonempty: since cdf μ → 1 at +∞, some point has cdf above τ.
    τ :
    :
    τ < 1
    (quantileSet μ τ).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⟩
    Causalean.Stat.nonempty_quantileSet · Causalean/Stat/Quantile/Quantile.lean:68
  • le_cdf_quantile lemma — Key membership lemma. For interior τ ∈ (0,1), the quantile lands in the super-level set: τ ≤ cdf μ (quantile μ τ). This is where right-continuity of the cdf is used.
    τ :
    hτ1 :
    τ < 1
    τ ≤ cdf μ (quantile μ τ)
    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
    Causalean.Stat.le_cdf_quantile · Causalean/Stat/Quantile/Quantile.lean:74
  • le_cdf_of_quantile_le lemma — Galois connection (one direction). If the quantile lies at or below x, then the cdf has already reached level τ at x.
    τ x :
    hτ1 :
    τ < 1
    hx :
    quantile μ τ ≤ x
    τ ≤ cdf μ x
    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)
    Causalean.Stat.le_cdf_of_quantile_le · Causalean/Stat/Quantile/Quantile.lean:94
  • quantile_le_of_le_cdf lemma — Galois connection (other direction). If the cdf reaches τ at x, then the quantile is at or below x.
    τ x :
    hτ0 :
    0 < τ
    hx :
    τ ≤ cdf μ x
    quantile μ τ ≤ x
    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
    Causalean.Stat.quantile_le_of_le_cdf · Causalean/Stat/Quantile/Quantile.lean:100
  • quantile_mono lemma — The quantile function is monotone in the probability level τ on (0,1).
    τ τ' :
    hτ0 :
    0 < τ
    hτ'1 :
    τ' < 1
    hττ' :
    τ ≤ τ'
    quantile μ τ ≤ quantile μ τ'
    Proof (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))
    Causalean.Stat.quantile_mono · Causalean/Stat/Quantile/Quantile.lean:113
Sample­Quantile­Joint 6 core · 8 supporting This file proves joint asymptotic normality for a finite vector of sample quantiles. ★ quantileIF_cross★ sampleQuantileVec_isAsymLinearVec★ sampleQuantileVec_tendsto_normal

Joint Normality of a Quantile Vector

This file proves joint asymptotic normality for a finite vector of sample quantiles. It packages the coordinatewise Bahadur representations into vector asymptotic linearity and uses the multivariate CLT to obtain an abstract Gaussian limit with covariance entries determined by quantile influence-function cross-moments.

abbrev eucl reviewed
Causalean.Stat

Pack a coordinate function into Euclidean space (the PiLp 2 synonym).

Definition (Lean source)
noncomputable abbrev eucl (v : Fin k → ℝ) : EuclideanSpace ℝ (Fin k) := (EuclideanSpace.equiv (Fin k) ℝ).symm v
def quantileIFVec reviewed
Causalean.Stat

The joint quantile influence function ψ(z)_j = (τⱼ − 1{z ≤ qⱼ}) / fⱼ, valued in EuclideanSpace ℝ (Fin k).

Definition (Lean source)
noncomputable def quantileIFVec (τ q f : Fin k → ℝ) : ℝ → EuclideanSpace ℝ (Fin k) := fun z => eucl (fun j => quantileIF (τ j) (q j) (f j) z)
def sampleQuantileVec reviewed
Causalean.Stat.IIDSample

The sample-quantile vector (q̂ₙ(τ₁), …, q̂ₙ(τ_k)).

Definition (Lean source)
noncomputable def IIDSample.sampleQuantileVec (S : IIDSample Ω ℝ μ P) (τ : Fin k → ℝ) : ℕ → Ω → EuclideanSpace ℝ (Fin k) := fun n ω => eucl (fun j => S.sampleQuantile (τ j) n ω)
Causalean.Stat.IIDSample.sampleQuantileVec · Causalean/Stat/Quantile/SampleQuantileJoint.lean:67 · uses IIDSample
lemma quantileIF_cross reviewed
Causalean.Stat

Covariance entry. Given qⱼ is the population τⱼ-quantile: F(qj)=τjF(q_j)=\tau_j and qₗ is the population τₗ-quantile: F(ql)=τlF(q_l)=\tau_l, the cross-moment of the two quantile influence functions ψτj\psi_{\tau_j} and ψτl\psi_{\tau_l} under the population measure equals (min(τj,τl)τjτl)/(fjfl)(\min(\tau_j,\tau_l)-\tau_j\tau_l)/(f_jf_l).

Formal statement
τj qj fj τl ql fl :
hj :
cdf P qj = τj
hl :
cdf P ql = τl
∫ z, quantileIF τj qj fj z * quantileIF τl ql fl z ∂P = (min τj τl - τj * τl) / (fj * fl)
Proof (Lean source)
lemma quantileIF_cross [IsProbabilityMeasure P] {τj qj fj τl ql fl : ℝ} (hj : cdf P qj = τj) (hl : cdf P ql = τl) : ∫ z, quantileIF τj qj fj z * quantileIF τl ql fl z ∂P = (min τj τl - τj * τl) / (fj * fl) := by -- Product of two lower-ray indicators is the indicator of the smaller ray. have hprod : ∀ z, cdfStat qj z * cdfStat ql z = cdfStat (min qj ql) z := by intro z simp only [cdfStat, Set.indicator_apply, Set.mem_Iic, le_min_iff] by_cases hzj : z ≤ qj <;> by_cases hzl : z ≤ ql <;> simp [hzj, hzl] -- The cdf of the min equals the min of the cdfs (by monotonicity). have hmin : cdf P (min qj ql) = min τj τl := by rcases le_total qj ql with hq | hq · rw [min_eq_left hq, hj, min_eq_left] rw [← hj, ← hl]; exact monotone_cdf P hq · rw [min_eq_right hq, hl, min_eq_right] rw [← hj, ← hl]; exact monotone_cdf P hq -- Expand the product of influence functions. have hexpand : (fun z => quantileIF τj qj fj z * quantileIF τl ql fl z) = (fun z => (τj * τl - τj * cdfStat ql z - τl * cdfStat qj z + cdfStat (min qj ql) z) / (fj * fl)) := by funext z unfold quantileIF rw [div_mul_div_comm, ← hprod z]; ring rw [hexpand] have hil : Integrable (cdfStat ql) P := integrable_cdfStat ql have hij : Integrable (cdfStat qj) P := integrable_cdfStat qj have him : Integrable (cdfStat (min qj ql)) P := integrable_cdfStat (min qj ql) rw [integral_div] have e1 : ∫ z, (τj * τl - τj * cdfStat ql z - τl * cdfStat qj z + cdfStat (min qj ql) z) ∂P = τj * τl - τj * cdf P ql - τl * cdf P qj + cdf P (min qj ql) := by have hB : Integrable (fun z => τj * τl - τj * cdfStat ql z) P := (integrable_const (τj * τl)).sub (hil.const_mul τj) have hC : Integrable (fun z => τl * cdfStat qj z) P := hij.const_mul τl have hA : Integrable (fun z => τj * τl - τj * cdfStat ql z - τl * cdfStat qj z) P := hB.sub hC rw [integral_add hA him, integral_sub hB hC, integral_sub (integrable_const (τj * τl)) (hil.const_mul τj)] simp only [integral_const, probReal_univ, one_smul, integral_const_mul, integral_cdfStat] rw [e1, hl, hj, hmin] ring
theorem sampleQuantileVec_isAsymLinearVec reviewed
Causalean.Stat.IIDSample

The sample-quantile vector is asymptotically linear with the joint influence function ψ. Given a SampleQuantileReg regularity bundle at every coordinate j: interior level τj\tau_j, positive density fjf_j at the population quantile qjq_j, cdf identification, differentiability of the population cdf, and an atomless population, the vector of sample τ\tau-quantiles is jointly asymptotically linear at the vector of population quantiles, with influence function the joint quantile influence function ψ\psi.

Formal statement
S :
IIDSample Ω ℝ μ P
τ q f :
Fin k → ℝ
hreg :
∀ j, SampleQuantileReg P (τ j) (q j) (f j)
IsAsymLinearVec (S.sampleQuantileVec τ) (eucl q) (quantileIFVec τ q f) S (fun m => range m)
Proof (Lean source)
theorem IIDSample.sampleQuantileVec_isAsymLinearVec (S : IIDSample Ω ℝ μ P) {τ q f : Fin k → ℝ} (hreg : ∀ j, SampleQuantileReg P (τ j) (q j) (f j)) : IsAsymLinearVec (S.sampleQuantileVec τ) (eucl q) (quantileIFVec τ q f) S (fun m => range m) := by -- Per-coordinate scalar asymptotic linearity. set AL : ∀ j, IsAsymLinear (S.sampleQuantile (τ j)) (q j) (quantileIF (τ j) (q j) (f j)) S (fun m => range m) := fun j => S.sampleQuantile_isAsymLinear (hreg j) with hAL -- The coordinate influence functions, packaged as `g x = (fun j => quantileIF…)`. set g : ℝ → Fin k → ℝ := fun x j => quantileIF (τ j) (q j) (f j) x with hg -- Coordinatewise bound used throughout. have hcoordbound : ∀ x j, |g x j| ≤ (|τ j| + 1) / |f j| := by intro x j have hc0 : 0 ≤ cdfStat (q j) x := cdfStat_nonneg (q j) x have hc1 : cdfStat (q j) x ≤ 1 := cdfStat_le_one (q j) x have hnum : |τ j - cdfStat (q j) x| ≤ |τ j| + 1 := by rw [abs_le] exact ⟨by have := neg_abs_le (τ j); linarith, by have := le_abs_self (τ j); linarith⟩ change |quantileIF (τ j) (q j) (f j) x| ≤ _ 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 _)) have hg_int : Integrable g P := by -- bounded by a constant (sup-norm ≤ sum of coordinate bounds) on a prob. measure refine (integrable_const (∑ j, (|τ j| + 1) / |f j|)).mono' (measurable_pi_lambda _ (fun j => measurable_quantileIF (τ j) (q j) (f j))).aestronglyMeasurable ?_ filter_upwards with x refine (pi_norm_le_iff_of_nonneg (sum_nonneg fun j _ => div_nonneg (by positivity) (abs_nonneg _))).2 (fun j => ?_) rw [Real.norm_eq_abs] exact (hcoordbound x j).trans (Finset.single_le_sum (f := fun j => (|τ j| + 1) / |f j|) (fun i _ => div_nonneg (by positivity) (abs_nonneg _)) (Finset.mem_univ j)) refine ⟨?_, ?_, ?_⟩ · -- mean_zero : ∫ quantileIFVec = 0 change ∫ x, eucl (g x) ∂P = 0 rw [ContinuousLinearEquiv.integral_comp_comm (EuclideanSpace.equiv (Fin k) ℝ).symm g] have hzero : (∫ x, g x ∂P) = 0 := by funext j have hproj := ContinuousLinearMap.integral_comp_comm (ContinuousLinearMap.proj (R := ℝ) (φ := fun _ : Fin k => ℝ) j) hg_int simp only [ContinuousLinearMap.proj_apply] at hproj rw [← hproj] exact (AL j).mean_zero rw [hzero, map_zero] · -- finite_var : ‖quantileIFVec‖² ∈ L¹(P) have hsum : (fun x => ‖quantileIFVec τ q f x‖ ^ 2) = fun x => ∑ j, (quantileIF (τ j) (q j) (f j) x) ^ 2 := by funext x exact norm_sq_eucl (g x) rw [hsum] exact integrable_finset_sum _ (fun j _ => quantileIF_sq_integrable) · -- remainder : the vector Bahadur remainder is o_p(1) -- The per-coordinate scalar remainder `Rₙⱼ`. set R : Fin k → ℕ → Ω → ℝ := fun j n ω => sqrt ((range n).card : ℝ) * (S.sampleQuantile (τ j) n ω - q j) - (sqrt ((range n).card : ℝ))⁻¹ * ∑ i ∈ range n, quantileIF (τ j) (q j) (f j) (S.Z i ω) with hR have hRlit : ∀ j, IsLittleOp (R j) (fun _ => (1 : ℝ)) μ := fun j => (AL j).remainder -- The vector bracket equals `eucl (fun j => R j n ω)`. have hbracket : ∀ n ω, sqrt (((range n).card : ℝ)) • (S.sampleQuantileVec τ n ω - eucl q) - (sqrt (((range n).card : ℝ)))⁻¹ • ∑ i ∈ range n, quantileIFVec τ q f (S.Z i ω) = eucl (fun j => R j n ω) := by intro n ω change sqrt _ • (eucl (fun j => S.sampleQuantile (τ j) n ω) - eucl q) - (sqrt _)⁻¹ • ∑ i ∈ range n, eucl (g (S.Z i ω)) = eucl (fun j => R j n ω) rw [← map_sub, ← map_smul, ← map_sum, ← map_smul, ← map_sub] congr 1 funext j simp only [Pi.sub_apply, Pi.smul_apply, Finset.sum_apply, smul_eq_mul, hR, hg] -- `∑ⱼ |Rₙⱼ|` is o_p(1), and the vector norm is bounded by it. have hsum_lit : IsLittleOp (fun n ω => ∑ j, |R j n ω|) (fun _ => (1 : ℝ)) μ := isLittleOp_finset_sum_one univ (fun j n ω => |R j n ω|) (fun j _ => isLittleOp_abs (hRlit j)) refine isLittleOp_of_abs_le_const_mul_one (C := 1) one_pos hsum_lit ?_ intro n ω rw [hbracket n ω] rw [abs_of_nonneg (norm_nonneg _), one_mul, abs_of_nonneg (sum_nonneg fun j _ => abs_nonneg _)] exact norm_eucl_le_sum_abs (fun j => R j n ω)
theorem sampleQuantileVec_tendsto_normal reviewed
Causalean.Stat.IIDSample

Joint asymptotic normality of the sample-quantile vector. Given a SampleQuantileReg bundle at every coordinate j, a candidate limit measure Q on the joint quantile space whose characteristic function at every direction t matches exp(12t,ψ2dP)\exp(-\tfrac12\int\langle t,\psi\rangle^2\,dP), the Gaussian shape determined by the joint influence function ψ\psi, and almost-everywhere measurability of the rescaled estimator sequence at every sample size, then the law of the rescaled sample-quantile vector n(q^n(τ)q)\sqrt n(\hat q_n(\tau_\bullet)-q_\bullet) converges weakly to Q as nn\to\infty.

Formal statement
S :
IIDSample Ω ℝ μ P
τ q f :
Fin k → ℝ
hreg :
∀ j, SampleQuantileReg P (τ j) (q j) (f j)
hQ :
∀ t : EuclideanSpace ℝ (Fin k),
charFun Q t = exp (-(((∫ z, (⟪t, quantileIFVec τ q f z⟫) ^ 2 ∂P : ℝ)) : ℂ) / 2)
hθn_meas :
∀ n,
AEMeasurable (IsAsymLinearVec.rescaledEstimator (S.sampleQuantileVec τ) (eucl q) (fun m => range m) n) μ
Tendsto (β := ProbabilityMeasure (EuclideanSpace ℝ (Fin k))) (fun n => ⟨μ.map (IsAsymLinearVec.rescaledEstimator (S.sampleQuantileVec τ) (eucl q) (fun m => range m) n), Measure.isProbabilityMeasure_map (hθn_meas n)⟩) atTop (𝓝 ⟨Q, ‹IsProbabilityMeasure Q›⟩)
Proof (Lean source)
theorem IIDSample.sampleQuantileVec_tendsto_normal (S : IIDSample Ω ℝ μ P) {τ q f : Fin k → ℝ} (hreg : ∀ j, SampleQuantileReg P (τ j) (q j) (f j)) (Q : Measure (EuclideanSpace ℝ (Fin k))) [IsProbabilityMeasure Q] (hQ : ∀ t : EuclideanSpace ℝ (Fin k), charFun Q t = exp (-(((∫ z, (⟪t, quantileIFVec τ q f z⟫) ^ 2 ∂P : ℝ)) : ℂ) / 2)) (hθn_meas : ∀ n, AEMeasurable (IsAsymLinearVec.rescaledEstimator (S.sampleQuantileVec τ) (eucl q) (fun m => range m) n) μ) : Tendsto (β := ProbabilityMeasure (EuclideanSpace ℝ (Fin k))) (fun n => ⟨μ.map (IsAsymLinearVec.rescaledEstimator (S.sampleQuantileVec τ) (eucl q) (fun m => range m) n), Measure.isProbabilityMeasure_map (hθn_meas n)⟩) atTop (𝓝 ⟨Q, ‹IsProbabilityMeasure Q›⟩) := by exact (S.sampleQuantileVec_isAsymLinearVec hreg).tendsto_normal_vec_clt (measurable_quantileIFVec τ q f) Q hQ hθn_meas
8 supporting declarations (lemmas, instances)
  • measurable_quantileIFVec lemma — The joint quantile influence function is measurable.
    τ q f :
    Fin k → ℝ
    Proof (Lean source)
    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))
    Causalean.Stat.measurable_quantileIFVec · Causalean/Stat/Quantile/SampleQuantileJoint.lean:72
  • eucl_apply lemma — Coordinate access for eucl: (eucl v) j = v j.
    v :
    Fin k → ℝ
    j :
    Fin k
    (eucl v) j = v j
    Proof (Lean source)
    @[simp] lemma eucl_apply (v : Fin k → ℝ) (j : Fin k) : (eucl v) j = v j := rfl
  • norm_sq_eucl lemma — Euclidean norm of a packed vector, squared, is the coordinatewise sum of squares.
    v :
    Fin k → ℝ
    ‖eucl v‖ ^ 2 = ∑ j, (v j) ^ 2
    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 (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_abs lemma — The Euclidean norm of a packed vector is bounded by the ℓ¹ norm of its coordinates: ‖eucl v‖ ≤ ∑ j, |v j|.
    v :
    Fin k → ℝ
    ‖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| := 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
    Causalean.Stat.norm_eucl_le_sum_abs · Causalean/Stat/Quantile/SampleQuantileJoint.lean:145
  • isLittleOp_zero_one' lemma — The zero sequence is o_p(1).
    IsLittleOp (fun _ (_ : Ω) => (0 : ℝ)) (fun _ => (1 : ℝ)) μ
    Proof (Lean source)
    lemma isLittleOp_zero_one' : IsLittleOp (fun _ (_ : Ω) => (0 : ℝ)) (fun _ => (1 : ℝ)) μ := by intro ε hε have hempty : {ω : Ω | ε * (1 : ℝ) < |(0 : ℝ)|} = (∅ : Set Ω) := by ext ω; simp only [abs_zero, mul_one, Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false] exact hε.not_gt have heq : (fun _ : ℕ => μ {ω : Ω | ε * (1 : ℝ) < |(0 : ℝ)|}) = fun _ : ℕ => (0 : ENNReal) := by funext n; rw [hempty, measure_empty] rw [show (fun n : ℕ => μ {ω : Ω | ε * (fun _ => (1 : ℝ)) n < |(fun _ _ => (0 : ℝ)) n ω|}) = (fun _ : ℕ => μ {ω : Ω | ε * (1 : ℝ) < |(0 : ℝ)|}) from rfl, heq] exact tendsto_const_nhds
    Causalean.Stat.isLittleOp_zero_one' · Causalean/Stat/Quantile/SampleQuantileJoint.lean:162
  • isLittleOp_finset_sum_one lemma — A finite sum of o_p(1) sequences is o_p(1).
    ι :
    Type*
    s :
    g :
    ι → ℕ → Ω → ℝ
    h :
    ∀ i ∈ s, IsLittleOp (g i) (fun _ => (1 : ℝ)) μ
    IsLittleOp (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_one' (μ := μ) | insert a s has ih => have ha := h a (mem_insert_self a s) have hs := ih (fun i hi => h i (mem_insert_of_mem hi)) have hadd := IsLittleOp.add_one ha hs simpa [Finset.sum_insert has] using hadd
    Causalean.Stat.isLittleOp_finset_sum_one · Causalean/Stat/Quantile/SampleQuantileJoint.lean:177
  • isLittleOp_of_abs_le_const_mul_one lemma — Domination: if |Xn| ≤ C·|Yn| with Yn o_p(1) and C > 0, then Xn is o_p(1).
    X Y :
    ℕ → Ω → ℝ
    C :
    hC :
    0 < C
    hY :
    IsLittleOp Y (fun _ => (1 : ℝ)) μ
    hbound :
    ∀ n ω, |X n ω| ≤ C * |Y n ω|
    IsLittleOp 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
    Causalean.Stat.isLittleOp_of_abs_le_const_mul_one · Causalean/Stat/Quantile/SampleQuantileJoint.lean:191
  • isLittleOp_abs lemma — The absolute value of an o_p(1) sequence is o_p(1) (the threshold events coincide).
    R :
    ℕ → Ω → ℝ
    hR :
    IsLittleOp R (fun _ => (1 : ℝ)) μ
    IsLittleOp (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