Stat.Sample.OccupancyWeightedMean
This module provides totalized occupancy-weighted differences of within-group sample means and a weak-second-moment variance bound under fixed overlap.
Basic 15 core · 13 supporting 15 to review This module defines totalized group/arm counts and residual sample means for a finite product sample. ★ measurable_occupancyWeightedResidual
Occupancy-weighted residual means: design statistics
This module defines totalized group/arm counts and residual sample means for a finite product sample. Every zero-count boundary is part of the definition, including the completely empty sample and an empty group type. It also exposes the measurability API needed to integrate the statistics under a product law.
The arm/group event consists of observations having the requested finite group label and Boolean arm label.
Definition (Lean source)
The group event consists of observations having the requested finite group label, irrespective of arm.
Definition (Lean source)
The residual at an arm/group label is the outcome minus its supplied arm/group center.
The supported residual equals the arm/group residual on its own label event and is zero elsewhere.
Definition (Lean source)
The finite design records only the group and arm label of each sample coordinate.
The arm/group count is the number of sample coordinates with both the requested group and requested arm.
The group count is the sum of its control and treated arm counts.
Definition (Lean source)
A sample group is usable exactly when both of its empirical arm counts are positive.
Definition (Lean source)
The usable-group total is the total empirical occupancy of groups having both arms represented.
Definition (Lean source)
The residual sum in an arm/group cell adds only coordinates belonging to that cell.
Definition (Lean source)
The totalized arm residual mean is the cell residual sum divided by its count when that count is positive, and zero when the count is zero.
Definition (Lean source)
The occupancy-weighted residual statistic averages, over usable groups, each group occupancy times the treated-minus-control residual mean. It is zero when no group is usable. The law argument fixes the intended public API but does not alter this sample statistic.
Definition (Lean source)
The inverse usable occupancy is the reciprocal of the usable-group total when positive, and zero at the empirical zero boundary.
The design variance factor is the usable-group sum of squared occupancy weights times the two reciprocal arm counts, totalized to zero when no group is usable.
Definition (Lean source)
Measurable group labels, arm labels, and outcomes make the zero-safe occupancy-weighted residual measurable on the finite product sample space.
Formal statement
Proof (Lean source)
13 supporting declarations (lemmas, instances)
-
measurableSet_groupEventlemma — A measurable group label has measurable group fibers.hypothesesconclusionMeasurableSet (groupEvent group k)Proof (Lean source)
lemma measurableSet_groupEvent (group : Omega -> kappa) (hgroup : Measurable group) (k : kappa) : MeasurableSet (groupEvent group k) := by change MeasurableSet (group ⁻¹' {k}) exact (measurableSet_singleton k).preimage hgroup -
measurableSet_armGroupEventlemma — Measurable group and arm labels have measurable joint arm/group fibers.hypothesesgroup :Omega -> kappaarm :Omega -> Boolhgroup :Measurable groupharm :Measurable arma :k :kappaconclusionMeasurableSet (armGroupEvent group arm a k)Proof (Lean source)
lemma measurableSet_armGroupEvent (group : Omega -> kappa) (arm : Omega -> Bool) (hgroup : Measurable group) (harm : Measurable arm) (a : Bool) (k : kappa) : MeasurableSet (armGroupEvent group arm a k) := by rw [show armGroupEvent group arm a k = groupEvent group k ∩ {omega | arm omega = a} by ext omega; simp [armGroupEvent, groupEvent]] exact (measurableSet_groupEvent group hgroup k).inter ((measurableSet_singleton a).preimage harm) -
measurable_sampleDesignlemma — Measurable group and arm labels make the coordinatewise finite design measurable.hypothesesconclusionMeasurable (sampleDesign (n := n) group arm)Proof (Lean source)
lemma measurable_sampleDesign {n : Nat} (group : Omega -> kappa) (arm : Omega -> Bool) (hgroup : Measurable group) (harm : Measurable arm) : Measurable (sampleDesign (n := n) group arm) := by apply measurable_pi_lambda intro i exact (hgroup.comp (measurable_pi_apply i : Measurable fun z : Fin n -> Omega => z i)).prodMk (harm.comp (measurable_pi_apply i : Measurable fun z : Fin n -> Omega => z i)) -
measurable_groupArmCountlemma — Measurable group and arm labels make each fixed arm/group count measurable on a finite product sample.hypothesesn :group :Omega -> kappaarm :Omega -> Boolhgroup :Measurable groupharm :Measurable arma :k :kappaconclusionProof (Lean source)
lemma measurable_groupArmCount {n : Nat} (group : Omega -> kappa) (arm : Omega -> Bool) (hgroup : Measurable group) (harm : Measurable arm) (a : Bool) (k : kappa) : Measurable (fun z : Fin n -> Omega => groupArmCount group arm z a k) := by let count : (Fin n -> kappa × Bool) -> Nat := fun d => (Finset.univ.filter fun i => (d i).1 = k ∧ (d i).2 = a).card have hcount : Measurable count := Measurable.of_discrete change Measurable (count ∘ sampleDesign group arm) exact hcount.comp (measurable_sampleDesign group arm hgroup harm) -
measurable_groupCountlemma — Measurable group and arm labels make each fixed group count measurable on the finite product sample space.hypothesesn :group :Omega -> kappaarm :Omega -> Boolhgroup :Measurable groupharm :Measurable armk :kappaconclusionProof (Lean source)
lemma measurable_groupCount {n : Nat} (group : Omega -> kappa) (arm : Omega -> Bool) (hgroup : Measurable group) (harm : Measurable arm) (k : kappa) : Measurable (fun z : Fin n -> Omega => groupCount group arm z k) := by unfold groupCount change Measurable ((fun z : Fin n -> Omega => groupArmCount group arm z false k) + fun z => groupArmCount group arm z true k) exact (measurable_groupArmCount group arm hgroup harm false k).add (measurable_groupArmCount group arm hgroup harm true k) -
measurableSet_usableGrouplemma — Measurable group and arm labels make the event that a fixed empirical group has both arms represented measurable.hypothesesn :group :Omega -> kappaarm :Omega -> Boolhgroup :Measurable groupharm :Measurable armk :kappaconclusionProof (Lean source)
lemma measurableSet_usableGroup {n : Nat} (group : Omega -> kappa) (arm : Omega -> Bool) (hgroup : Measurable group) (harm : Measurable arm) (k : kappa) : MeasurableSet {z : Fin n -> Omega | usableGroup group arm z k} := by have hfalse := measurable_groupArmCount (n := n) group arm hgroup harm false k have htrue := measurable_groupArmCount (n := n) group arm hgroup harm true k exact (measurableSet_lt measurable_const hfalse).inter (measurableSet_lt measurable_const htrue) -
measurable_usableGroupTotallemma — Measurable group and arm labels make the total occupancy in empirically usable groups measurable.hypothesesconclusionProof (Lean source)
lemma measurable_usableGroupTotal {n : Nat} (group : Omega -> kappa) (arm : Omega -> Bool) (hgroup : Measurable group) (harm : Measurable arm) : Measurable (fun z : Fin n -> Omega => usableGroupTotal group arm z) := by classical unfold usableGroupTotal apply measurable_sum intro k hk exact Measurable.ite (measurableSet_usableGroup group arm hgroup harm k) (measurable_groupCount group arm hgroup harm k) measurable_const -
measurable_armGroupResiduallemma — A measurable outcome makes each arm/group-centered residual measurable.hypothesesconclusionMeasurable (armGroupResidual Y center a k)Proof (Lean source)
lemma measurable_armGroupResidual (Y : Omega -> Real) (center : Bool -> kappa -> Real) (hY : Measurable Y) (a : Bool) (k : kappa) : Measurable (armGroupResidual Y center a k) := by unfold armGroupResidual change Measurable (Y - fun _ => center a k) exact hY.sub measurable_const -
measurable_supportedArmGroupResiduallemma — Measurable group labels, arm labels, and outcomes make each residual restricted to its own arm/group cell measurable.hypothesesgroup :Omega -> kappaarm :Omega -> BoolY :Omega -> Realhgroup :Measurable groupharm :Measurable armhY :a :k :kappaconclusionMeasurable (supportedArmGroupResidual group arm Y center a k)Proof (Lean source)
lemma measurable_supportedArmGroupResidual (group : Omega -> kappa) (arm : Omega -> Bool) (Y : Omega -> Real) (center : Bool -> kappa -> Real) (hgroup : Measurable group) (harm : Measurable arm) (hY : Measurable Y) (a : Bool) (k : kappa) : Measurable (supportedArmGroupResidual group arm Y center a k) := by unfold supportedArmGroupResidual exact (measurable_armGroupResidual Y center hY a k).indicator (measurableSet_armGroupEvent group arm hgroup harm a k) -
measurable_armResidualSumlemma — Measurable group labels, arm labels, and outcomes make each arm/group residual sum measurable on the finite product sample space.hypothesesn :group :Omega -> kappaarm :Omega -> BoolY :Omega -> Realhgroup :Measurable groupharm :Measurable armhY :a :k :kappaconclusionProof (Lean source)
lemma measurable_armResidualSum {n : Nat} (group : Omega -> kappa) (arm : Omega -> Bool) (Y : Omega -> Real) (center : Bool -> kappa -> Real) (hgroup : Measurable group) (harm : Measurable arm) (hY : Measurable Y) (a : Bool) (k : kappa) : Measurable (fun z : Fin n -> Omega => armResidualSum group arm Y center z a k) := by classical unfold armResidualSum apply measurable_sum intro i hi exact (measurable_supportedArmGroupResidual group arm Y center hgroup harm hY a k).comp (measurable_pi_apply i : Measurable fun z : Fin n -> Omega => z i) -
measurable_armResidualMeanlemma — Measurable group labels, arm labels, and outcomes make each zero-safe arm/group residual mean measurable on the finite product sample space.hypothesesn :group :Omega -> kappaarm :Omega -> BoolY :Omega -> Realhgroup :Measurable groupharm :Measurable armhY :a :k :kappaconclusionProof (Lean source)
lemma measurable_armResidualMean {n : Nat} (group : Omega -> kappa) (arm : Omega -> Bool) (Y : Omega -> Real) (center : Bool -> kappa -> Real) (hgroup : Measurable group) (harm : Measurable arm) (hY : Measurable Y) (a : Bool) (k : kappa) : Measurable (fun z : Fin n -> Omega => armResidualMean group arm Y center z a k) := by let count := fun z : Fin n -> Omega => groupArmCount group arm z a k have hcount : Measurable count := measurable_groupArmCount group arm hgroup harm a k have hpos : MeasurableSet {z | 0 < count z} := measurableSet_lt measurable_const hcount have hcast : Measurable (fun z => (count z : Real)) := (Measurable.of_discrete : Measurable fun m : Nat => (m : Real)).comp hcount unfold armResidualMean exact Measurable.ite hpos (hcast.inv.mul (measurable_armResidualSum group arm Y center hgroup harm hY a k)) measurable_const -
measurable_inverseUsableGroupTotallemma — Measurable group and arm labels make the zero-safe reciprocal usable occupancy measurable on the finite product sample space.hypothesesconclusionMeasurable (inverseUsableGroupTotal (n := n) group arm)Proof (Lean source)
lemma measurable_inverseUsableGroupTotal {n : Nat} (group : Omega -> kappa) (arm : Omega -> Bool) (hgroup : Measurable group) (harm : Measurable arm) : Measurable (inverseUsableGroupTotal (n := n) group arm) := by have htotal : Measurable (fun z : Fin n -> Omega => usableGroupTotal group arm z) := measurable_usableGroupTotal group arm hgroup harm have hpos : MeasurableSet {z : Fin n -> Omega | 0 < usableGroupTotal group arm z} := measurableSet_lt measurable_const htotal have htotalCast : Measurable (fun z : Fin n -> Omega => (usableGroupTotal group arm z : Real)) := (Measurable.of_discrete : Measurable fun m : Nat => (m : Real)).comp htotal unfold inverseUsableGroupTotal exact Measurable.ite hpos htotalCast.inv measurable_const -
measurable_occupancyDesignVarianceFactorlemma — Measurable group and arm labels make the zero-safe occupancy design variance factor measurable on the finite product sample space.hypothesesconclusionMeasurable (occupancyDesignVarianceFactor (n := n) group arm)Proof (Lean source)
lemma measurable_occupancyDesignVarianceFactor {n : Nat} (group : Omega -> kappa) (arm : Omega -> Bool) (hgroup : Measurable group) (harm : Measurable arm) : Measurable (occupancyDesignVarianceFactor (n := n) group arm) := by classical have htotal : Measurable (fun z : Fin n -> Omega => usableGroupTotal group arm z) := measurable_usableGroupTotal group arm hgroup harm have hpos : MeasurableSet {z : Fin n -> Omega | 0 < usableGroupTotal group arm z} := measurableSet_lt measurable_const htotal have htotalCast : Measurable (fun z : Fin n -> Omega => (usableGroupTotal group arm z : Real)) := (Measurable.of_discrete : Measurable fun m : Nat => (m : Real)).comp htotal have hsum : Measurable (fun z : Fin n -> Omega => ∑ k, if usableGroup group arm z k then (groupCount group arm z k : Real) ^ 2 * ((groupArmCount group arm z true k : Real)⁻¹ + (groupArmCount group arm z false k : Real)⁻¹) else 0) := by apply measurable_sum intro k hk have hgroupCount := measurable_groupCount (n := n) group arm hgroup harm k have hgroupCountCast : Measurable (fun z : Fin n -> Omega => (groupCount group arm z k : Real)) := (Measurable.of_discrete : Measurable fun m : Nat => (m : Real)).comp hgroupCount have htrue := measurable_groupArmCount (n := n) group arm hgroup harm true k have hfalse := measurable_groupArmCount (n := n) group arm hgroup harm false k have htrueCast : Measurable (fun z : Fin n -> Omega => (groupArmCount group arm z true k : Real)) := (Measurable.of_discrete : Measurable fun m : Nat => (m : Real)).comp htrue have hfalseCast : Measurable (fun z : Fin n -> Omega => (groupArmCount group arm z false k : Real)) := (Measurable.of_discrete : Measurable fun m : Nat => (m : Real)).comp hfalse exact Measurable.ite (measurableSet_usableGroup group arm hgroup harm k) ((hgroupCountCast.pow measurable_const).mul (htrueCast.inv.add hfalseCast.inv)) measurable_const unfold occupancyDesignVarianceFactor exact Measurable.ite hpos ((htotalCast.inv.pow measurable_const).mul hsum) measurable_const
BinomialDesign 3 core · 0 supporting 3 to review This module turns weighted sums over finite Boolean assignments into binomial sums and controls the inverse-arm contribution of one occupied group. ★ sum_bernoulli_local_variance_le_share
Bernoulli enumeration for occupancy-weighted design factors
This module turns weighted sums over finite Boolean assignments into binomial sums and controls the inverse-arm contribution of one occupied group. It is entirely algebraic and does not use conditional probability.
The two-arm inverse-count contribution is the sum of the inverse success and failure counts when both are positive, and zero at either endpoint.
The binomial interior indicator is one when both success and failure counts are positive, and zero at either endpoint.
Definition (Lean source)
FiniteDesign 1 core · 0 supporting 1 to review This module assembles groupwise inverse-arm bounds into an algebraic comparison between the expected occupancy design variance factor and reciprocal usable occupancy. ★ sum_jointWeight_variance_le_inverse
Finite enumeration for occupancy-weighted design factors
This module assembles groupwise inverse-arm bounds into an algebraic comparison between the expected occupancy design variance factor and reciprocal usable occupancy. Zero-mass group fibers vanish before any conditional arm probability is formed.
If all joint group/arm masses are nonnegative, their two arm masses sum to the group mass, the overlap margin is positive and at most one half, and each positive-mass group gives both arms at least the overlap share, the joint-design average of the occupancy variance factor is bounded by a margin-dependent multiple of average reciprocal usable occupancy. Zero-mass groups contribute zero before any conditional arm probability is formed.
Formal statement
Proof (Lean source)
MomentBounds 1 core · 3 supporting 1 to review This module proves finite-product orthogonality, a one-coordinate second-moment comparison, and the design-only reciprocal-count estimate for occupancy-weighted differences of within-group residual means. ★ integral_occupancyDesignVarianceFactor_le_reciprocal
Product-moment bounds for occupancy-weighted residual means
This module proves finite-product orthogonality, a one-coordinate second-moment comparison, and the design-only reciprocal-count estimate for occupancy-weighted differences of within-group residual means. Outcomes are real-valued and need only the stated supported second-moment bounds.
If group and arm labels are measurable, the overlap margin is positive and at most one half, and both arms receive at least that share in every positive-mass group, the expected design variance factor is at most sixteen divided by the squared margin times one minus the margin, multiplied by expected reciprocal usable occupancy. This includes zero-mass groups, empty samples, empty group types, and every zero-count boundary.
Formal statement
Proof (Lean source)
3 supporting declarations (lemmas, instances)
-
supportedArmGroupResidual_mul_eq_zero_of_nelemma — When two arm/group labels differ, their supported residuals have zero pointwise product because their supports are disjoint.hypothesesgroup :Omega -> kappaarm :Omega -> BoolY :Omega -> Reala b :k l :kappahne :(a, k) ≠ (b, l)omega :OmegaconclusionsupportedArmGroupResidual group arm Y center a k omega * supportedArmGroupResidual group arm Y center b l omega= 0Proof (Lean source)
lemma supportedArmGroupResidual_mul_eq_zero_of_ne (group : Omega -> kappa) (arm : Omega -> Bool) (Y : Omega -> Real) (center : Bool -> kappa -> Real) (a b : Bool) (k l : kappa) (hne : (a, k) ≠ (b, l)) (omega : Omega) : supportedArmGroupResidual group arm Y center a k omega * supportedArmGroupResidual group arm Y center b l omega = 0 := by classical simp only [supportedArmGroupResidual, Set.indicator_apply] by_cases h₁ : omega ∈ armGroupEvent group arm a k · by_cases h₂ : omega ∈ armGroupEvent group arm b l · exact elim (hne (Prod.ext (h₁.2.symm.trans h₂.2) (h₁.1.symm.trans h₂.1))) · simp [h₁, h₂] · simp [h₁] -
integral_designWeight_residual_cross_coordinates_eq_zerolemma — If group labels, arm labels, and outcomes are measurable, every supported residual has a finite second moment, each residual is centered within its arm/group cell, and the two sample coordinates differ, any finite-design weight times their two supported residuals has product-law integral zero.hypothesesn :mu :Measure Omegagroup :Omega -> kappaarm :Omega -> BoolY :Omega -> Realhgroup :Measurable groupharm :Measurable armhY :hmem :∀ a k, MemLp (supportedArmGroupResidual group arm Y center a k) 2 muhcenter :∀ a k, ∫ omega in armGroupEvent group arm a k, armGroupResidual Y center a k omega ∂mu = 0i j :Fin nhij :i ≠ ja b :k l :kappaconclusion∫ z : Fin n -> Omega, W (sampleDesign group arm z) * supportedArmGroupResidual group arm Y center a k (z i) * supportedArmGroupResidual group arm Y center b l (z j) ∂(Measure.pi (fun _ : Fin n => mu))= 0Proof (Lean source)
lemma integral_designWeight_residual_cross_coordinates_eq_zero {n : Nat} (mu : Measure Omega) [IsProbabilityMeasure mu] (group : Omega -> kappa) (arm : Omega -> Bool) (Y : Omega -> Real) (center : Bool -> kappa -> Real) (hgroup : Measurable group) (harm : Measurable arm) (hY : Measurable Y) (hmem : ∀ a k, MemLp (supportedArmGroupResidual group arm Y center a k) 2 mu) (hcenter : ∀ a k, ∫ omega in armGroupEvent group arm a k, armGroupResidual Y center a k omega ∂mu = 0) (W : (Fin n -> kappa × Bool) -> Real) (i j : Fin n) (hij : i ≠ j) (a b : Bool) (k l : kappa) : ∫ z : Fin n -> Omega, W (sampleDesign group arm z) * supportedArmGroupResidual group arm Y center a k (z i) * supportedArmGroupResidual group arm Y center b l (z j) ∂(Measure.pi (fun _ : Fin n => mu)) = 0 := by -- Split off coordinate `i` with `piEquivPiSubtypeProd`. For every fixed -- complement, the weight and the `j` residual depend on `omega_i` only -- through its finite design label. Partition that one-coordinate integral -- by labels and use `hcenter` on each fiber. classical let f : Fin n -> Omega -> Real := fun q => if q = i then supportedArmGroupResidual group arm Y center a k else if q = j then supportedArmGroupResidual group arm Y center b l else fun _ => 1 have hf : ∀ q, Integrable (f q) mu := by intro q dsimp [f] split_ifs · exact (hmem a k).integrable (by norm_num) · exact (hmem b l).integrable (by norm_num) · exact integrable_const 1 have hformula := integral_designWeight_mul_prod mu group arm hgroup harm W f hf have hrhs : (∑ d : Fin n -> kappa × Bool, W d * ∏ q, ∫ omega in armGroupEvent group arm (d q).2 (d q).1, f q omega ∂mu) = 0 := by apply Finset.sum_eq_zero intro d hd have hzero : (∫ omega in armGroupEvent group arm (d i).2 (d i).1, f i omega ∂mu) = 0 := by simpa [f] using setIntegral_supported_eq_zero mu group arm Y center hgroup harm hcenter a (d i).2 k (d i).1 rw [Finset.prod_eq_zero (Finset.mem_univ i) hzero] simp have hprod_eval (z : Fin n -> Omega) : (∏ q, f q (z q)) = supportedArmGroupResidual group arm Y center a k (z i) * supportedArmGroupResidual group arm Y center b l (z j) := by calc (∏ q, f q (z q)) = ∏ q, (if q = i then supportedArmGroupResidual group arm Y center a k (z q) else 1) * (if q = j then supportedArmGroupResidual group arm Y center b l (z q) else 1) := by apply Finset.prod_congr rfl intro q hq by_cases hqi : q = i · subst q simp [f, hij] · by_cases hqj : q = j · subst q simp [f, hqi] · simp [f, hqi, hqj] _ = (∏ q, if q = i then supportedArmGroupResidual group arm Y center a k (z q) else 1) * ∏ q, if q = j then supportedArmGroupResidual group arm Y center b l (z q) else 1 := by rw [Finset.prod_mul_distrib] _ = supportedArmGroupResidual group arm Y center a k (z i) * supportedArmGroupResidual group arm Y center b l (z j) := by simp calc (∫ z : Fin n -> Omega, W (sampleDesign group arm z) * supportedArmGroupResidual group arm Y center a k (z i) * supportedArmGroupResidual group arm Y center b l (z j) ∂(Measure.pi (fun _ : Fin n => mu))) = ∫ z : Fin n -> Omega, W (sampleDesign group arm z) * ∏ q, f q (z q) ∂(Measure.pi (fun _ : Fin n => mu)) := by congr 1 funext z rw [hprod_eval] ring _ = ∑ d : Fin n -> kappa × Bool, W d * ∏ q, ∫ omega in armGroupEvent group arm (d q).2 (d q).1, f q omega ∂mu := hformula _ = 0 := hrhs -
integral_designWeight_residual_sq_le_indicatorlemma — If group labels, arm labels, and outcomes are measurable, every supported residual has a finite second moment, each cell's residual second moment obeys the stated envelope, and the design weight is nonnegative, the weighted residual square at one sample coordinate is bounded in expectation by the corresponding weighted cell indicator envelope.hypothesesn :mu :Measure Omegagroup :Omega -> kappaarm :Omega -> BoolY :Omega -> RealV :hgroup :Measurable groupharm :Measurable armhY :hmem :∀ a k, MemLp (supportedArmGroupResidual group arm Y center a k) 2 muhsq :∀ a k,∫ omega in armGroupEvent group arm a k, (armGroupResidual Y center a k omega) ^ 2 ∂mu≤ (mu (armGroupEvent group arm a k)).toReal * V ^ 2hW :∀ d, 0 ≤ W di :Fin na :k :kappaconclusion∫ z : Fin n -> Omega, W (sampleDesign group arm z) * (supportedArmGroupResidual group arm Y center a k (z i)) ^ 2 ∂(Measure.pi (fun _ : Fin n => mu))≤ V ^ 2 * ∫ z : Fin n -> Omega, W (sampleDesign group arm z) * (armGroupEvent group arm a k).indicator (fun _ => (1 : Real)) (z i) ∂(Measure.pi (fun _ : Fin n => mu))Proof (Lean source)
lemma integral_designWeight_residual_sq_le_indicator {n : Nat} (mu : Measure Omega) [IsProbabilityMeasure mu] (group : Omega -> kappa) (arm : Omega -> Bool) (Y : Omega -> Real) (center : Bool -> kappa -> Real) (V : Real) (hgroup : Measurable group) (harm : Measurable arm) (hY : Measurable Y) (hmem : ∀ a k, MemLp (supportedArmGroupResidual group arm Y center a k) 2 mu) (hsq : ∀ a k, ∫ omega in armGroupEvent group arm a k, (armGroupResidual Y center a k omega) ^ 2 ∂mu ≤ (mu (armGroupEvent group arm a k)).toReal * V ^ 2) (W : (Fin n -> kappa × Bool) -> Real) (hW : ∀ d, 0 ≤ W d) (i : Fin n) (a : Bool) (k : kappa) : ∫ z : Fin n -> Omega, W (sampleDesign group arm z) * (supportedArmGroupResidual group arm Y center a k (z i)) ^ 2 ∂(Measure.pi (fun _ : Fin n => mu)) ≤ V ^ 2 * ∫ z : Fin n -> Omega, W (sampleDesign group arm z) * (armGroupEvent group arm a k).indicator (fun _ => (1 : Real)) (z i) ∂(Measure.pi (fun _ : Fin n => mu)) := by -- Use the same replacement-coordinate split. On each fixed design fiber -- `W` is constant; pull it out and apply `hsq`. `hmem` supplies all Fubini -- and integrability obligations for the unbounded residual. classical let f : Fin n -> Omega -> Real := fun q => if q = i then fun omega => (supportedArmGroupResidual group arm Y center a k omega) ^ 2 else fun _ => 1 let g : Fin n -> Omega -> Real := fun q => if q = i then fun omega => V ^ 2 * (armGroupEvent group arm a k).indicator (fun _ => (1 : Real)) omega else fun _ => 1 have hf : ∀ q, Integrable (f q) mu := by intro q dsimp [f] split_ifs · exact (hmem a k).integrable_sq · exact integrable_const 1 have hg : ∀ q, Integrable (g q) mu := by intro q dsimp [g] split_ifs · exact ((integrable_const (1 : Real)).indicator (measurableSet_armGroupEvent group arm hgroup harm a k)).const_mul (V ^ 2) · exact integrable_const 1 have hformula_f := integral_designWeight_mul_prod mu group arm hgroup harm W f hf have hformula_g := integral_designWeight_mul_prod mu group arm hgroup harm W g hg have hsum_le : (∑ d : Fin n -> kappa × Bool, W d * ∏ q, ∫ omega in armGroupEvent group arm (d q).2 (d q).1, f q omega ∂mu) ≤ ∑ d : Fin n -> kappa × Bool, W d * ∏ q, ∫ omega in armGroupEvent group arm (d q).2 (d q).1, g q omega ∂mu := by apply Finset.sum_le_sum intro d hd apply mul_le_mul_of_nonneg_left _ (hW d) apply Finset.prod_le_prod · intro q hq apply integral_nonneg intro omega dsimp [f] split_ifs <;> positivity · intro q hq by_cases hqi : q = i · subst q simpa [f, g] using setIntegral_supported_sq_le_indicator mu group arm Y center V hgroup harm hsq a (d i).2 k (d i).1 · simp [f, g, hqi] have hprod_f (z : Fin n -> Omega) : (∏ q, f q (z q)) = (supportedArmGroupResidual group arm Y center a k (z i)) ^ 2 := by calc (∏ q, f q (z q)) = ∏ q, if q = i then (supportedArmGroupResidual group arm Y center a k (z q)) ^ 2 else 1 := by apply Finset.prod_congr rfl intro q hq by_cases hqi : q = i <;> simp [f, hqi] _ = (supportedArmGroupResidual group arm Y center a k (z i)) ^ 2 := by simpa using (Finset.prod_ite_eq' univ i (fun q => (supportedArmGroupResidual group arm Y center a k (z q)) ^ 2)) have hprod_g (z : Fin n -> Omega) : (∏ q, g q (z q)) = V ^ 2 * (armGroupEvent group arm a k).indicator (fun _ => (1 : Real)) (z i) := by calc (∏ q, g q (z q)) = ∏ q, if q = i then V ^ 2 * (armGroupEvent group arm a k).indicator (fun _ => (1 : Real)) (z q) else 1 := by apply Finset.prod_congr rfl intro q hq by_cases hqi : q = i <;> simp [g, hqi] _ = V ^ 2 * (armGroupEvent group arm a k).indicator (fun _ => (1 : Real)) (z i) := by simpa using (Finset.prod_ite_eq' univ i (fun q => V ^ 2 * (armGroupEvent group arm a k).indicator (fun _ => (1 : Real)) (z q))) calc (∫ z : Fin n -> Omega, W (sampleDesign group arm z) * (supportedArmGroupResidual group arm Y center a k (z i)) ^ 2 ∂(Measure.pi (fun _ : Fin n => mu))) = ∫ z : Fin n -> Omega, W (sampleDesign group arm z) * ∏ q, f q (z q) ∂(Measure.pi (fun _ : Fin n => mu)) := by congr 1 funext z rw [hprod_f] _ = ∑ d : Fin n -> kappa × Bool, W d * ∏ q, ∫ omega in armGroupEvent group arm (d q).2 (d q).1, f q omega ∂mu := hformula_f _ ≤ ∑ d : Fin n -> kappa × Bool, W d * ∏ q, ∫ omega in armGroupEvent group arm (d q).2 (d q).1, g q omega ∂mu := hsum_le _ = ∫ z : Fin n -> Omega, W (sampleDesign group arm z) * ∏ q, g q (z q) ∂(Measure.pi (fun _ : Fin n => mu)) := hformula_g.symm _ = V ^ 2 * ∫ z : Fin n -> Omega, W (sampleDesign group arm z) * (armGroupEvent group arm a k).indicator (fun _ => (1 : Real)) (z i) ∂(Measure.pi (fun _ : Fin n => mu)) := by rw [← integral_const_mul] congr 1 funext z rw [hprod_g] ring
Variance 1 core · 1 supporting 1 to review This module represents the occupancy-weighted statistic as a finite sum of supported residuals, proves its square integrability, and bounds its second moment by expected reciprocal usable occupancy. ★ integral_occupancyWeightedResidual_sq_le_reciprocal
Weak-moment variance bound for occupancy-weighted residual means
This module represents the occupancy-weighted statistic as a finite sum of supported residuals, proves its square integrability, and bounds its second moment by expected reciprocal usable occupancy. Outcomes need only supported arm/group second moments; all empirical zero-count cases are totalized.
If group labels, arm labels, and outcomes are measurable, every supported residual has a finite second moment, residuals are centered within every arm/group cell, their cellwise second moments obey the stated envelope, the overlap margin is positive and at most one half, and both arms receive at least that share in every positive-mass group, the squared occupancy-weighted residual has product-law expectation at most sixteen divided by the squared margin times one minus the margin, multiplied by the squared envelope and expected reciprocal usable occupancy.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
occupancyWeightedResidual_memLp_twotheorem — If group labels, arm labels, and outcomes are measurable and every arm/group-supported residual has a finite second moment, the zero-safe occupancy-weighted residual has a finite second moment under every finite independent product sample.hypothesesn :mu :Measure Omegagroup :Omega -> kappaarm :Omega -> BoolY :Omega -> Realhgroup :Measurable groupharm :Measurable armhY :hmem :∀ a k, MemLp (supportedArmGroupResidual group arm Y center a k) 2 muconclusionMemLp (occupancyWeightedResidual (n := n) mu group arm Y center) 2 (Measure.pi (fun _ : Fin n => mu))Proof (Lean source)
theorem occupancyWeightedResidual_memLp_two {n : Nat} (mu : Measure Omega) [IsProbabilityMeasure mu] (group : Omega -> kappa) (arm : Omega -> Bool) (Y : Omega -> Real) (center : Bool -> kappa -> Real) (hgroup : Measurable group) (harm : Measurable arm) (hY : Measurable Y) (hmem : ∀ a k, MemLp (supportedArmGroupResidual group arm Y center a k) 2 mu) : MemLp (occupancyWeightedResidual (n := n) mu group arm Y center) 2 (Measure.pi (fun _ : Fin n => mu)) := by -- Expand the statistic as a finite sum of supported residual coordinates. -- Its design coefficients range over a finite set, hence are bounded; -- close under finite sums and bounded scalar multiplication in `MemLp`. classical let weight : (Fin n → kappa × Bool) → Bool → kappa → Real := occupancyResidualWeight let bound : Real := ∑ d : Fin n → kappa × Bool, ∑ a : Bool, ∑ k : kappa, |weight d a k| have hweight_bound (d : Fin n → kappa × Bool) (a : Bool) (k : kappa) : |weight d a k| ≤ bound := by dsimp [bound] calc |weight d a k| ≤ ∑ k' : kappa, |weight d a k'| := Finset.single_le_sum (fun k' _ => abs_nonneg (weight d a k')) (Finset.mem_univ k) _ ≤ ∑ a' : Bool, ∑ k' : kappa, |weight d a' k'| := Finset.single_le_sum (fun a' _ => sum_nonneg fun k' _ => abs_nonneg (weight d a' k')) (Finset.mem_univ a) _ ≤ ∑ d' : Fin n → kappa × Bool, ∑ a' : Bool, ∑ k' : kappa, |weight d' a' k'| := Finset.single_le_sum (fun d' _ => sum_nonneg fun a' _ => sum_nonneg fun k' _ => abs_nonneg (weight d' a' k')) (Finset.mem_univ d) have hterm (i : Fin n) (a : Bool) (k : kappa) : MemLp (fun z : Fin n → Omega => weight (sampleDesign group arm z) a k * supportedArmGroupResidual group arm Y center a k (z i)) 2 (Measure.pi (fun _ : Fin n => mu)) := by have hr := (hmem a k).comp_measurePreserving (measurePreserving_eval (fun _ : Fin n => mu) i) have hw : Measurable (fun d : Fin n → kappa × Bool => weight d a k) := Measurable.of_discrete apply hr.of_le_mul · have hm : AEStronglyMeasurable (((fun d : Fin n → kappa × Bool => weight d a k) ∘ sampleDesign group arm) * (supportedArmGroupResidual group arm Y center a k ∘ fun z => z i)) (Measure.pi (fun _ : Fin n => mu)) := ((hw.comp (measurable_sampleDesign group arm hgroup harm)).mul ((measurable_supportedArmGroupResidual group arm Y center hgroup harm hY a k).comp (measurable_pi_apply i))).aestronglyMeasurable refine hm.congr ?_ filter_upwards [] with z rfl · filter_upwards [] with z rw [Real.norm_eq_abs, Real.norm_eq_abs, abs_mul] exact mul_le_mul_of_nonneg_right (hweight_bound _ _ _) (abs_nonneg _) have hsum : MemLp (fun z : Fin n → Omega => ∑ k : kappa, ∑ a : Bool, ∑ i : Fin n, weight (sampleDesign group arm z) a k * supportedArmGroupResidual group arm Y center a k (z i)) 2 (Measure.pi (fun _ : Fin n => mu)) := by exact memLp_finsetSum univ fun k _ => memLp_finsetSum univ fun a _ => memLp_finsetSum univ fun i _ => hterm i a k convert hsum using 1 funext z unfold occupancyWeightedResidual dsimp [weight, occupancyResidualWeight] change (if 0 < usableGroupTotal group arm z then (usableGroupTotal group arm z : Real)⁻¹ * ∑ k, if usableGroup group arm z k then (groupCount group arm z k : Real) * (armResidualMean group arm Y center z true k - armResidualMean group arm Y center z false k) else 0 else 0) = ∑ k : kappa, ∑ a : Bool, ∑ i : Fin n, (if 0 < usableGroupTotal group arm z then (usableGroupTotal group arm z : Real)⁻¹ * if usableGroup group arm z k then (groupCount group arm z k : Real) * (if a then (groupArmCount group arm z true k : Real)⁻¹ else -(groupArmCount group arm z false k : Real)⁻¹) else 0 else 0) * supportedArmGroupResidual group arm Y center a k (z i) split_ifs with htotal · rw [Finset.mul_sum] apply Finset.sum_congr rfl intro k hk by_cases huk : usableGroup group arm z k · have hf : 0 < groupArmCount group arm z false k := huk.1 have ht : 0 < groupArmCount group arm z true k := huk.2 simp only [huk, if_pos, Fintype.sum_bool, armResidualMean, armResidualSum, hf, ht] simp only [Bool.false_eq_true, if_false] rw [mul_sub] simp_rw [Finset.mul_sum] ring_nf simp_rw [Finset.mul_sum] rw [Finset.sum_neg_distrib] ring_nf · simp [huk] · simp