Stat.Bootstrap.Efron­Resampling

This directory provides the nonparametric bootstrap as an actual conditional resampling law: the empirical measure of a finite data vector, the product law for draws with replacement, exact finite representations and mom

Mean 11 core · 17 supporting · 3 submodules 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 4 core · 4 supporting This module defines the empirical distribution of a finite data vector, the product law of an equal-size sample drawn with replacement, and the pushforward bootstrap law of a statistic. ★ bootstrapLaw_isProbabilityMeasure

Efron bootstrap measures

This module defines the empirical distribution of a finite data vector, the product law of an equal-size sample drawn with replacement, and the pushforward bootstrap law of a statistic. The definitions follow Efron's nonparametric bootstrap literally: the resample coordinates are independent draws from the empirical distribution.

def empiricalMeasure reviewed
Causalean.Stat

Given a data vector of length n, its empirical measure assigns mass 1/n to every indexed observation, counting repeated observations with their multiplicity.

Definition (Lean source)
X :
Type u_1
shared
n :
ℕ
shared
x :
Fin n → X
empiricalMeasure x :
def bootstrapResample reviewed
Causalean.Stat

Given a data vector, its Efron bootstrap resampling law is the finite product of its empirical measure, so its n coordinates are independent draws with replacement.

Definition (Lean source)
X :
Type u_1
shared
n :
ℕ
shared
x :
Fin n → X
bootstrapResample x :
Measure (Fin n → X)
Measure.pi (fun _ ↦ empiricalMeasure x)
def bootstrapLaw reviewed
Causalean.Stat

Given a real-valued sample statistic and observed data, the bootstrap law of the statistic is the pushforward of the Efron resampling law through that statistic.

Definition (Lean source)
X :
Type u_1
shared
n :
ℕ
shared
T :
(Fin n → X) → ℝ
x :
Fin n → X
bootstrapLaw T x :
theorem bootstrapLaw_isProbabilityMeasure reviewed
Causalean.Stat

Given a real-valued sample statistic and observed data, if the statistic is measurable and the data size is nonzero, its bootstrap law has total mass one.

Formal statement
X :
Type u_1
shared
n :
ℕ
shared
T :
(Fin n → X) → ℝ
x :
Fin n → X
hn :
n ≠ 0
hT :
Proof (Lean source)
theorem bootstrapLaw_isProbabilityMeasure (T : (Fin n → X) → ℝ) (x : Fin n → X) (hn : n ≠ 0) (hT : Measurable T) : IsProbabilityMeasure (bootstrapLaw T x) := by -- Proof plan: install the preceding resample-law instance and apply -- `Measure.isProbabilityMeasure_map hT.aemeasurable`. let _ : IsProbabilityMeasure (bootstrapResample x) := bootstrapResample_isProbabilityMeasure x hn unfold bootstrapLaw exact Measure.isProbabilityMeasure_map hT.aemeasurable
Causalean.Stat.bootstrapLaw_isProbabilityMeasure · Causalean/Stat/Bootstrap/EfronResampling/Basic.lean:71 · uses bootstrapLaw
4 supporting declarations (lemmas, instances)
Finite­Representation 1 core · 1 supporting This module expands the product of empirical measures into the uniform atomic law on all index maps Fin n → Fin n. ★ bootstrapResample_eq_average_dirac

Finite atomic representation of the Efron bootstrap

This module expands the product of empirical measures into the uniform atomic law on all index maps Fin n → Fin n. It also records the corresponding exact finite-average integration rule.

theorem bootstrapResample_eq_average_dirac reviewed
Causalean.Stat

For a data vector, the Efron resampling law is the uniform atomic measure on all n^n index resamples, with duplicate data values retained through their index multiplicities.

