Stat.Sample
Sampling primitives: iid samples as measurable maps, coordinatewise measurable modifications of almost-everywhere measurable iid families, and their product-law identities.
Sample 5 core · 6 supporting This file provides the library's causal-agnostic model of an independent and identically distributed sample relative to arbitrary ambient and population measures; probability-measure instances are supplied separately whe ★ map_eq★ ofAEMeasurable
I.i.d. Samples
This file provides the library's causal-agnostic model of an independent and identically distributed sample relative to arbitrary ambient and population measures; probability-measure instances are supplied separately when needed. It also defines sample means of real-valued statistics along the first sample points, supplying the base object used by the limit and inference modules.
An independent and identically distributed sample with marginal law P, realized as a sequence of sample points given by measurable maps on a single ambient measured space: the family is mutually independent, identically distributed, and the law of each point is the measure P. Neither the ambient measure nor P is required by this structure to be a probability measure.
Definition (Lean source)
For a measurable sample space carrying a measure, a measurable observation space carrying a population measure, an independent and identically distributed sample from that population, a real-valued statistic of one observation, and a nonnegative integer sample size, the sample mean is the function that assigns each sample-space outcome the average , with the reciprocal convention also applying when .
For an i.i.d. sample S and any sample index i, the pushforward law of the i-th sample point equals the population law P.
Formal statement
Each indexed family of random variables whose coordinates are almost-everywhere measurable has a coordinatewise measurable modification, chosen by the standard measurable-representative construction at every index.
Definition (Lean source)
Coordinatewise almost-everywhere measurability, mutual independence of the original coordinates, and a common coordinate law define an IID sample of measurable representatives with the original first-coordinate law, using the representatives, their measurability, their independence, their identical distributions, and their marginal law.
Definition (Lean source)
6 supporting declarations (lemmas, instances)
-
measurable_Ztheorem — Each individual sample point of an i.i.d. sample is a measurable map from the ambient measured space to the observation space.hypothesesconclusionMeasurable (S.Z i)Proof (Lean source)
@[fun_prop] theorem measurable_Z (S : IIDSample Ω X μ P) (i : ℕ) : Measurable (S.Z i) := S.meas i -
measurableModification_measurabletheorem — Under coordinatewise almost-everywhere measurability, the measurable modification at the specified index is measurable.hypothesesconclusionMeasurable (measurableModification X hX i)Proof (Lean source)
@[fun_prop] theorem measurableModification_measurable (hX : ∀ i, AEMeasurable (X i) μ) (i : ℕ) : Measurable (measurableModification X hX i) := (hX i).measurable_mk -
measurableModification_ae_eqtheorem — Under coordinatewise almost-everywhere measurability, the measurable modification at the specified index equals the original coordinate almost everywhere.hypothesesconclusionmeasurableModification X hX i =ᵐ[μ] X iProof (Lean source)
theorem measurableModification_ae_eq (hX : ∀ i, AEMeasurable (X i) μ) (i : ℕ) : measurableModification X hX i =ᵐ[μ] X i := (hX i).ae_eq_mk.symm -
ofAEMeasurable_ae_eqtheorem — Coordinatewise almost-everywhere measurability, mutual independence, a common coordinate law, and a specified index imply that the corresponding constructed sample coordinate equals the original coordinate almost everywhere.hypothesesΩ :sharedType u_1E :sharedType u_2X :sharedℕ → Ω → EhX :∀ i, AEMeasurable (X i) μhindep :iIndepFun X μhident :∀ i, IdentDistrib (X 0) (X i) μ μi :ℕconclusion(ofAEMeasurable hX hindep hident).Z i =ᵐ[μ] X iProof (Lean source)
theorem ofAEMeasurable_ae_eq (hX : ∀ i, AEMeasurable (X i) μ) (hindep : iIndepFun X μ) (hident : ∀ i, IdentDistrib (X 0) (X i) μ μ) (i : ℕ) : (ofAEMeasurable hX hindep hident).Z i =ᵐ[μ] X i := measurableModification_ae_eq hX i -
finite_sum_ae_eqtheorem — Coordinatewise almost-everywhere measurability, a real-valued statistic, and a finite set of indices imply that the sum of the statistic over the measurable modifications equals the original-coordinate sum almost everywhere.hypothesesΩ :sharedType u_1E :sharedType u_2X :sharedℕ → Ω → EhX :∀ i, AEMeasurable (X i) μψ :E → ℝs :Finset ℕconclusion(fun ω => ∑ i ∈ s, ψ (measurableModification X hX i ω))=ᵐ[μ] (fun ω => ∑ i ∈ s, ψ (X i ω))Proof (Lean source)
theorem finite_sum_ae_eq (hX : ∀ i, AEMeasurable (X i) μ) (ψ : E → ℝ) (s : Finset ℕ) : (fun ω => ∑ i ∈ s, ψ (measurableModification X hX i ω)) =ᵐ[μ] (fun ω => ∑ i ∈ s, ψ (X i ω)) := by induction s using Finset.induction_on with | empty => simp | @insert i s his ih => filter_upwards [ih, measurableModification_ae_eq hX i] with ω hsum hi simp [Finset.sum_insert his, hsum, hi] -
sampleMean_ae_eqtheorem — Coordinatewise almost-everywhere measurability, mutual independence, a common coordinate law, a real-valued statistic, and a sample size imply that the measurable sample mean equals the original-coordinate sample mean almost everywhere.hypothesesΩ :sharedType u_1E :sharedType u_2X :sharedℕ → Ω → EhX :∀ i, AEMeasurable (X i) μhindep :iIndepFun X μhident :∀ i, IdentDistrib (X 0) (X i) μ μψ :E → ℝn :ℕconclusion(ofAEMeasurable hX hindep hident).sampleMean ψ n=ᵐ[μ] (fun ω => (n : ℝ)⁻¹ * ∑ i ∈ range n, ψ (X i ω))Proof (Lean source)
theorem sampleMean_ae_eq (hX : ∀ i, AEMeasurable (X i) μ) (hindep : iIndepFun X μ) (hident : ∀ i, IdentDistrib (X 0) (X i) μ μ) (ψ : E → ℝ) (n : ℕ) : (ofAEMeasurable hX hindep hident).sampleMean ψ n =ᵐ[μ] (fun ω => (n : ℝ)⁻¹ * ∑ i ∈ range n, ψ (X i ω)) := by change (fun ω => (n : ℝ)⁻¹ * ∑ i ∈ range n, ψ (measurableModification X hX i ω)) =ᵐ[μ] (fun ω => (n : ℝ)⁻¹ * ∑ i ∈ range n, ψ (X i ω)) filter_upwards [finite_sum_ae_eq hX ψ (range n)] with ω hω exact congrArg ((n : ℝ)⁻¹ * ·) hω
CollisionEstimator 4 core · 0 supporting This module defines an ordered-pair collision estimator for inverse-frequency functionals, together with cell-weighted moments and cross-sample averages for observations equipped with an explicit projection to their cell
Collision and cross-sample estimators
This module defines an ordered-pair collision estimator for inverse-frequency functionals, together with cell-weighted moments and cross-sample averages for observations equipped with an explicit projection to their cell labels.
Given a finite or infinite cell-label space, a real-valued cell-mass function, and two cell labels, the collision kernel equals the reciprocal mass of the first label when the labels coincide and equals zero otherwise.
Definition (Lean source)
Given a cell-label space, a real-valued cell-mass function, a nonnegative integer target-sample size, and a target sample of that size, the collision scale is the average collision-kernel value over all ordered pairs of distinct target indices, with the displayed reciprocal convention also applying at sample sizes zero and one.
Definition (Lean source)
Given a cell-label space and an observation space, a real-valued cell-mass function, a map assigning each observation to a cell, a nonnegative integer source-sample size, a source sample, a real-valued observation statistic, and a cell label, the cell moment is the inverse source-sample size and inverse cell mass times the sum of the statistic over source observations projected to that cell.
Definition (Lean source)
Given a cell-label space and an observation space, a real-valued cell-mass function, an observation-to-cell map, nonnegative integer source and target sample sizes, a source sample, a target sample of cell labels, and a real-valued observation statistic, the cross-sample average is the average, over target observations, of the corresponding source-sample cell moments.
Definition (Lean source)
EffectiveSampleSize 6 core · 7 supporting This module distinguishes the sample average of squared weights from the scale-invariant Kish design effect and effective sample size. ★ empiricalWeightSecondMoment_mean★ empiricalWeightSecondMoment_lower_tail_le_of_mean_variance
Empirical weight second moments and Kish effective sample size
This module distinguishes the sample average of squared weights from the scale-invariant Kish design effect and effective sample size. It proves agreement under realized mean-one normalization, then gives mean, variance, and product-law lower-tail results for the empirical weight second moment.
Given a real-valued weight function, a sample size, and an indexed sample, the empirical weight second moment is the sample average of the squared weights.
Definition (Lean source)
Given a real-valued weight function, a sample size, and an indexed sample, this legacy compatibility name denotes the empirical weight second moment, not a scale-invariant finite-sample Kish design effect.
Definition (Lean source)
Given a finite vector of realized weights, the Kish design effect is zero when their sum is zero; otherwise it is the number of weights times their squared-weight sum, divided by the square of their total weight.
Definition (Lean source)
Given a finite vector of realized weights, the Kish effective sample size is zero when their squared-weight sum is zero, and otherwise uses squared total weight divided by the squared-weight sum.
Definition (Lean source)
For a probability measure, a weight function, a sample size, positivity of that size, and integrability of the squared weight, the expected empirical weight second moment equals its population counterpart.
Formal statement
Proof (Lean source)
Given a sample size, a sampling probability measure, a weight function, a weight envelope, a positive reference mean, positivity of the sample size, positivity of the reference mean, square-integrability of the empirical second moment, its assumed exact mean, and its assumed variance bound, Chebyshev's inequality bounds the probability of falling below half the reference mean.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
kishDesignEffect_eq_empiricalWeightSecondMoment_of_sum_eqlemma — Given realized weights, a positive sample size, and realized mean-one normalization, the two quantities agree.hypothesesconclusionkishDesignEffect w = empiricalWeightSecondMoment id n wProof (Lean source)
lemma kishDesignEffect_eq_empiricalWeightSecondMoment_of_sum_eq {n : ℕ} (w : Fin n → ℝ) (hn : 0 < n) (hsum : ∑ i, w i = (n : ℝ)) : kishDesignEffect w = empiricalWeightSecondMoment id n w := by have hnR : (n : ℝ) ≠ 0 := by exact_mod_cast hn.ne' rw [kishDesignEffect, if_neg] · simp only [empiricalWeightSecondMoment, id_eq, hsum, inv_eq_one_div] calc (n : ℝ) * (∑ x, w x ^ 2) / (n : ℝ) ^ 2 = ((n : ℝ) / (n : ℝ) ^ 2) * ∑ x, w x ^ 2 := by ring _ = 1 / (n : ℝ) * ∑ x, w x ^ 2 := by congr 1 field_simp [hnR] · simpa [hsum] using hnR -
one_le_secondMoment_of_mean_onelemma — For a probability measure, a real-valued weight, square-integrability of the weight, and population mean one, the weight's population second moment is at least one.hypothesesconclusion1 ≤ ∫ x, w x ^ 2 ∂μProof (Lean source)
lemma one_le_secondMoment_of_mean_one {𝒳 : Type*} [MeasurableSpace 𝒳] (μ : Measure 𝒳) [IsProbabilityMeasure μ] (w : 𝒳 → ℝ) (hw : MemLp w 2 μ) (hmean : (∫ x, w x ∂μ) = 1) : 1 ≤ ∫ x, w x ^ 2 ∂μ := by have hv := variance_nonneg w μ rw [variance_eq_sub hw, hmean] at hv norm_num at hv ⊢ linarith -
empiricalKishDispersion_meanlemma — For a probability measure, a weight function, a sample size, positivity of that size, and integrability of the squared weight, this legacy compatibility theorem gives the mean of the empirical weight second moment.hypothesesconclusion= ∫ o, g o ^ 2 ∂μProof (Lean source)
lemma empiricalKishDispersion_mean {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] (g : Ω → ℝ) (n : ℕ) (hn : 0 < n) (hF : Integrable (fun o => g o ^ 2) μ) : (∫ sample : Fin n → Ω, empiricalKishDispersion g n sample ∂Measure.pi (fun _ : Fin n => μ)) = ∫ o, g o ^ 2 ∂μ := by exact empiricalWeightSecondMoment_mean μ g n hn hF -
empiricalWeightSecondMoment_variance_lelemma — For a probability measure, a weight function, a sample size, a weight envelope, a population second-moment value, positivity of the sample size, square-integrability of the squared weight, the population second-moment identity, and the fourth-moment envelope, the stated variance bound holds.hypothesesΩ :Type*μ :g :Ω → ℝn :ℕk kappa :ℝhn :0 < nhF :MemLp (fun o => g o ^ 2) 2 μhkappa :(∫ o, g o ^ 2 ∂μ) = kappahfourth :∀ᵐ o ∂μ, g o ^ 4 ≤ 4 * k ^ 2 * g o ^ 2conclusionvariance (fun sample : Fin n → Ω => empiricalWeightSecondMoment g n sample) (Measure.pi (fun _ : Fin n => μ))≤ 4 * k ^ 2 * kappa / nProof (Lean source)
lemma empiricalWeightSecondMoment_variance_le {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] (g : Ω → ℝ) (n : ℕ) (k kappa : ℝ) (hn : 0 < n) (hF : MemLp (fun o => g o ^ 2) 2 μ) (hkappa : (∫ o, g o ^ 2 ∂μ) = kappa) (hfourth : ∀ᵐ o ∂μ, g o ^ 4 ≤ 4 * k ^ 2 * g o ^ 2) : variance (fun sample : Fin n → Ω => empiricalWeightSecondMoment g n sample) (Measure.pi (fun _ : Fin n => μ)) ≤ 4 * k ^ 2 * kappa / n := by have hvar := iid_average_variance μ n (fun o => g o ^ 2) hF have hsingle : variance (fun o => g o ^ 2) μ ≤ 4 * k ^ 2 * kappa := by calc variance (fun o => g o ^ 2) μ ≤ ∫ o, (g o ^ 2) ^ 2 ∂μ := variance_le_expectation_sq hF.aestronglyMeasurable _ = ∫ o, g o ^ 4 ∂μ := by apply integral_congr_ae filter_upwards with o ring _ ≤ ∫ o, 4 * k ^ 2 * g o ^ 2 ∂μ := by have hleft : Integrable (fun o => g o ^ 4) μ := by have hpow : (fun o => g o ^ 4) = fun o => (g o ^ 2) ^ 2 := by funext o ring rw [hpow] exact hF.integrable_sq exact integral_mono_ae hleft (hF.integrable (by norm_num) |>.const_mul _) hfourth _ = 4 * k ^ 2 * kappa := by rw [integral_const_mul, hkappa] change variance (fun sample : Fin n → Ω => (n : ℝ)⁻¹ * ∑ i, g (sample i) ^ 2) (Measure.pi (fun _ : Fin n => μ)) ≤ _ rw [hvar] calc (n : ℝ)⁻¹ * variance (fun o => g o ^ 2) μ ≤ (n : ℝ)⁻¹ * (4 * k ^ 2 * kappa) := by gcongr _ = 4 * k ^ 2 * kappa / n := by ring -
empiricalKishDispersion_variance_lelemma — For a probability measure, a weight function, a sample size, a weight envelope, a population second-moment value, positivity of the sample size, square-integrability of the squared weight, the population second-moment identity, and the fourth-moment envelope, this legacy compatibility theorem gives the variance bound for the empirical weight second moment.hypothesesΩ :Type*μ :g :Ω → ℝn :ℕk kappa :ℝhn :0 < nhF :MemLp (fun o => g o ^ 2) 2 μhkappa :(∫ o, g o ^ 2 ∂μ) = kappahfourth :∀ᵐ o ∂μ, g o ^ 4 ≤ 4 * k ^ 2 * g o ^ 2conclusionvariance (fun sample : Fin n → Ω => empiricalKishDispersion g n sample) (Measure.pi (fun _ : Fin n => μ))≤ 4 * k ^ 2 * kappa / nProof (Lean source)
lemma empiricalKishDispersion_variance_le {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] (g : Ω → ℝ) (n : ℕ) (k kappa : ℝ) (hn : 0 < n) (hF : MemLp (fun o => g o ^ 2) 2 μ) (hkappa : (∫ o, g o ^ 2 ∂μ) = kappa) (hfourth : ∀ᵐ o ∂μ, g o ^ 4 ≤ 4 * k ^ 2 * g o ^ 2) : variance (fun sample : Fin n → Ω => empiricalKishDispersion g n sample) (Measure.pi (fun _ : Fin n => μ)) ≤ 4 * k ^ 2 * kappa / n := by exact empiricalWeightSecondMoment_variance_le μ g n k kappa hn hF hkappa hfourth -
empiricalKishDispersion_lower_tail_lelemma — Given a sample size, a sampling probability measure, a weight function, a weight envelope, a positive reference mean, positivity of the sample size, positivity of the reference mean, square-integrability of the empirical second moment, its assumed exact mean, and its assumed variance bound, this legacy compatibility theorem is the Chebyshev specialization now named empiricalWeightSecondMoment_lower_tail_le_of_mean_variance.hypothesesΩ :Type*n :ℕQ :g :Ω → ℝk kappa :ℝhn :0 < nhkappa :0 < kappahF :MemLp (empiricalKishDispersion g n) 2 Qhmean :(∫ sample, empiricalKishDispersion g n sample ∂Q) = kappahvar :variance (empiricalKishDispersion g n) Q ≤ 4 * k ^ 2 * kappa / nconclusion(Q {sample | empiricalKishDispersion g n sample < kappa / 2}).toReal≤ 16 * k ^ 2 / ((n : ℝ) * kappa)Proof (Lean source)
lemma empiricalKishDispersion_lower_tail_le {Ω : Type*} [MeasurableSpace Ω] (n : ℕ) (Q : Measure (Fin n → Ω)) [IsProbabilityMeasure Q] (g : Ω → ℝ) (k kappa : ℝ) (hn : 0 < n) (hkappa : 0 < kappa) (hF : MemLp (empiricalKishDispersion g n) 2 Q) (hmean : (∫ sample, empiricalKishDispersion g n sample ∂Q) = kappa) (hvar : variance (empiricalKishDispersion g n) Q ≤ 4 * k ^ 2 * kappa / n) : (Q {sample | empiricalKishDispersion g n sample < kappa / 2}).toReal ≤ 16 * k ^ 2 / ((n : ℝ) * kappa) := by exact empiricalWeightSecondMoment_lower_tail_le_of_mean_variance n Q g k kappa hn hkappa hF hmean hvar -
empiricalWeightSecondMoment_lower_tail_lelemma — For a population probability measure, a weight function, a sample size, a weight envelope, a positive population second-moment value, positivity of the sample size, positivity of that moment, square-integrability of the squared weight, the population second-moment identity, and the fourth-moment envelope, the stated product-law lower-tail bound holds.hypothesesΩ :Type*μ :g :Ω → ℝn :ℕk kappa :ℝhn :0 < nhkappa :0 < kappahF :MemLp (fun o => g o ^ 2) 2 μhmoment :(∫ o, g o ^ 2 ∂μ) = kappahfourth :∀ᵐ o ∂μ, g o ^ 4 ≤ 4 * k ^ 2 * g o ^ 2conclusion((Measure.pi (fun _ : Fin n => μ)) {sample | empiricalWeightSecondMoment g n sample < kappa / 2}).toReal≤ 16 * k ^ 2 / ((n : ℝ) * kappa)Proof (Lean source)
lemma empiricalWeightSecondMoment_lower_tail_le {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] (g : Ω → ℝ) (n : ℕ) (k kappa : ℝ) (hn : 0 < n) (hkappa : 0 < kappa) (hF : MemLp (fun o => g o ^ 2) 2 μ) (hmoment : (∫ o, g o ^ 2 ∂μ) = kappa) (hfourth : ∀ᵐ o ∂μ, g o ^ 4 ≤ 4 * k ^ 2 * g o ^ 2) : ((Measure.pi (fun _ : Fin n => μ)) {sample | empiricalWeightSecondMoment g n sample < kappa / 2}).toReal ≤ 16 * k ^ 2 / ((n : ℝ) * kappa) := by have hsample : MemLp (empiricalWeightSecondMoment g n) 2 (Measure.pi (fun _ : Fin n => μ)) := by unfold empiricalWeightSecondMoment apply MemLp.const_mul simpa using memLp_finsetSum univ fun i _ => hF.comp_measurePreserving (measurePreserving_eval (fun _ : Fin n => μ) i) exact empiricalWeightSecondMoment_lower_tail_le_of_mean_variance n (Measure.pi (fun _ : Fin n => μ)) g k kappa hn hkappa hsample ((empiricalWeightSecondMoment_mean μ g n hn (hF.integrable (by norm_num))).trans hmoment) (empiricalWeightSecondMoment_variance_le μ g n k kappa hn hF hmoment hfourth)
EmpiricalMass 3 core · 1 supporting This module defines the empirical frequency of one point in a finite i.i.d. ★ integral_empiricalMass★ integral_empiricalMass_sq
Empirical mass of a point
This module defines the empirical frequency of one point in a finite i.i.d. sample and establishes its range, expectation, and second moment.
Given an observation space, a nonnegative sample size, a sample indexed by the integers from zero through one less than that size, and a point in the observation space, the empirical mass of that point is the reciprocal of the sample size multiplied by the number of sampled observations equal to that point.
Definition (Lean source)
Expected empirical mass. Given a positive sample size and a measurable singleton {a}, the expectation, under the -fold product sampling measure, of the empirical mass of the point a — the fraction of sample observations equal to a — equals the population probability of {a}.
Formal statement
Proof (Lean source)
Second moment of the empirical mass. Given a positive sample size and a measurable singleton {a}, the second moment, under the -fold product sampling measure, of the empirical mass of the point a equals the squared population probability of {a} plus the usual binomial sampling correction .
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
abs_empiricalMass_le_onelemma — The absolute empirical mass of any point is at most one, including for the empty sample.hypothesesconclusion|empiricalMass sample x| ≤ 1Proof (Lean source)
lemma abs_empiricalMass_le_one {N : ℕ} (sample : Fin N → 𝒳) (x : 𝒳) : |empiricalMass sample x| ≤ 1 := by by_cases hN : 0 < N · classical unfold empiricalMass have hcount_nonneg : 0 ≤ ∑ j : Fin N, if sample j = x then (1 : ℝ) else 0 := by positivity have hcount_le : ∑ j : Fin N, (if sample j = x then (1 : ℝ) else 0) ≤ N := by calc _ ≤ ∑ _j : Fin N, (1 : ℝ) := by apply Finset.sum_le_sum intro j hj split_ifs <;> norm_num _ = N := by simp have hNreal : 0 < (N : ℝ) := by exact_mod_cast hN rw [abs_of_nonneg (mul_nonneg (inv_nonneg.mpr hNreal.le) hcount_nonneg)] calc (N : ℝ)⁻¹ * ∑ j : Fin N, (if sample j = x then 1 else 0) ≤ (N : ℝ)⁻¹ * N := by gcongr _ = 1 := by field_simp · have hzero : N = 0 := Nat.eq_zero_of_not_pos hN subst N simp [empiricalMass]
PiTransport 4 core · 13 supporting This file proves that the joint observable of a finite independent identically distributed sample pushes the underlying probability measure forward to the corresponding finite product measure. ★ iidSample_finN_pushforward★ event_pullback_along_iidSample
Transport to Product Samples
This file proves that the joint observable of a finite independent identically distributed sample pushes the underlying probability measure forward to the corresponding finite product measure. It also transports high-probability events on product samples back to events on the original sample space.
Two further transports live here. First, forgetting part of an i.i.d. sample:
restricting a product sample to a sub-index (a cross-fitting fold, a sample
split, a Finset of coordinates) is measure preserving onto the product measure
over the sub-index, so integrals and pushforwards transport verbatim. Second,
the existence of an i.i.d. sample with a prescribed marginal, which is shown
to be equivalent to that marginal being a probability measure — i.e. to carry no
information at all.
Given a measurable observation space and a probability measure on it, the independent, identically distributed sample on the infinite product space is formed by coordinate projections, and every coordinate has the given probability measure as its marginal law.
Definition (Lean source)
For an i.i.d. sample S and a fixed horizon n, the joint map of the first n sample points pushes μ forward to the product measure on Fin n → X.
Formal statement
Proof (Lean source)
Event transport along an IID sample (Fin n version). Given a measurable event E in the space of length-n outcome tuples whose product-measure probability under n independent copies of the population law is at least , the pullback of E along the joint observable built from the first n coordinates of the i.i.d. sample is a measurable event on the underlying sample space, with probability at least .
Formal statement
Proof (Lean source)
Given a measurable observation space and a measure on it, the existence-of-an-independent, identically distributed-sample assertion states that there is a sample space with a measurable structure and a measure carrying a nonempty collection of independent, identically distributed samples whose common marginal law is the given measure.
Definition (Lean source)
13 supporting declarations (lemmas, instances)
-
iidSample_finN_measurablelemma — The joint observable Ψ ω k = S.Z k ω is measurable Ω → (Fin n → X).hypothesesconclusionMeasurable (fun ω : Ω => fun k : Fin n => S.Z k ω)Proof (Lean source)
lemma iidSample_finN_measurable (S : IIDSample Ω X μ P) (n : ℕ) : Measurable (fun ω : Ω => fun k : Fin n => S.Z k ω) := measurable_pi_lambda _ (fun k => S.meas k) -
measurePreserving_pi_restrict_deptheorem — Dropping the coordinates outside a decidable sub-index of a product of probability measures leaves the product measure over that sub-index: the retained coordinates carry exactly their own product law, with no trace of the discarded ones.hypothesesι :sharedType u_3ι → Type*∀ i, MeasurableSpace (X i)μ :∀ i, Measure (X i)∀ i, IsProbabilityMeasure (μ i)p :ι → PropconclusionMeasurePreserving (fun (s : ∀ i, X i) (i : Subtype p) => s i.1) (Measure.pi μ) (Measure.pi fun i : Subtype p => μ i.1)Proof (Lean source)
theorem measurePreserving_pi_restrict_dep {X : ι → Type*} [∀ i, MeasurableSpace (X i)] (μ : ∀ i, Measure (X i)) [∀ i, IsProbabilityMeasure (μ i)] (p : ι → Prop) [DecidablePred p] : MeasurePreserving (fun (s : ∀ i, X i) (i : Subtype p) => s i.1) (Measure.pi μ) (Measure.pi fun i : Subtype p => μ i.1) := by have hsplit := MeasureTheory.measurePreserving_piEquivPiSubtypeProd (μ := μ) p have hfst : MeasurePreserving fst ((Measure.pi fun i : Subtype p => μ i.1).prod (Measure.pi fun i : Subtype (fun i => ¬ p i) => μ i.1)) (Measure.pi fun i : Subtype p => μ i.1) := measurePreserving_fst simpa [MeasurableEquiv.piEquivPiSubtypeProd, Function.comp_def] using hfst.comp hsplit -
measurePreserving_pi_restricttheorem — Dropping the coordinates outside a decidable sub-index of an i.i.d. product sample leaves the i.i.d. product sample over that sub-index.hypothesesι :sharedType u_3X :Type*μ :p :ι → PropconclusionMeasurePreserving (fun (s : ι → X) (i : Subtype p) => s i.1) (Measure.pi fun _ : ι => μ) (Measure.pi fun _ : Subtype p => μ)Proof (Lean source)
theorem measurePreserving_pi_restrict {X : Type*} [MeasurableSpace X] (μ : Measure X) [IsProbabilityMeasure μ] (p : ι → Prop) [DecidablePred p] : MeasurePreserving (fun (s : ι → X) (i : Subtype p) => s i.1) (Measure.pi fun _ : ι => μ) (Measure.pi fun _ : Subtype p => μ) := measurePreserving_pi_restrict_dep (fun _ : ι => μ) p -
map_pi_restricttheorem — The law of the sub-index coordinates of an i.i.d. product sample is the product law over that sub-index; this is the pushforward packaging of the measure-preserving statement.hypothesesι :sharedType u_3X :Type*μ :p :ι → PropProof (Lean source)
theorem map_pi_restrict {X : Type*} [MeasurableSpace X] (μ : Measure X) [IsProbabilityMeasure μ] (p : ι → Prop) [DecidablePred p] : (Measure.pi fun _ : ι => μ).map (fun (s : ι → X) (i : Subtype p) => s i.1) = Measure.pi fun _ : Subtype p => μ := (measurePreserving_pi_restrict μ p).map_eq -
integral_comp_pi_restricttheorem — Averaging a function of the sub-index coordinates over the whole i.i.d. product sample is the same as averaging it over an i.i.d. product sample indexed by the sub-index alone.hypothesesProof (Lean source)
theorem integral_comp_pi_restrict {X E : Type*} [MeasurableSpace X] [NormedAddCommGroup E] [NormedSpace ℝ E] (μ : Measure X) [IsProbabilityMeasure μ] (p : ι → Prop) [DecidablePred p] (g : (Subtype p → X) → E) : ∫ s : ι → X, g (fun i : Subtype p => s i.1) ∂(Measure.pi fun _ : ι => μ) = ∫ z, g z ∂(Measure.pi fun _ : Subtype p => μ) := by classical have hmeasf : Measurable (fun (s : ι → X) (i : Subtype p) => s i.1) := by fun_prop by_cases hg : AEStronglyMeasurable g (Measure.pi fun _ : Subtype p => μ) · have hmap := integral_map (f := g) hmeasf.aemeasurable (by rwa [map_pi_restrict μ p]) rw [map_pi_restrict μ p] at hmap exact hmap.symm · rw [integral_undef (fun h => hg h.aestronglyMeasurable), integral_undef fun h => hg ?_] -- Transport `L⁰`-measurability back across the product splitting. have hsplit := MeasureTheory.measurePreserving_piEquivPiSubtypeProd (μ := fun _ : ι => μ) p have hcomp := h.aestronglyMeasurable.comp_measurePreserving (hsplit.symm (MeasurableEquiv.piEquivPiSubtypeProd (fun _ : ι => X) p)) rw [show (fun s : ι → X => g fun i : Subtype p => s i.1) ∘ ⇑(MeasurableEquiv.piEquivPiSubtypeProd (fun _ : ι => X) p).symm = fun w => g w.1 by funext w simp only [Function.comp_apply] refine congrArg g ?_ funext i simp [MeasurableEquiv.piEquivPiSubtypeProd, Equiv.piEquivPiSubtypeProd, i.2]] at hcomp exact AEStronglyMeasurable.of_comp_fst hcomp (IsProbabilityMeasure.ne_zero _) -
measurePreserving_pi_restrict_finsettheorem — Dropping the coordinates outside a finite set of indices of an i.i.d. product sample leaves the i.i.d. product sample indexed by that finite set.hypothesesconclusionMeasurePreserving (fun (s : ι → X) (i : {i : ι // i ∈ S}) => s i.1) (Measure.pi fun _ : ι => μ) (Measure.pi fun _ : {i : ι // i ∈ S} => μ)Proof (Lean source)
theorem measurePreserving_pi_restrict_finset {X : Type*} [MeasurableSpace X] (μ : Measure X) [IsProbabilityMeasure μ] (S : Finset ι) : MeasurePreserving (fun (s : ι → X) (i : {i : ι // i ∈ S}) => s i.1) (Measure.pi fun _ : ι => μ) (Measure.pi fun _ : {i : ι // i ∈ S} => μ) := by classical convert measurePreserving_pi_restrict μ (· ∈ S) using 2 -
map_pi_restrict_finsettheorem — The law of the coordinates in a finite index set of an i.i.d. product sample is the product law over that finite set; this is the pushforward packaging of the measure-preserving statement.hypothesesconclusion(Measure.pi fun _ : ι => μ).map (fun (s : ι → X) (i : {i : ι // i ∈ S}) => s i.1)= Measure.pi fun _ : {i : ι // i ∈ S} => μProof (Lean source)
theorem map_pi_restrict_finset {X : Type*} [MeasurableSpace X] (μ : Measure X) [IsProbabilityMeasure μ] (S : Finset ι) : (Measure.pi fun _ : ι => μ).map (fun (s : ι → X) (i : {i : ι // i ∈ S}) => s i.1) = Measure.pi fun _ : {i : ι // i ∈ S} => μ := (measurePreserving_pi_restrict_finset μ S).map_eq -
integral_comp_pi_restrict_finsettheorem — Averaging a function of the coordinates in a finite index set over the whole i.i.d. product sample is the same as averaging it over an i.i.d. product sample indexed by that finite set.hypothesesconclusion∫ s : ι → X, g (fun i : {i : ι // i ∈ S} => s i.1) ∂(Measure.pi fun _ : ι => μ)= ∫ z, g z ∂(Measure.pi fun _ : {i : ι // i ∈ S} => μ)Proof (Lean source)
theorem integral_comp_pi_restrict_finset {X E : Type*} [MeasurableSpace X] [NormedAddCommGroup E] [NormedSpace ℝ E] (μ : Measure X) [IsProbabilityMeasure μ] (S : Finset ι) (g : ({i : ι // i ∈ S} → X) → E) : ∫ s : ι → X, g (fun i : {i : ι // i ∈ S} => s i.1) ∂(Measure.pi fun _ : ι => μ) = ∫ z, g z ∂(Measure.pi fun _ : {i : ι // i ∈ S} => μ) := by classical convert integral_comp_pi_restrict μ (· ∈ S) g using 2 congr 1 exact Subsingleton.elim _ _ -
hasIIDSample_of_isProbabilityMeasuretheorem — An i.i.d. sample with a given law always exists: every probability measure is the common marginal of some independent, identically distributed sample, realised on the infinite product space by the coordinate projections.hypothesesX :Type uP :conclusionProof (Lean source)
theorem hasIIDSample_of_isProbabilityMeasure {X : Type u} [MeasurableSpace X] (P : Measure X) [IsProbabilityMeasure P] : HasIIDSample P := ⟨ℕ → X, inferInstance, Measure.infinitePi fun _ : ℕ => P, ⟨iidSample_infinitePi P⟩⟩ -
hasIIDSample_iff_isProbabilityMeasuretheorem — The existence of an i.i.d. sample with a prescribed common marginal is equivalent to that marginal being a probability measure.Proof (Lean source)
theorem hasIIDSample_iff_isProbabilityMeasure {X : Type u} [MeasurableSpace X] (P : Measure X) : HasIIDSample P ↔ IsProbabilityMeasure P := by refine ⟨?_, fun _ => hasIIDSample_of_isProbabilityMeasure P⟩ rintro ⟨Ω, mΩ, μ, ⟨S⟩⟩ haveI : IsProbabilityMeasure μ := S.indep.isProbabilityMeasure rw [← S.map_eq 0] exact Measure.isProbabilityMeasure_map (S.meas 0).aemeasurable -
measurable_finCoordinatewisetheorem — Applying a measurable observation rule separately to every position of a finite sample produces a measurable recoded sample.hypothesesconclusionMeasurable (fun z : Fin n → X => fun i => phi (z i))Proof (Lean source)
theorem measurable_finCoordinatewise (n : ℕ) {phi : X → Y} (hphi : Measurable phi) : Measurable (fun z : Fin n → X => fun i => phi (z i)) := by exact measurable_pi_lambda _ fun i => hphi.comp (measurable_pi_apply i) -
map_pi_finCoordinatewisetheorem — Under a common probability law, applying a measurable observation rule coordinate by coordinate turns the finite product law into the finite product of the recoded marginal law.hypothesesProof (Lean source)
theorem map_pi_finCoordinatewise (n : ℕ) (mu : Measure X) [IsProbabilityMeasure mu] {phi : X → Y} (hphi : Measurable phi) : (Measure.pi (fun _ : Fin n => mu)).map (fun z : Fin n → X => fun i => phi (z i)) = Measure.pi (fun _ : Fin n => mu.map phi) := by let _ : IsProbabilityMeasure (mu.map phi) := Measure.isProbabilityMeasure_map hphi.aemeasurable exact Measure.pi_map_pi (fun _ : Fin n => hphi.aemeasurable) -
integral_comp_finCoordinatewisetheorem — Under a common probability law, if the observation rule is measurable and the real-valued statistic of the recoded sample is measurable, then its expectation after coordinatewise recoding equals its expectation under the product of the recoded marginal law.hypothesesX :sharedType uXY :sharedType uYn :ℕmu :phi :X → Yhphi :Measurable phig :(Fin n → Y) → ℝhg :Proof (Lean source)
theorem integral_comp_finCoordinatewise (n : ℕ) (mu : Measure X) [IsProbabilityMeasure mu] {phi : X → Y} (hphi : Measurable phi) (g : (Fin n → Y) → ℝ) (hg : Measurable g) : (∫ z : Fin n → X, g (fun i => phi (z i)) ∂Measure.pi (fun _ : Fin n => mu)) = ∫ y, g y ∂Measure.pi (fun _ : Fin n => mu.map phi) := by let coord : (Fin n → X) → (Fin n → Y) := fun z i => phi (z i) have hcoord : Measurable coord := measurable_finCoordinatewise n hphi calc (∫ z : Fin n → X, g (fun i => phi (z i)) ∂Measure.pi (fun _ : Fin n => mu)) = ∫ y, g y ∂(Measure.pi (fun _ : Fin n => mu)).map coord := (integral_map hcoord.aemeasurable hg.aestronglyMeasurable).symm _ = ∫ y, g y ∂Measure.pi (fun _ : Fin n => mu.map phi) := by rw [map_pi_finCoordinatewise n mu hphi]