Stat.Bootstrap.Efron­Resampling.Mean

This directory proves almost-sure consistency of Efron's nonparametric bootstrap for a sample mean of a measurable real statistic with a finite second moment.

Basic 6 core · 9 supporting This module defines the centered empirical row law, the conditional bootstrap law of the root-sample-size mean, and the corresponding true sampling law. ★ bootstrapMeanLaw_eq_iidRowNormalizedSumLaw

Laws used in the Efron bootstrap CLT for a mean

This module defines the centered empirical row law, the conditional bootstrap law of the root-sample-size mean, and the corresponding true sampling law. The definitions are totalized at sample size zero by a point mass at zero; every theorem identifying them with Efron's literal bootstrap law assumes the genuine case n ≠ 0.

def centeredBootstrapSum reviewed
Causalean.Stat

Given an observation statistic, observed data, and a same-size resample, the centered bootstrap sum is the resample's statistic total minus the data-average total, normalized by the square root of the sample size.

Definition (Lean source)
X :
Type u_2
shared
n :
ℕ
ψ :
X → ℝ
x xstar :
Fin n → X
centeredBootstrapSum ψ x xstar :
ℝ
(sqrt (n : ℝ))⁻¹ * ∑ i, (ψ (xstar i) - finMean (fun j ↦ ψ (x j)))
def centeredEmpiricalLaw reviewed
Causalean.Stat

Given an iid sample, an observation statistic, a row size, and a realized outcome, the centered empirical row law is the empirical distribution of statistic values centered at their sample average, with a point mass at zero for the zero row.

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
ψ :
X → ℝ
n :
ℕ
ω :
Ω
centeredEmpiricalLaw S ψ n ω :
if n
= 0 then Measure.dirac 0 else empiricalMeasure (fun i : Fin n ↦ ψ (S.Z i ω) - S.sampleMean ψ n ω)
def bootstrapMeanLaw reviewed
Causalean.Stat

Given an iid sample, a measurable observation statistic, a row size, and a realized outcome, the conditional bootstrap law of the centered normalized mean is Efron's resampling law at positive sizes and a point mass at zero at size zero.

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
ψ :
X → ℝ
hψ :
n :
ℕ
ω :
Ω
bootstrapMeanLaw S ψ hψ n ω :
if hn : n
= 0 then ⟨Measure.dirac 0, inferInstance⟩ else ⟨Causalean.Stat.bootstrapLaw (centeredBootstrapSum ψ (S.sampleVector n ω)) (S.sampleVector n ω), bootstrapLaw_isProbabilityMeasure _ _ hn (measurable_centeredBootstrapSum ψ hψ _)⟩
theorem bootstrapMeanLaw_eq_iidRowNormalizedSumLaw reviewed
Causalean.Stat