Formal statement
X :
Type u_1
shared
n :
ℕ
shared
x :
Fin n → X
bootstrapResample x = ((n : ℝ≥0∞) ^ n)⁻¹ • ∑ j : Fin n → Fin n, Measure.dirac (x ∘ j)
Proof (Lean source)
theorem bootstrapResample_eq_average_dirac (x : Fin n → X) : bootstrapResample x = ((n : ℝ≥0∞) ^ n)⁻¹ • ∑ j : Fin n → Fin n, Measure.dirac (x ∘ j) := by -- Proof plan: express one empirical coordinate as the map of the uniform atomic law on -- `Fin n`, commute coordinatewise map with `Measure.pi`, and expand the finite product. -- The empty-index case is `Measure.pi_of_empty`; the successor case distributes the product -- over a finite sum and uses `Measure.map_dirac'`. classical by_cases hn : n = 0 · subst n simp only [bootstrapResample, empiricalMeasure, finiteSampleMeasure, Finset.univ_eq_empty, Finset.sum_empty, smul_zero, Nat.cast_zero, pow_zero, inv_one, one_smul, Fintype.sum_unique] rw [Measure.pi_of_empty _ (x ∘ default)] · let _ : IsProbabilityMeasure (empiricalMeasure x) := empiricalMeasure_isProbabilityMeasure x hn unfold bootstrapResample apply Measure.pi_eq intro s hs rw [Measure.smul_apply, Measure.finsetSum_apply] simp only [Measure.dirac_apply' _ (MeasurableSet.univ_pi hs)] unfold empiricalMeasure finiteSampleMeasure simp_rw [Measure.smul_apply, Measure.finsetSum_apply, Measure.dirac_apply' _ (hs _), smul_eq_mul] rw [ENNReal.ofReal_natCast, Finset.prod_mul_distrib] simp only [Finset.prod_const, Finset.card_univ, Fintype.card_fin, ENNReal.inv_pow] rw [Fintype.prod_sum] congr 1 apply Finset.sum_congr rfl intro j hj by_cases h : x ∘ j ∈ Set.univ.pi s · have hi : ∀ i, x (j i) ∈ s i := by simpa [Set.mem_pi] using h simp [indicator, h, hi] · have hi : ∃ i, x (j i) ∉ s i := by simpa [Set.mem_pi] using h obtain ⟨i, hi⟩ := hi rw [Finset.prod_eq_zero (Finset.mem_univ i)] · exact Set.indicator_of_notMem h (1 : (Fin n → X) → ℝ≥0∞) · exact Set.indicator_of_notMem hi (1 : X → ℝ≥0∞)
Causalean.Stat.bootstrapResample_eq_average_dirac · Causalean/Stat/Bootstrap/EfronResampling/FiniteRepresentation.lean:23 · uses bootstrapResample
1 supporting declaration (lemmas, instances)
  • integral_bootstrapResample_eq_average theorem — For a data vector and a measurable real function of a resample, its bootstrap expectation is the ordinary average over all index resamples.
    X :
    Type u_1
    shared
    n :
    ℕ
    shared
    x :
    Fin n → X
    f :
    (Fin n → X) → ℝ
    hf :
    ∫ y, f y ∂bootstrapResample x = ((n : ℝ) ^ n)⁻¹ * ∑ j : Fin n → Fin n, f (x ∘ j)
    Proof (Lean source)
    theorem integral_bootstrapResample_eq_average (x : Fin n → X) (f : (Fin n → X) → ℝ) (hf : Measurable f) : ∫ y, f y ∂bootstrapResample x = ((n : ℝ) ^ n)⁻¹ * ∑ j : Fin n → Fin n, f (x ∘ j) := by -- Proof plan: rewrite by `bootstrapResample_eq_average_dirac`, then use -- `integral_smul_measure`, `integral_finsetSum_measure`, and `integral_dirac'`. rw [bootstrapResample_eq_average_dirac, integral_smul_measure] rw [integral_finsetSum_measure] · simp only [integral_dirac' f _ hf.stronglyMeasurable, smul_eq_mul, ENNReal.toReal_inv, ENNReal.toReal_pow, ENNReal.toReal_natCast] · intro j hj exact integrable_dirac' hf.stronglyMeasurable (by simp)
    Causalean.Stat.integral_bootstrapResample_eq_average · Causalean/Stat/Bootstrap/EfronResampling/FiniteRepresentation.lean:70
Measurability 3 core · 5 supporting This module defines the data-dependent bootstrap CDF and lower quantile. ★ measurable_bootstrapLowerQuantile

Measurability of bootstrap distribution functions and quantiles

This module defines the data-dependent bootstrap CDF and lower quantile. The CDF is a finite average of measurable threshold indicators. Right-continuity reduces the quantile infimum to rational thresholds, yielding measurability as a function of the observed data.

def bootstrapCDF reviewed
Causalean.Stat

Given a statistic, observed data, and a threshold, the bootstrap cumulative distribution value is the real mass that the bootstrap law assigns to (-∞,t].

Definition (Lean source)
X :
Type u_1
shared
n :
ℕ
shared
T :
(Fin n → X) → ℝ
x :
Fin n → X
t :
ℝ
bootstrapCDF T x t :
ℝ
(bootstrapLaw T x (Iic t)).toReal
def bootstrapLowerQuantile reviewed
Causalean.Stat

Given a statistic, a quantile level, and observed data, the lower bootstrap quantile is the infimum of thresholds where the bootstrap CDF reaches that level.

Definition (Lean source)
X :
Type u_1
shared
n :
ℕ
shared
T :
(Fin n → X) → ℝ
β :
ℝ
x :
Fin n → X
bootstrapLowerQuantile T β x :
ℝ
sInf {t : ℝ | β ≤ bootstrapCDF T x t}
theorem measurable_bootstrapLowerQuantile reviewed
Causalean.Stat

For a statistic that is measurable, a nonzero sample size, and any real quantile level, the lower bootstrap quantile is measurable as a function of the data. Outside (0,1] the sInf convention makes the generalized inverse degenerate, but it remains measurable.

Formal statement
X :
Type u_1
shared
n :
ℕ
shared
T :
(Fin n → X) → ℝ
hT :
hn :
n ≠ 0
β :
ℝ
Proof (Lean source)
theorem measurable_bootstrapLowerQuantile (T : (Fin n → X) → ℝ) (hT : Measurable T) (hn : n ≠ 0) (β : ℝ) : Measurable (bootstrapLowerQuantile T β) := by -- Proof plan: split into `β ≤ 0`, `0 < β ≤ 1`, and `1 < β`. The outer cases are -- constant by CDF bounds. In the middle case, use `measurable_of_Iic`, rewrite each preimage -- with `bootstrapLowerQuantile_le_iff`, and apply `measurable_bootstrapCDF`. by_cases hβ0 : β ≤ 0 · rw [show bootstrapLowerQuantile T β = fun _ ↦ 0 by funext x unfold bootstrapLowerQuantile rw [show {t : ℝ | β ≤ bootstrapCDF T x t} = univ by ext t simp only [Set.mem_ofPred_eq, Set.mem_univ, iff_true] exact hβ0.trans (ENNReal.toReal_nonneg), Real.sInf_univ]] exact measurable_const · have hβ0' : 0 < β := lt_of_not_ge hβ0 by_cases hβ1 : β ≤ 1 · apply measurable_of_Iic intro t rw [show (bootstrapLowerQuantile T β) ⁻¹' Iic t = {x : Fin n → X | β ≤ bootstrapCDF T x t} by ext x simp only [Set.mem_preimage, Set.mem_Iic, Set.mem_ofPred_eq] exact bootstrapLowerQuantile_le_iff T hT x hn β t hβ0' hβ1] exact measurableSet_le measurable_const (measurable_bootstrapCDF T hT t) · have hβ1' : 1 < β := lt_of_not_ge hβ1 rw [show bootstrapLowerQuantile T β = fun _ ↦ 0 by funext x unfold bootstrapLowerQuantile rw [show {t : ℝ | β ≤ bootstrapCDF T x t} = ∅ by ext t simp only [Set.mem_ofPred_eq, Set.mem_empty_iff_false, iff_false] intro ht let _ : IsProbabilityMeasure (bootstrapLaw T x) := bootstrapLaw_isProbabilityMeasure T x hn hT have hcdf : bootstrapCDF T x t = cdf (bootstrapLaw T x) t := bootstrapCDF_eq_cdf T hT x hn t exact (not_le_of_gt hβ1') (ht.trans (by rw [hcdf] exact ProbabilityTheory.cdf_le_one (bootstrapLaw T x) t)), Real.sInf_empty]] exact measurable_const
5 supporting declarations (lemmas, instances)
  • bootstrapCDF_eq_average_indicators theorem — For a statistic, observed data, and a threshold, if the statistic is measurable, the bootstrap CDF is the average of the threshold indicators over all index resamples.
    X :
    Type u_1
    shared
    n :
    ℕ
    shared
    T :
    (Fin n → X) → ℝ
    hT :
    x :
    Fin n → X
    t :
    ℝ
    bootstrapCDF T x t = ((n : ℝ) ^ n)⁻¹ * ∑ j : Fin n → Fin n, if T (x ∘ j) ≤ t then 1 else 0
    Proof (Lean source)
    theorem bootstrapCDF_eq_average_indicators (T : (Fin n → X) → ℝ) (hT : Measurable T) (x : Fin n → X) (t : ℝ) : bootstrapCDF T x t = ((n : ℝ) ^ n)⁻¹ * ∑ j : Fin n → Fin n, if T (x ∘ j) ≤ t then 1 else 0 := by -- Proof plan: use `Measure.map_apply hT` on `Iic t`, rewrite the resampling measure by its -- atomic representation, and evaluate each Dirac mass; `hn` converts the ENNReal weight. classical unfold bootstrapCDF bootstrapLaw rw [Measure.map_apply hT measurableSet_Iic, bootstrapResample_eq_average_dirac, Measure.smul_apply, Measure.finsetSum_apply] simp only [Measure.dirac_apply' _ (hT measurableSet_Iic), smul_eq_mul] rw [ENNReal.toReal_mul, ENNReal.toReal_inv, ENNReal.toReal_pow, ENNReal.toReal_natCast] rw [ENNReal.toReal_sum (by intro j hj by_cases h : T (x ∘ j) ≤ t <;> simp [indicator, h])] congr 1 apply Finset.sum_congr rfl intro j hj by_cases h : T (x ∘ j) ≤ t <;> simp [indicator, h]
    Causalean.Stat.bootstrapCDF_eq_average_indicators · Causalean/Stat/Bootstrap/EfronResampling/Measurability.lean:30
  • measurable_bootstrapCDF theorem — For a statistic that is measurable and a fixed threshold, the bootstrap CDF is measurable as a function of the data.
    X :
    Type u_1
    shared
    n :
    ℕ
    shared
    T :
    (Fin n → X) → ℝ
    hT :
    t :
    ℝ
    Measurable (fun x : Fin n → X ↦ bootstrapCDF T x t)
    Proof (Lean source)
    theorem measurable_bootstrapCDF (T : (Fin n → X) → ℝ) (hT : Measurable T) (t : ℝ) : Measurable (fun x : Fin n → X ↦ bootstrapCDF T x t) := by -- Proof plan: rewrite by `bootstrapCDF_eq_average_indicators`; for fixed `j`, the map -- `x ↦ x ∘ j` is measurable coordinatewise, hence so is the threshold indicator. classical rw [show (fun x : Fin n → X ↦ bootstrapCDF T x t) = fun x ↦ ((n : ℝ) ^ n)⁻¹ * ∑ j : Fin n → Fin n, if T (x ∘ j) ≤ t then 1 else 0 by funext x exact bootstrapCDF_eq_average_indicators T hT x t] apply Measurable.const_mul apply Finset.measurable_sum Finset.univ intro j hj have hcomp : Measurable (fun x : Fin n → X ↦ x ∘ j) := by refine measurable_pi_iff.mpr fun i ↦ ?_ exact measurable_pi_apply (j i) exact Measurable.ite (measurableSet_le (hT.comp hcomp) measurable_const) measurable_const measurable_const
  • bootstrapCDF_rightContinuous theorem — For a statistic, observed data, and a threshold, if the statistic is measurable and the sample size is nonzero, the bootstrap CDF is right-continuous at that threshold.
    X :
    Type u_1
    shared
    n :
    ℕ
    shared
    T :
    (Fin n → X) → ℝ
    hT :
    x :
    Fin n → X
    hn :
    n ≠ 0
    t :
    ℝ
    Proof (Lean source)
    theorem bootstrapCDF_rightContinuous (T : (Fin n → X) → ℝ) (hT : Measurable T) (x : Fin n → X) (hn : n ≠ 0) (t : ℝ) : ContinuousWithinAt (bootstrapCDF T x) (Ici t) t := by -- Proof plan: install probability for `bootstrapLaw T x`, identify `bootstrapCDF` with -- `cdf` via `cdf_eq_real`, and use the Stieltjes CDF's `right_continuous`. let _ : IsProbabilityMeasure (bootstrapLaw T x) := bootstrapLaw_isProbabilityMeasure T x hn hT have hcdf : bootstrapCDF T x = cdf (bootstrapLaw T x) := by funext s unfold bootstrapCDF exact (ProbabilityTheory.cdf_eq_real (bootstrapLaw T x) s).symm rw [hcdf] exact (cdf (bootstrapLaw T x)).right_continuous t
    Causalean.Stat.bootstrapCDF_rightContinuous · Causalean/Stat/Bootstrap/EfronResampling/Measurability.lean:77
  • bootstrapLowerQuantile_eq_sInf_rat theorem — For a statistic, observed data, and a positive quantile level no greater than one, if the statistic is measurable and the sample size is nonzero, the lower bootstrap quantile can be computed by taking the infimum only over rational thresholds.
    X :
    Type u_1
    shared
    n :
    ℕ
    shared
    T :
    (Fin n → X) → ℝ
    hT :
    x :
    Fin n → X
    hn :
    n ≠ 0
    β :
    ℝ
    hβ0 :
    0 < β
    hβ1 :
    β ≤ 1
    = sInf ((fun q : ℚ ↦ (q : ℝ)) '' {q : ℚ | β ≤ bootstrapCDF T x (q : ℝ)})
    Proof (Lean source)
    theorem bootstrapLowerQuantile_eq_sInf_rat (T : (Fin n → X) → ℝ) (hT : Measurable T) (x : Fin n → X) (hn : n ≠ 0) (β : ℝ) (hβ0 : 0 < β) (hβ1 : β ≤ 1) : bootstrapLowerQuantile T β x = sInf ((fun q : ℚ ↦ (q : ℝ)) '' {q : ℚ | β ≤ bootstrapCDF T x (q : ℝ)}) := by -- Proof plan: prove both candidate sets have the same greatest lower bound. Approximate any -- real candidate from above by rationals and pass the CDF inequality to the limit using -- `bootstrapCDF_rightContinuous`; `hβ0` bounds the sets below and `hβ1` plus finite support -- makes them nonempty. let A : Set ℝ := {t | β ≤ bootstrapCDF T x t} let B : Set ℝ := (fun q : ℚ ↦ (q : ℝ)) '' {q : ℚ | β ≤ bootstrapCDF T x (q : ℝ)} have hA_bdd : BddBelow A := bddBelow_bootstrapQuantileSet T hT x hn hβ0 have hA_ne : A.Nonempty := nonempty_bootstrapQuantileSet T hT x hn hβ1 have hBA : B ⊆ A := by intro y hy rcases hy with ⟨q, hq, rfl⟩ exact hq have hB_ne : B.Nonempty := by obtain ⟨a, ha⟩ := hA_ne obtain ⟨q, haq⟩ := exists_rat_gt a refine ⟨(q : ℝ), ⟨q, ?_, rfl⟩⟩ exact (bootstrapLowerQuantile_le_iff_aux T hT x hn β (q : ℝ) hβ0 hβ1).mp ((bootstrapLowerQuantile_le_iff_aux T hT x hn β a hβ0 hβ1).mpr ha |>.trans haq.le) have hB_bdd : BddBelow B := hA_bdd.mono hBA change sInf A = sInf B apply le_antisymm · exact le_csInf hB_ne fun b hb ↦ csInf_le hA_bdd (hBA hb) · apply le_csInf hA_ne intro a ha by_contra hnot have haB : a < sInf B := lt_of_not_ge hnot obtain ⟨q, haq, hqB⟩ := exists_rat_btwn haB have hqA : (q : ℝ) ∈ A := (bootstrapLowerQuantile_le_iff_aux T hT x hn β (q : ℝ) hβ0 hβ1).mp ((bootstrapLowerQuantile_le_iff_aux T hT x hn β a hβ0 hβ1).mpr ha |>.trans haq.le) have hqmem : (q : ℝ) ∈ B := ⟨q, hqA, rfl⟩ exact (not_le_of_gt hqB) (csInf_le hB_bdd hqmem)
    Causalean.Stat.bootstrapLowerQuantile_eq_sInf_rat · Causalean/Stat/Bootstrap/EfronResampling/Measurability.lean:174
  • bootstrapLowerQuantile_le_iff theorem — For a statistic, observed data, a positive quantile level no greater than one, and a threshold, if the statistic is measurable and the sample size is nonzero, a lower bootstrap quantile is at most that threshold exactly when the bootstrap CDF has reached the level there.
    X :
    Type u_1
    shared
    n :
    ℕ
    shared
    T :
    (Fin n → X) → ℝ
    hT :
    x :
    Fin n → X
    hn :
    n ≠ 0
    β t :
    ℝ
    hβ0 :
    0 < β
    hβ1 :
    β ≤ 1
    bootstrapLowerQuantile T β x ≤ t ↔ β ≤ bootstrapCDF T x t
    Proof (Lean source)
    theorem bootstrapLowerQuantile_le_iff (T : (Fin n → X) → ℝ) (hT : Measurable T) (x : Fin n → X) (hn : n ≠ 0) (β t : ℝ) (hβ0 : 0 < β) (hβ1 : β ≤ 1) : bootstrapLowerQuantile T β x ≤ t ↔ β ≤ bootstrapCDF T x t := by -- Proof plan: the reverse direction is `csInf_le`; for the forward direction show the -- infimum attains the CDF level using right-continuity and upward closure. At `β = 1`, use -- the maximum of the finite set `T (x ∘ j)` to establish nonemptiness. exact bootstrapLowerQuantile_le_iff_aux T hT x hn β t hβ0 hβ1
    Causalean.Stat.bootstrapLowerQuantile_le_iff · Causalean/Stat/Bootstrap/EfronResampling/Measurability.lean:217
Moments 1 core · 1 supporting This module computes the first moment of the bootstrap sample mean and the second moment of its square-root-n centered version. ★ integral_centered_finMean_sq_bootstrapResample

Exact bootstrap moments of the sample mean

This module computes the first moment of the bootstrap sample mean and the second moment of its square-root-n centered version. Both identities are exact finite-sample statements.

theorem integral_centered_finMean_sq_bootstrapResample reviewed
Causalean.Stat

For real data with nonzero length, the bootstrap second moment of the square-root-scaled centered resample mean equals the empirical centered second moment.

Formal statement
n :
ℕ
shared
x :
Fin n → ℝ
hn :
n ≠ 0
∫ y, (sqrt n * (finMean y - finMean x)) ^ 2 ∂bootstrapResample x
= (n : ℝ)⁻¹ * ∑ i, (x i - finMean x) ^ 2
Proof (Lean source)
theorem integral_centered_finMean_sq_bootstrapResample (x : Fin n → ℝ) (hn : n ≠ 0) : ∫ y, (sqrt n * (finMean y - finMean x)) ^ 2 ∂bootstrapResample x = (n : ℝ)⁻¹ * ∑ i, (x i - finMean x) ^ 2 := by let _ : IsProbabilityMeasure (empiricalMeasure x) := empiricalMeasure_isProbabilityMeasure x hn have hIdSq : Integrable (fun z : ℝ => z ^ 2) (empiricalMeasure x) := by unfold empiricalMeasure finiteSampleMeasure apply Integrable.smul_measure · rw [integrable_finsetSum_measure] intro i hi exact integrable_dirac' (stronglyMeasurable_id.pow 2) (by simp) · simp [hn] have hId : MemLp (fun z : ℝ => z) 2 (empiricalMeasure x) := (memLp_two_iff_integrable_sq measurable_id.aestronglyMeasurable).2 hIdSq have hvar := iid_average_variance (empiricalMeasure x) n (fun z : ℝ => z) hId have hmean : ∫ y, finMean y ∂bootstrapResample x = finMean x := integral_finMean_bootstrapResample x hn have hfin_meas : Measurable (finMean : (Fin n → ℝ) → ℝ) := by unfold finMean fun_prop have hpopmean : ∫ z, z ∂empiricalMeasure x = finMean x := by have h := integral_finiteSampleMeasure x measurable_id simpa only [empiricalMeasure, id_eq, one_div, finMean, smul_eq_mul] using h calc ∫ y, (sqrt n * (finMean y - finMean x)) ^ 2 ∂bootstrapResample x = (n : ℝ) * ∫ y, (finMean y - finMean x) ^ 2 ∂bootstrapResample x := by rw [← integral_const_mul] congr 1 funext y rw [mul_pow, Real.sq_sqrt (Nat.cast_nonneg n)] _ = (n : ℝ) * variance finMean (bootstrapResample x) := by congr 1 rw [ProbabilityTheory.variance_eq_integral hfin_meas.aemeasurable] rw [hmean] _ = variance (fun z : ℝ => z) (empiricalMeasure x) := by rw [show finMean = fun sample : Fin n → ℝ => (n : ℝ)⁻¹ * ∑ i, (fun z : ℝ => z) (sample i) by funext sample simp [finMean]] rw [show bootstrapResample x = Measure.pi (fun _ : Fin n => empiricalMeasure x) by rfl] rw [hvar] field_simp _ = ∫ z, (z - finMean x) ^ 2 ∂empiricalMeasure x := by rw [ProbabilityTheory.variance_eq_integral (X := fun z : ℝ => z) measurable_id.aemeasurable] rw [hpopmean] _ = (n : ℝ)⁻¹ * ∑ i, (x i - finMean x) ^ 2 := by have h := integral_finiteSampleMeasure (f := fun z : ℝ => (z - finMean x) ^ 2) x (by fun_prop) simpa only [empiricalMeasure, one_div] using h
Causalean.Stat.integral_centered_finMean_sq_bootstrapResample · Causalean/Stat/Bootstrap/EfronResampling/Moments.lean:49 · uses bootstrapResample , finMean
1 supporting declaration (lemmas, instances)