With a nonzero row size, an iid sample, a measurable observation statistic, and a realized outcome, the conditional bootstrap mean law equals the normalized iid row-sum law from the centered empirical distribution.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
μ :
shared
P :
shared
n :
ℕ
hn :
n ≠ 0
S :
IIDSample Ω X μ P
ψ :
X → ℝ
hψ :
ω :
Ω
bootstrapMeanLaw S ψ hψ n ω
Proof (Lean source)
theorem bootstrapMeanLaw_eq_iidRowNormalizedSumLaw {n : ℕ} (hn : n ≠ 0) (S : IIDSample Ω X μ P) (ψ : X → ℝ) (hψ : Measurable ψ) (ω : Ω) : bootstrapMeanLaw S ψ hψ n ω = iidRowNormalizedSumLaw (fun m ↦ centeredEmpiricalLaw S ψ m ω) n := by -- Push each empirical draw through subtraction of the fixed sample mean, commute this -- coordinatewise map with `Measure.pi`, and finish with `Measure.map_map` and extensionality. apply ProbabilityMeasure.toMeasure_injective rw [bootstrapMeanLaw_toMeasure hn] change bootstrapLaw (centeredBootstrapSum ψ (S.sampleVector n ω)) (S.sampleVector n ω) = (Measure.pi (fun _ : Fin n => centeredEmpiricalLaw S ψ n ω)).map (fun y => (sqrt (n : ℝ))⁻¹ * iidRowSum n y) rw [centeredEmpiricalLaw, if_neg hn] let g : X → ℝ := fun z => ψ z - S.sampleMean ψ n ω have hg : Measurable g := hψ.sub measurable_const have hemp : empiricalMeasure (fun i : Fin n => g (S.sampleVector n ω i)) = (empiricalMeasure (S.sampleVector n ω)).map g := by unfold empiricalMeasure finiteSampleMeasure rw [Measure.map_smul] rw [Measure.map_finset_sum hg.aemeasurable] simp_rw [Measure.map_dirac' hg] let _ : IsProbabilityMeasure (empiricalMeasure (S.sampleVector n ω)) := empiricalMeasure_isProbabilityMeasure _ hn change ((Measure.pi (fun _ : Fin n => empiricalMeasure (S.sampleVector n ω))).map (centeredBootstrapSum ψ (S.sampleVector n ω))) = (Measure.pi (fun _ : Fin n => empiricalMeasure (fun i : Fin n => g (S.sampleVector n ω i)))).map (fun y => (sqrt (n : ℝ))⁻¹ * iidRowSum n y) rw [hemp] rw [← Measure.pi_map_pi (fun _ => hg.aemeasurable)] have hcoord : Measurable (fun x : Fin n → X => fun i => g (x i)) := by fun_prop have hnorm : Measurable (fun y : Fin n → ℝ => (sqrt (n : ℝ))⁻¹ * iidRowSum n y) := measurable_const.mul (measurable_iidRowSum n) rw [Measure.map_map (μ := Measure.pi (fun _ : Fin n => empiricalMeasure (S.sampleVector n ω))) (g := fun y : Fin n → ℝ => (sqrt (n : ℝ))⁻¹ * iidRowSum n y) (f := fun x : Fin n → X => fun i => g (x i)) hnorm hcoord] congr 1 have hmean : finMean (fun i : Fin n => ψ (S.sampleVector n ω i)) = S.sampleMean ψ n ω := by unfold finMean IIDSample.sampleVector IIDSample.sampleMean rw [smul_eq_mul, Fin.sum_univ_eq_sum_range (fun i ↦ ψ (S.Z i ω)) n] funext y unfold centeredBootstrapSum iidRowSum g simp only [Function.comp_apply] rw [hmean]
def samplingMeanLaw reviewed
Causalean.Stat

Given an iid sample, a measurable observation statistic, and a row size, the sampling law of the square-root-scaled centered sample mean is its distribution under repeated draws from the population.

Definition (Lean source)
Ω :
Type u_1
shared
X :
Type u_2
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
ψ :
X → ℝ
hψ :
n :
ℕ
samplingMeanLaw S ψ hψ n :
by letI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure exact ⟨μ.map (fun ω ↦ sqrt (n : ℝ) * (S.sampleMean ψ n ω - ∫ x, ψ x ∂P)), Measure.isProbabilityMeasure_map (by fun_prop : AEMeasurable (fun ω ↦ sqrt (n : ℝ) * (S.sampleMean ψ n ω - ∫ x, ψ x ∂P)) μ)⟩
def populationVariance reviewed
Causalean.Stat

Given an observation statistic and a measure on the observation space, the nonnegative population variance is the variance of the statistic represented as a nonnegative real number for use as a Gaussian variance parameter.

Definition (Lean source)
X :
Type u_2
shared
ψ :
X → ℝ
P :
populationVariance ψ P :
(variance ψ P).toNNReal
9 supporting declarations (lemmas, instances)
Almost­Sure 3 core · 5 supporting This module derives the almost-sure convergence of the empirical mean and variance and the Lindeberg tail condition using only a finite second moment. ★ centeredEmpiricalSecondMoment_tendsto_ae★ centeredEmpiricalLindeberg_tendsto_ae

Almost-sure empirical conditions for the bootstrap mean CLT

This module derives the almost-sure convergence of the empirical mean and variance and the Lindeberg tail condition using only a finite second moment. The tail argument is organized around the measurable squared-tail truncation below, so no moment above order two is assumed.

def squaredTail reviewed
Causalean.Stat

Given an observation statistic, a tail threshold, and an observation, the squared tail contribution is the statistic's square when its absolute value exceeds the threshold and zero otherwise.

Definition (Lean source)
X :
Type u_2
shared
ψ :
X → ℝ
M :
ℝ
x :
X
squaredTail ψ M x :
ℝ
(ψ x) ^ 2 * indicator {y : X | M ≤ |ψ y|} (fun _ ↦ (1 : ℝ)) x
theorem centeredEmpiricalSecondMoment_tendsto_ae reviewed
Causalean.Stat

Given an iid sample, a measurable observation statistic, and an integrable population square, the centered empirical row law's second moment converges almost surely to the population variance.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
ψ :
X → ℝ
hψ :
hψ2 :
Integrable (fun x ↦ (ψ x) ^ 2) P
∀ᵐ ω ∂μ, Tendsto (fun n ↦ ∫ y, y ^ 2 ∂centeredEmpiricalLaw S ψ n ω) atTop (𝓝 (variance ψ P))
Proof (Lean source)
theorem centeredEmpiricalSecondMoment_tendsto_ae (S : IIDSample Ω X μ P) (ψ : X → ℝ) (hψ : Measurable ψ) (hψ2 : Integrable (fun x ↦ (ψ x) ^ 2) P) : ∀ᵐ ω ∂μ, Tendsto (fun n ↦ ∫ y, y ^ 2 ∂centeredEmpiricalLaw S ψ n ω) atTop (𝓝 (variance ψ P)) := by filter_upwards [empiricalVar_tendsto_ae S ψ hψ hψ2] with ω hvar apply hvar.congr' filter_upwards [eventually_ne_atTop 0] with n hn exact (integral_sq_centeredEmpiricalLaw_eq_empiricalVar hn S ψ ω).symm
Causalean.Stat.centeredEmpiricalSecondMoment_tendsto_ae · Causalean/Stat/Bootstrap/EfronResampling/Mean/AlmostSure.lean:199 · uses IIDSample , centeredEmpiricalLaw
theorem centeredEmpiricalLindeberg_tendsto_ae reviewed
Causalean.Stat

Given an iid sample, a measurable observation statistic, and an integrable population square, every positive Lindeberg tail of the centered empirical row law vanishes almost surely at the square-root sample-size scale.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
ψ :
X → ℝ
hψ :
hψ2 :
Integrable (fun x ↦ (ψ x) ^ 2) P
∀ᵐ ω ∂μ, ∀ ε : ℝ, 0 < ε → Tendsto (fun n ↦ ∫ y in {y : ℝ | ε * sqrt (n : ℝ) ≤ |y|}, y ^ 2 ∂centeredEmpiricalLaw S ψ n ω) atTop (𝓝 0)
Proof (Lean source)
theorem centeredEmpiricalLindeberg_tendsto_ae (S : IIDSample Ω X μ P) (ψ : X → ℝ) (hψ : Measurable ψ) (hψ2 : Integrable (fun x ↦ (ψ x) ^ 2) P) : ∀ᵐ ω ∂μ, ∀ ε : ℝ, 0 < ε → Tendsto (fun n ↦ ∫ y in {y : ℝ | ε * sqrt (n : ℝ) ≤ |y|}, y ^ 2 ∂centeredEmpiricalLaw S ψ n ω) atTop (𝓝 0) := by filter_upwards [sampleMean_tendsto_ae S ψ hψ hψ2, sampleSquaredTail_tendsto_ae S ψ hψ hψ2] with ω hmean htails intro ε hε apply tendsto_order.2 constructor · intro a ha filter_upwards with n exact lt_of_lt_of_le ha (setIntegral_nonneg (measurableSet_le measurable_const measurable_id.abs) (fun _ _ ↦ sq_nonneg _)) · intro δ hδ have htailNat : Tendsto (fun M : ℕ ↦ 4 * ∫ x, squaredTail ψ (M : ℝ) x ∂P) atTop (𝓝 0) := by convert ((integral_squaredTail_tendsto_zero ψ hψ hψ2).const_mul 4).comp (tendsto_natCast_atTop_atTop (R := ℝ)) using 1 <;> simp [Function.comp_def] have hsmallEventually : ∀ᶠ M : ℕ in atTop, 4 * ∫ x, squaredTail ψ (M : ℝ) x ∂P < δ := htailNat.eventually (eventually_lt_nhds hδ) rcases eventually_atTop.1 hsmallEventually with ⟨M, hM⟩ have hMsmall : 4 * ∫ x, squaredTail ψ (M : ℝ) x ∂P < δ := hM M le_rfl have hmeanBound : ∀ᶠ n : ℕ in atTop, |S.sampleMean ψ n ω| < |∫ x, ψ x ∂P| + 1 := hmean.abs.eventually (eventually_lt_nhds (lt_add_one _)) have hroot : Tendsto (fun n : ℕ ↦ ε * sqrt (n : ℝ)) atTop atTop := (Real.tendsto_sqrt_atTop.comp (tendsto_natCast_atTop_atTop (R := ℝ))).const_mul_atTop hε have hthreshold : ∀ᶠ n : ℕ in atTop, 2 * ((M : ℝ) + (|∫ x, ψ x ∂P| + 1)) ≤ ε * sqrt (n : ℝ) := hroot.eventually (eventually_ge_atTop _) have htailSmall : ∀ᶠ n : ℕ in atTop, 4 * S.sampleMean (squaredTail ψ M) n ω < δ := (htails M).const_mul 4 |>.eventually (eventually_lt_nhds hMsmall) filter_upwards [hmeanBound, hthreshold, htailSmall, eventually_ne_atTop 0] with n hnmean hnthreshold hntail hn have hthreshold' : 2 * ((M : ℝ) + |S.sampleMean ψ n ω|) ≤ ε * sqrt (n : ℝ) := by linarith have hdom : (∫ y in {y : ℝ | ε * sqrt (n : ℝ) ≤ |y|}, y ^ 2 ∂centeredEmpiricalLaw S ψ n ω) ≤ 4 * S.sampleMean (squaredTail ψ M) n ω := by have hA : MeasurableSet {y : ℝ | ε * sqrt (n : ℝ) ≤ |y|} := by exact measurableSet_le measurable_const measurable_id.abs rw [setIntegral_sq_centeredEmpiricalLaw_eq_average hn S ψ ω (A := {y : ℝ | ε * sqrt (n : ℝ) ≤ |y|}) hA] unfold IIDSample.sampleMean rw [← Fin.sum_univ_eq_sum_range (fun i ↦ squaredTail ψ M (S.Z i ω)) n] calc (n : ℝ)⁻¹ * ∑ i : Fin n, indicator {y : ℝ | ε * sqrt (n : ℝ) ≤ |y|} (fun y : ℝ ↦ y ^ 2) (ψ (S.Z i ω) - S.sampleMean ψ n ω) ≤ (n : ℝ)⁻¹ * ∑ i : Fin n, 4 * squaredTail ψ M (S.Z i ω) := by apply mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun i _ ↦ ?_) (by positivity) let x := ψ (S.Z i ω) let m := S.sampleMean ψ n ω by_cases hc : ε * sqrt (n : ℝ) ≤ |x - m| · have hbig : 2 * ((M : ℝ) + |m|) ≤ |x - m| := hthreshold'.trans hc have htri : |x - m| ≤ |x| + |m| := abs_sub x m have haux : 2 * ((M : ℝ) + |m|) ≤ |x| + |m| := hbig.trans htri have hm_le : |m| ≤ |x| := by have hMnonneg : 0 ≤ (M : ℝ) := Nat.cast_nonneg M linarith [abs_nonneg m] have hM_le : (M : ℝ) ≤ |x| := by have hMnonneg : 0 ≤ (M : ℝ) := Nat.cast_nonneg M linarith [abs_nonneg m] have habs : |x - m| ≤ 2 * |x| := by linarith have hsquares : (x - m) ^ 2 ≤ 4 * x ^ 2 := by have hs := (sq_le_sq₀ (abs_nonneg (x - m)) (by positivity : 0 ≤ 2 * |x|)).2 habs rw [sq_abs] at hs nlinarith [sq_abs x] simpa [x, m, squaredTail, hc, hM_le] using hsquares · by_cases ht : (M : ℝ) ≤ |x| · simp [x, m, squaredTail, hc, ht, sq_nonneg] · simp [x, m, squaredTail, hc, ht] _ = 4 * ((n : ℝ)⁻¹ * ∑ i : Fin n, squaredTail ψ M (S.Z i ω)) := by rw [← Finset.mul_sum] ring exact lt_of_le_of_lt hdom hntail
5 supporting declarations (lemmas, instances)
  • integral_squaredTail_tendsto_zero theorem — If an observation statistic is measurable and has an integrable square under the population law, its squared-tail expectations vanish as the threshold grows without bound.
    X :
    Type u_2
    shared
    ψ :
    X → ℝ
    hψ :
    hψ2 :
    Integrable (fun x ↦ (ψ x) ^ 2) P
    Tendsto (fun M : ℝ ↦ ∫ x, squaredTail ψ M x ∂P) atTop (𝓝 0)
    Proof (Lean source)
    theorem integral_squaredTail_tendsto_zero (ψ : X → ℝ) (hψ : Measurable ψ) (hψ2 : Integrable (fun x ↦ (ψ x) ^ 2) P) : Tendsto (fun M : ℝ ↦ ∫ x, squaredTail ψ M x ∂P) atTop (𝓝 0) := by have hmeas : ∀ M : ℝ, AEStronglyMeasurable (squaredTail ψ M) P := by intro M exact ((hψ.pow_const 2).mul (measurable_const.indicator (measurableSet_le measurable_const hψ.abs))).aestronglyMeasurable have hbound : ∀ M : ℝ, ∀ᵐ x ∂P, ‖squaredTail ψ M x‖ ≤ (ψ x) ^ 2 := by intro M filter_upwards with x by_cases hx : M ≤ |ψ x| · simp [squaredTail, hx] · simp [squaredTail, hx, sq_nonneg] have hpoint : ∀ᵐ x ∂P, Tendsto (fun M : ℝ ↦ squaredTail ψ M x) atTop (𝓝 0) := by filter_upwards with x apply tendsto_const_nhds.congr' filter_upwards [eventually_gt_atTop |ψ x|] with M hM simp [squaredTail, not_le.mpr hM] simpa using (tendsto_integral_filter_of_dominated_convergence (fun x ↦ (ψ x) ^ 2) (Eventually.of_forall hmeas) (Eventually.of_forall hbound) hψ2 hpoint)
    Causalean.Stat.integral_squaredTail_tendsto_zero · Causalean/Stat/Bootstrap/EfronResampling/Mean/AlmostSure.lean:33
  • sampleMean_tendsto_ae theorem — Given an iid sample, a measurable observation statistic, and an integrable population square, the transformed sample mean converges almost surely to its population expectation.
    Ω :
    Type u_1
    shared
    X :
    Type u_2
    shared
    μ :
    shared
    P :
    shared
    S :
    IIDSample Ω X μ P
    ψ :
    X → ℝ
    hψ :
    hψ2 :
    Integrable (fun x ↦ (ψ x) ^ 2) P
    ∀ᵐ ω ∂μ, Tendsto (fun n ↦ S.sampleMean ψ n ω) atTop (𝓝 (∫ x, ψ x ∂P))
    Proof (Lean source)
    theorem sampleMean_tendsto_ae (S : IIDSample Ω X μ P) (ψ : X → ℝ) (hψ : Measurable ψ) (hψ2 : Integrable (fun x ↦ (ψ x) ^ 2) P) : ∀ᵐ ω ∂μ, Tendsto (fun n ↦ S.sampleMean ψ n ω) atTop (𝓝 (∫ x, ψ x ∂P)) := by haveI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure haveI : IsProbabilityMeasure P := by rw [← S.law] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable have hmem : MemLp ψ 2 P := (memLp_two_iff_integrable_sq hψ.aestronglyMeasurable).2 hψ2 have hψint : Integrable ψ P := hmem.integrable (by norm_num) have hψint_sample : Integrable (fun ω ↦ ψ (S.Z 0 ω)) μ := by have hmap : Integrable ψ (μ.map (S.Z 0)) := by simpa [S.law] using hψint exact hmap.comp_measurable (S.meas 0) have hindep : Pairwise (onFun (fun f g ↦ IndepFun f g μ) (fun i ω ↦ ψ (S.Z i ω))) := by have hi : iIndepFun (fun i ↦ ψ ∘ S.Z i) μ := S.indep.comp (fun _ ↦ ψ) (fun _ ↦ hψ) intro i j hij exact hi.indepFun hij have hident : ∀ i, IdentDistrib (fun ω ↦ ψ (S.Z i ω)) (fun ω ↦ ψ (S.Z 0 ω)) μ μ := by intro i exact ((S.identDist i).symm.comp hψ) have hslln := strong_law_ae_real (fun i ω ↦ ψ (S.Z i ω)) hψint_sample hindep hident have hint : (∫ ω, ψ (S.Z 0 ω) ∂μ) = ∫ x, ψ x ∂P := by rw [← integral_map (S.meas 0).aemeasurable hψ.aestronglyMeasurable, S.law] filter_upwards [hslln] with ω hω unfold IIDSample.sampleMean simpa [hint, div_eq_mul_inv, mul_comm] using hω
  • sampleSecondMoment_tendsto_ae theorem — Given an iid sample, a measurable observation statistic, and an integrable population square, the empirical second moment converges almost surely to the population second moment.
    Ω :
    Type u_1
    shared
    X :
    Type u_2
    shared
    μ :
    shared
    P :
    shared
    S :
    IIDSample Ω X μ P
    ψ :
    X → ℝ
    hψ :
    hψ2 :
    Integrable (fun x ↦ (ψ x) ^ 2) P
    ∀ᵐ ω ∂μ, Tendsto (fun n ↦ S.sampleMean (fun x ↦ (ψ x) ^ 2) n ω) atTop (𝓝 (∫ x, (ψ x) ^ 2 ∂P))
    Proof (Lean source)
    theorem sampleSecondMoment_tendsto_ae (S : IIDSample Ω X μ P) (ψ : X → ℝ) (hψ : Measurable ψ) (hψ2 : Integrable (fun x ↦ (ψ x) ^ 2) P) : ∀ᵐ ω ∂μ, Tendsto (fun n ↦ S.sampleMean (fun x ↦ (ψ x) ^ 2) n ω) atTop (𝓝 (∫ x, (ψ x) ^ 2 ∂P)) := by haveI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure haveI : IsProbabilityMeasure P := by rw [← S.law] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable let g : X → ℝ := fun x ↦ (ψ x) ^ 2 have hg : Measurable g := hψ.pow_const 2 have hg_sample : Integrable (fun ω ↦ g (S.Z 0 ω)) μ := by have hmap : Integrable g (μ.map (S.Z 0)) := by simpa [S.law, g] using hψ2 exact hmap.comp_measurable (S.meas 0) have hindep : Pairwise (onFun (fun f₁ f₂ ↦ IndepFun f₁ f₂ μ) (fun i ω ↦ g (S.Z i ω))) := by have hi : iIndepFun (fun i ↦ g ∘ S.Z i) μ := S.indep.comp (fun _ ↦ g) (fun _ ↦ hg) intro i j hij exact hi.indepFun hij have hident : ∀ i, IdentDistrib (fun ω ↦ g (S.Z i ω)) (fun ω ↦ g (S.Z 0 ω)) μ μ := by intro i exact ((S.identDist i).symm.comp hg) have hslln := strong_law_ae_real (fun i ω ↦ g (S.Z i ω)) hg_sample hindep hident have hint : (∫ ω, g (S.Z 0 ω) ∂μ) = ∫ x, g x ∂P := by rw [← integral_map (S.meas 0).aemeasurable hg.aestronglyMeasurable, S.law] filter_upwards [hslln] with ω hω unfold IIDSample.sampleMean simpa [g, hint, div_eq_mul_inv, mul_comm] using hω
    Causalean.Stat.sampleSecondMoment_tendsto_ae · Causalean/Stat/Bootstrap/EfronResampling/Mean/AlmostSure.lean:96
  • sampleSquaredTail_tendsto_ae theorem — Given an iid sample, a measurable observation statistic, and an integrable population square, all integer-threshold squared-tail sample averages converge on one common probability-one event.
    Ω :
    Type u_1
    shared
    X :
    Type u_2
    shared
    μ :
    shared
    P :
    shared
    S :
    IIDSample Ω X μ P
    ψ :
    X → ℝ
    hψ :
    hψ2 :
    Integrable (fun x ↦ (ψ x) ^ 2) P
    ∀ᵐ ω ∂μ, ∀ M : ℕ, Tendsto (fun n ↦ S.sampleMean (squaredTail ψ M) n ω) atTop (𝓝 (∫ x, squaredTail ψ M x ∂P))
    Proof (Lean source)
    theorem sampleSquaredTail_tendsto_ae (S : IIDSample Ω X μ P) (ψ : X → ℝ) (hψ : Measurable ψ) (hψ2 : Integrable (fun x ↦ (ψ x) ^ 2) P) : ∀ᵐ ω ∂μ, ∀ M : ℕ, Tendsto (fun n ↦ S.sampleMean (squaredTail ψ M) n ω) atTop (𝓝 (∫ x, squaredTail ψ M x ∂P)) := by haveI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure haveI : IsProbabilityMeasure P := by rw [← S.law] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable rw [ae_all_iff] intro M let g : X → ℝ := squaredTail ψ M have hg : Measurable g := by dsimp [g, squaredTail] exact (hψ.pow_const 2).mul (measurable_const.indicator (measurableSet_le measurable_const hψ.abs)) have hgint : Integrable g P := by refine Integrable.mono hψ2 hg.aestronglyMeasurable ?_ filter_upwards with x by_cases hx : (M : ℝ) ≤ |ψ x| · simp [g, squaredTail, hx] · simp [g, squaredTail, hx, sq_nonneg] have hg_sample : Integrable (fun ω ↦ g (S.Z 0 ω)) μ := by have hmap : Integrable g (μ.map (S.Z 0)) := by simpa [S.law] using hgint exact hmap.comp_measurable (S.meas 0) have hindep : Pairwise (onFun (fun f₁ f₂ ↦ IndepFun f₁ f₂ μ) (fun i ω ↦ g (S.Z i ω))) := by have hi : iIndepFun (fun i ↦ g ∘ S.Z i) μ := S.indep.comp (fun _ ↦ g) (fun _ ↦ hg) intro i j hij exact hi.indepFun hij have hident : ∀ i, IdentDistrib (fun ω ↦ g (S.Z i ω)) (fun ω ↦ g (S.Z 0 ω)) μ μ := by intro i exact ((S.identDist i).symm.comp hg) have hslln := strong_law_ae_real (fun i ω ↦ g (S.Z i ω)) hg_sample hindep hident have hint : (∫ ω, g (S.Z 0 ω) ∂μ) = ∫ x, g x ∂P := by rw [← integral_map (S.meas 0).aemeasurable hg.aestronglyMeasurable, S.law] filter_upwards [hslln] with ω hω unfold IIDSample.sampleMean simpa [g, hint, div_eq_mul_inv, mul_comm] using hω
    Causalean.Stat.sampleSquaredTail_tendsto_ae · Causalean/Stat/Bootstrap/EfronResampling/Mean/AlmostSure.lean:132
  • empiricalVar_tendsto_ae theorem — Given an iid sample, a measurable observation statistic, and an integrable population square, the plug-in empirical variance converges almost surely to the population variance.
    Ω :
    Type u_1
    shared
    X :
    Type u_2
    shared
    μ :
    shared
    P :
    shared
    S :
    IIDSample Ω X μ P
    ψ :
    X → ℝ
    hψ :
    hψ2 :
    Integrable (fun x ↦ (ψ x) ^ 2) P
    ∀ᵐ ω ∂μ, Tendsto (fun n ↦ S.empiricalVar ψ n ω) atTop (𝓝 (variance ψ P))
    Proof (Lean source)
    theorem empiricalVar_tendsto_ae (S : IIDSample Ω X μ P) (ψ : X → ℝ) (hψ : Measurable ψ) (hψ2 : Integrable (fun x ↦ (ψ x) ^ 2) P) : ∀ᵐ ω ∂μ, Tendsto (fun n ↦ S.empiricalVar ψ n ω) atTop (𝓝 (variance ψ P)) := by haveI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure haveI : IsProbabilityMeasure P := by rw [← S.law] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable have hmem : MemLp ψ 2 P := (memLp_two_iff_integrable_sq hψ.aestronglyMeasurable).2 hψ2 filter_upwards [sampleMean_tendsto_ae S ψ hψ hψ2, sampleSecondMoment_tendsto_ae S ψ hψ hψ2] with ω hmean hsecond rw [variance_eq_sub hmem] exact hsecond.sub (hmean.pow 2)
Main 2 core · 3 supporting This module formalizes the same-size specialization of the Bickel--Freedman mean result: the observed sample and the Efron resample both have size n. ★ bootstrapMeanLaw_tendsto_gaussian_ae★ bootstrapMeanLaw_cdfKolmogorov_samplingMeanLaw_tendsto_ae

Same-size Bickel--Freedman consistency for the Efron bootstrap mean

This module formalizes the same-size specialization of the Bickel--Freedman mean result: the observed sample and the Efron resample both have size n. For a measurable real statistic of iid observations with a finite second moment, the conditional bootstrap distribution of the centered root-sample-size mean converges almost surely to the centered Gaussian with the population variance. At positive variance it is also uniformly close, in Kolmogorov distance, to the true finite-sample distribution. The final declarations specialize the result to real-valued observations and the identity statistic.

theorem bootstrapMeanLaw_tendsto_gaussian_ae reviewed
Causalean.Stat

Given an iid sample, a measurable observation statistic, and an integrable population square, the conditional Efron-bootstrap law of the square-root-scaled centered mean converges almost surely to the centered Gaussian with the population variance.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
ψ :
X → ℝ
hψ :
hψ2 :
Integrable (fun x ↦ (ψ x) ^ 2) P
∀ᵐ ω ∂μ, Tendsto (fun n ↦ bootstrapMeanLaw S ψ hψ n ω) atTop (𝓝 (⟨gaussianReal 0 (populationVariance ψ P), inferInstance⟩ : ProbabilityMeasure ℝ))
Proof (Lean source)
theorem bootstrapMeanLaw_tendsto_gaussian_ae (S : IIDSample Ω X μ P) (ψ : X → ℝ) (hψ : Measurable ψ) (hψ2 : Integrable (fun x ↦ (ψ x) ^ 2) P) : ∀ᵐ ω ∂μ, Tendsto (fun n ↦ bootstrapMeanLaw S ψ hψ n ω) atTop (𝓝 (⟨gaussianReal 0 (populationVariance ψ P), inferInstance⟩ : ProbabilityMeasure ℝ)) := by letI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure haveI : IsProbabilityMeasure P := by rw [← S.law] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable filter_upwards [centeredEmpiricalSecondMoment_tendsto_ae S ψ hψ hψ2, centeredEmpiricalLindeberg_tendsto_ae S ψ hψ hψ2] with ω hsecond hlindeberg have hcenter : ∀ n, ∫ x, x ∂centeredEmpiricalLaw S ψ n ω = 0 := by intro n by_cases hn : n = 0 · subst n simp [centeredEmpiricalLaw] · exact integral_id_centeredEmpiricalLaw hn S ψ ω have hsecond' : Tendsto (fun n : ℕ ↦ ∫ x, x ^ 2 ∂centeredEmpiricalLaw S ψ n ω) atTop (𝓝 ((populationVariance ψ P : NNReal) : ℝ)) := by simpa [populationVariance, Real.toNNReal_of_nonneg (variance_nonneg ψ P)] using hsecond have hrow := iidRowNormalizedSumLaw_tendsto_gaussian (fun n ↦ centeredEmpiricalLaw S ψ n ω) (populationVariance ψ P) (fun n ↦ memLp_id_centeredEmpiricalLaw S ψ n ω) hcenter hsecond' hlindeberg apply hrow.congr' filter_upwards [eventually_ne_atTop 0] with n hn exact (bootstrapMeanLaw_eq_iidRowNormalizedSumLaw hn S ψ hψ ω).symm
theorem bootstrapMeanLaw_cdfKolmogorov_samplingMeanLaw_tendsto_ae reviewed
Causalean.Stat

Given an iid sample, a measurable observation statistic, an integrable population square, and strictly positive population variance, the conditional bootstrap and sampling laws approach one another almost surely in Kolmogorov distance.

Formal statement
Ω :
Type u_1
shared
X :
Type u_2
shared
μ :
shared
P :
shared
S :
IIDSample Ω X μ P
ψ :
X → ℝ
hψ :
hψ2 :
Integrable (fun x ↦ (ψ x) ^ 2) P
hvar :
0 < variance ψ P
∀ᵐ ω ∂μ, Tendsto (fun n ↦ cdfKolmogorov (bootstrapMeanLaw S ψ hψ n ω) (samplingMeanLaw S ψ hψ n)) atTop (𝓝 0)
Proof (Lean source)
theorem bootstrapMeanLaw_cdfKolmogorov_samplingMeanLaw_tendsto_ae (S : IIDSample Ω X μ P) (ψ : X → ℝ) (hψ : Measurable ψ) (hψ2 : Integrable (fun x ↦ (ψ x) ^ 2) P) (hvar : 0 < variance ψ P) : ∀ᵐ ω ∂μ, Tendsto (fun n ↦ cdfKolmogorov (bootstrapMeanLaw S ψ hψ n ω) (samplingMeanLaw S ψ hψ n)) atTop (𝓝 0) := by have hvar' : 0 < populationVariance ψ P := by simpa [populationVariance, Real.toNNReal_pos] using hvar filter_upwards [bootstrapMeanLaw_tendsto_gaussian_ae S ψ hψ hψ2] with ω hboot exact tendsto_cdfKolmogorov_of_tendsto hboot (samplingMeanLaw_tendsto_gaussian S ψ hψ hψ2) (continuous_cdf_gaussianReal_zero hvar')
Causalean.Stat.bootstrapMeanLaw_cdfKolmogorov_samplingMeanLaw_tendsto_ae · Causalean/Stat/Bootstrap/EfronResampling/Mean/Main.lean:137 · uses IIDSample , bootstrapMeanLaw , cdfKolmogorov , samplingMeanLaw
3 supporting declarations (lemmas, instances)