Stat.FiniteRaoBlackwell.PairedPoissonHistogram
This roll-up module exports a parameter-independent count estimator obtained from any estimator of paired fixed samples, the law identity for pairing two independent iid arrays, and the general and twice-sample-size risk
Basic 8 core · 5 supporting This module turns an estimator of paired fixed samples into an estimator of two count histograms. ★ pairedPoissonHistogramEstimator_of_totals_ge
Finite histogram fibres and paired conditional averages
This module turns an estimator of paired fixed samples into an estimator of two count histograms. The construction averages the two histogram fibres independently, then pairs the retained prefixes coordinatewise.
Given a finite ordered sample and an alphabet symbol, its finite-sample histogram count is the number of sample positions equal to that symbol.
Definition (Lean source)
Given a finite count histogram, its histogram total is the sum of the counts over the alphabet.
Definition (Lean source)
Given a finite count histogram, its histogram fibre is the set of ordered arrays whose length is the histogram total and whose histogram equals the given one.
Definition (Lean source)
Given a certificate that the requested length does not exceed the histogram total and a compatible ordering, the retained histogram prefix consists of the ordering's first requested entries.
Definition (Lean source)
Given one retained array and another retained array, their coordinatewise pairing places the entries with each common index into a pair.
Given a paired-sample estimator, two finite count histograms, and certificates that both totals contain the requested sample length, the paired conditional histogram average independently averages the estimator over all compatible orderings, after retaining and coordinatewise pairing the two prefixes.
Definition (Lean source)
Given a paired-sample estimator, a fallback value, and two finite count histograms, the paired Poisson-histogram estimator uses the independent compatible-ordering average when both totals are large enough and returns the fallback when either total is too small.
Definition (Lean source)
Given a paired-sample estimator, a fallback value, two finite count histograms, and certificates that both totals contain the requested sample length, the paired count estimator equals the independent compatible-ordering average.
Formal statement
Proof (Lean source)
5 supporting declarations (lemmas, instances)
-
histogramTotal_finiteSampleHistogramtheorem — The histogram of a finite ordered sample has total equal to the sample size.hypothesesconclusionhistogramTotal (finiteSampleHistogram x) = mProof (Lean source)
theorem histogramTotal_finiteSampleHistogram {m : ℕ} {X : Type*} [Fintype X] [DecidableEq X] (x : Fin m → X) : histogramTotal (finiteSampleHistogram x) = m := by classical unfold histogramTotal finiteSampleHistogram simp_rw [Fintype.card_subtype] rw [← Finset.card_eq_sum_card_fiberwise (s := univ) (t := univ) (f := x) (by simp)] simp -
histogramFiberFintypeinstance — Given a finite count histogram, its histogram fibre has a finite enumeration. -
histogramFiber_nonemptytheorem — Every finite count histogram has at least one compatible ordering.Proof (Lean source)
theorem histogramFiber_nonempty {X : Type*} [Fintype X] [DecidableEq X] (c : X → ℕ) : Nonempty (HistogramFiber c) := by classical let S := Σ a : X, Fin (c a) have hcard : card S = histogramTotal c := by simp [S, histogramTotal] let e : Fin (histogramTotal c) ≃ S := (Fintype.equivFinOfCardEq hcard).symm let x : Fin (histogramTotal c) → X := fun i => (e i).1 refine ⟨⟨x, ?_⟩⟩ funext a unfold finiteSampleHistogram change card {i : Fin (histogramTotal c) // (e i).1 = a} = c a calc _ = card {s : S // s.1 = a} := Fintype.card_congr (Equiv.subtypeEquivOfSubtype e) _ = card (Σ b : {b : X // b = a}, Fin (c b.1)) := Fintype.card_congr (Equiv.subtypeSigmaEquiv (fun b : X => Fin (c b)) (fun b => b = a)) _ = c a := by rw [Fintype.card_sigma] simp only [Fintype.card_fin] simpa using Fintype.sum_subsingleton (fun b : {b : X // b = a} => c b.1) ⟨a, rfl⟩ -
pairedPoissonHistogramEstimator_of_total_lttheorem — Given a paired-sample estimator, a fallback value, two finite count histograms, and a certificate that at least one total is too small, the paired count estimator equals its fallback.hypothesesn :ℕX Y :est :(Fin n → X × Y) → ℝfallback :ℝcX :X → ℕcY :Y → ℕhfail :histogramTotal cX < n ∨ histogramTotal cY < nconclusionpairedPoissonHistogramEstimator est fallback (cX, cY) = fallbackProof (Lean source)
theorem pairedPoissonHistogramEstimator_of_total_lt {n : ℕ} {X Y : Type*} [Fintype X] [DecidableEq X] [Fintype Y] [DecidableEq Y] (est : (Fin n → X × Y) → ℝ) (fallback : ℝ) (cX : X → ℕ) (cY : Y → ℕ) (hfail : histogramTotal cX < n ∨ histogramTotal cY < n) : pairedPoissonHistogramEstimator est fallback (cX, cY) = fallback := by rcases hfail with hX | hY · simp [pairedPoissonHistogramEstimator, Nat.not_le_of_lt hX] · by_cases hX : n ≤ histogramTotal cX · simp [pairedPoissonHistogramEstimator, hX, Nat.not_le_of_lt hY] · simp [pairedPoissonHistogramEstimator, hX] -
measurable_pairedPoissonHistogramEstimatortheorem — Given a paired-sample estimator and a fallback value, the resulting paired count estimator is measurable on finite measurable alphabets with measurable singletons.hypothesesconclusionMeasurable (pairedPoissonHistogramEstimator est fallback)Proof (Lean source)
@[fun_prop] theorem measurable_pairedPoissonHistogramEstimator {n : ℕ} {X Y : Type*} [Fintype X] [MeasurableSpace X] [MeasurableSingletonClass X] [DecidableEq X] [Fintype Y] [MeasurableSpace Y] [MeasurableSingletonClass Y] [DecidableEq Y] (est : (Fin n → X × Y) → ℝ) (fallback : ℝ) : Measurable (pairedPoissonHistogramEstimator est fallback) := by exact measurable_of_countable _
FixedRisk 1 core · 1 supporting This module proves the finite Jensen inequality for independent histogram fibres and its integrated squared-risk consequence for two independent samples whose fixed totals may differ. ★ pairedHistogramAverage_productRisk_le
Fixed-total risk contraction for two histogram fibres
This module proves the finite Jensen inequality for independent histogram fibres and its integrated squared-risk consequence for two independent samples whose fixed totals may differ.
Given two finite-alphabet probability laws, a paired-sample estimator, a real target, and certificates that both fixed totals contain the requested sample length, independent histogram averaging followed by coordinatewise pairing has no greater squared risk than the paired iid experiment.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
pairedHistogramAverage_sq_sub_letheorem — Given a paired-sample estimator, a real target, two finite count histograms, and certificates that both totals contain the requested sample length, the squared loss of the independent two-fibre average is at most the uniform average squared loss over both ordering fibres.hypothesesn :ℕX Y :est :(Fin n → X × Y) → ℝtheta :ℝcX :X → ℕcY :Y → ℕhX :n ≤ histogramTotal cXhY :n ≤ histogramTotal cYconclusion(pairedHistogramAverage est cX cY hX hY - theta) ^ 2≤ (∑ x : HistogramFiber cX, ∑ y : HistogramFiber cY, (est (pairRetainedArrays (retainedHistogramPrefix hX x) (retainedHistogramPrefix hY y)) - theta) ^ 2) / (card (HistogramFiber cX) * card (HistogramFiber cY))Proof (Lean source)
theorem pairedHistogramAverage_sq_sub_le {n : ℕ} {X Y : Type*} [Fintype X] [DecidableEq X] [Fintype Y] [DecidableEq Y] (est : (Fin n → X × Y) → ℝ) (theta : ℝ) (cX : X → ℕ) (cY : Y → ℕ) (hX : n ≤ histogramTotal cX) (hY : n ≤ histogramTotal cY) : (pairedHistogramAverage est cX cY hX hY - theta) ^ 2 ≤ (∑ x : HistogramFiber cX, ∑ y : HistogramFiber cY, (est (pairRetainedArrays (retainedHistogramPrefix hX x) (retainedHistogramPrefix hY y)) - theta) ^ 2) / (card (HistogramFiber cX) * card (HistogramFiber cY)) := by classical letI : Nonempty (HistogramFiber cX) := histogramFiber_nonempty cX letI : Nonempty (HistogramFiber cY) := histogramFiber_nonempty cY have hcard : ((card (HistogramFiber cX) * card (HistogramFiber cY) : ℕ) : ℝ) ≠ 0 := by positivity rw [pairedHistogramAverage] have hrewrite : (∑ x : HistogramFiber cX, ∑ y : HistogramFiber cY, est (pairRetainedArrays (retainedHistogramPrefix hX x) (retainedHistogramPrefix hY y))) / (card (HistogramFiber cX) * card (HistogramFiber cY)) - theta = (∑ z : HistogramFiber cX × HistogramFiber cY, (est (pairRetainedArrays (retainedHistogramPrefix hX z.1) (retainedHistogramPrefix hY z.2)) - theta)) / card (HistogramFiber cX × HistogramFiber cY) := by rw [Fintype.sum_prod_type, Fintype.card_prod] simp only [fst, snd] simp_rw [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] simp only [Nat.cast_mul] field_simp [hcard] rw [hrewrite] simpa [Fintype.sum_prod_type, Fintype.card_prod] using (sum_div_card_sq_le_sum_sq_div_card (s := univ) (f := fun z : HistogramFiber cX × HistogramFiber cY => est (pairRetainedArrays (retainedHistogramPrefix hX z.1) (retainedHistogramPrefix hY z.2)) - theta))
PairingLaw 1 core · 1 supporting This module gives the measurable coordinatewise-pairing map and its exact law. ★ map_pairRetainedArrays_prod_pi
Regrouping two independent iid arrays into iid pairs
This module gives the measurable coordinatewise-pairing map and its exact law. It identifies two independent finite iid arrays with one iid array from the product law.
Given one probability law and a second probability law, coordinatewise pairing sends two independent iid arrays to an iid array from the product law.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
measurable_pairRetainedArraystheorem — Pairing two finite arrays coordinatewise is measurable.hypothesesn :ℕX Y :conclusionProof (Lean source)
@[fun_prop] theorem measurable_pairRetainedArrays {n : ℕ} {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] : Measurable (fun z : (Fin n → X) × (Fin n → Y) => pairRetainedArrays z.1 z.2) := by let e := (MeasurableEquiv.arrowProdEquivProdArrow X Y (Fin n)).symm have hfun : (fun z : (Fin n → X) × (Fin n → Y) => pairRetainedArrays z.1 z.2) = e := by funext z i rfl rw [hfun] exact e.measurable
Risk 2 core · 4 supporting This module defines the histogram law of a finite Poisson sample, proves the squared-risk transfer for two independent histogram laws with an explicit fallback penalty, and specializes both means to twice the fixed sampl ★ pairedPoissonHistogramRisk_le_fixedRisk_add_tails
Paired Poisson-histogram Rao--Blackwell risk transfer
This module defines the histogram law of a finite Poisson sample, proves the squared-risk transfer for two independent histogram laws with an explicit fallback penalty, and specializes both means to twice the fixed sample size.
Given a finite-alphabet probability law and a Poisson intensity, the count-histogram law is the distribution of the unordered histogram of a finite Poisson sample.
Definition (Lean source)
Given two finite-alphabet probability laws, their Poisson intensities, a paired fixed-sample estimator, a fallback value, and a real target, the paired histogram estimator has integrable squared loss and risk at most the paired fixed-sample risk plus the fallback loss times the sum of the two marginal lower-tail probabilities.
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
measurable_finiteSampleHistogramtheorem — The map from a finite sample to its histogram is measurable over a finite alphabet with measurable singletons.hypothesesX :conclusionProof (Lean source)
@[fun_prop] theorem measurable_finiteSampleHistogram {X : Type*} [Fintype X] [MeasurableSpace X] [MeasurableSingletonClass X] [DecidableEq X] : Measurable (fun s : FiniteSample X => finiteSampleHistogram s.points) := by -- `FiniteSample X` is countable for finite `X`; use the discrete/countable -- measurability instance rather than unfolding the dependent sample type. apply measurable_to_countable' intro c rw [MeasurableSpace.measurableSet_iInf] intro m change MeasurableSet ((Sigma.mk m) ⁻¹' {s : FiniteSample X | finiteSampleHistogram s.points = c}) exact (Set.to_countable _).measurableSet -
countLaw_map_histogramTotaltheorem — Given a finite-alphabet probability law and a Poisson intensity, the total count under the histogram law has the scalar Poisson distribution with that intensity.hypothesesX :P :lam :ℝ≥0conclusionProof (Lean source)
theorem countLaw_map_histogramTotal {X : Type*} [Fintype X] [MeasurableSpace X] [MeasurableSingletonClass X] [DecidableEq X] (P : Measure X) [IsProbabilityMeasure P] (lam : ℝ≥0) : Measure.map histogramTotal (countLaw P lam) = poissonMeasure lam := by -- Compose the two pushforwards with `Measure.map_map`, identify their -- composite pointwise by `histogramTotal_finiteSampleHistogram`, and finish -- with `finitePoissonSampleLaw_map_count`. unfold countLaw rw [Measure.map_map (measurable_of_countable histogramTotal) measurable_finiteSampleHistogram] have hcomp : histogramTotal ∘ (fun s : FiniteSample X => finiteSampleHistogram s.points) = FiniteSample.count := by funext s exact histogramTotal_finiteSampleHistogram s.points rw [hcomp] exact finitePoissonSampleLaw_map_count P lam -
pairedPoissonHistogramRisk_two_n_letheorem — Given two finite-alphabet probability laws, a paired fixed-sample estimator, a real target, a target-magnitude bound, and a certificate of that bound, using zero fallback and Poisson means twice the sample size gives a risk penalty no larger than twice the squared bound times the common Poisson lower-tail probability.hypothesesconclusion(∫ c, (pairedPoissonHistogramEstimator est 0 c - theta) ^ 2 ∂((countLaw P (2 * n)).prod (countLaw Q (2 * n))))≤ (∫ z, (est z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => P.prod Q))+ B ^ 2 * (poissonMeasure (2 * n)).real {k | k < n} * 2Proof (Lean source)
theorem pairedPoissonHistogramRisk_two_n_le {n : ℕ} {X Y : Type*} [Fintype X] [MeasurableSpace X] [MeasurableSingletonClass X] [DecidableEq X] [Fintype Y] [MeasurableSpace Y] [MeasurableSingletonClass Y] [DecidableEq Y] (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (est : (Fin n → X × Y) → ℝ) (theta B : ℝ) (htheta : |theta| ≤ B) : (∫ c, (pairedPoissonHistogramEstimator est 0 c - theta) ^ 2 ∂((countLaw P (2 * n)).prod (countLaw Q (2 * n)))) ≤ (∫ z, (est z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => P.prod Q)) + B ^ 2 * (poissonMeasure (2 * n)).real {k | k < n} * 2 := by -- Specialize the central theorem at equal rates and fallback zero, rewrite -- the duplicated tail sum, and use `sq_le_sq₀ (abs_nonneg theta) htheta` -- (or the equivalent `theta ^ 2 ≤ B ^ 2`) before multiplying by the -- nonnegative tail probability. have htransfer := (pairedPoissonHistogramRisk_le_fixedRisk_add_tails P Q (2 * n) (2 * n) est 0 theta).2 have hB_nonneg : 0 ≤ B := (abs_nonneg theta).trans htheta have htheta_sq : theta ^ 2 ≤ B ^ 2 := by rw [← sq_abs theta] exact (sq_le_sq₀ (abs_nonneg theta) hB_nonneg).2 htheta have htail_nonneg : 0 ≤ (poissonMeasure (2 * n)).real {k | k < n} := measureReal_nonneg calc (∫ c, (pairedPoissonHistogramEstimator est 0 c - theta) ^ 2 ∂((countLaw P (2 * n)).prod (countLaw Q (2 * n)))) ≤ (∫ z, (est z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => P.prod Q)) + (0 - theta) ^ 2 * ((poissonMeasure (2 * n)).real {k | k < n} + (poissonMeasure (2 * n)).real {k | k < n}) := htransfer _ = (∫ z, (est z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => P.prod Q)) + theta ^ 2 * (poissonMeasure (2 * n)).real {k | k < n} * 2 := by ring _ ≤ (∫ z, (est z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => P.prod Q)) + B ^ 2 * (poissonMeasure (2 * n)).real {k | k < n} * 2 := by apply add_le_add_right exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right htheta_sq htail_nonneg) (by norm_num) -
pairedPoissonHistogramRisk_two_n_exp_letheorem — Given two finite-alphabet probability laws, a paired fixed-sample estimator, a real target, a target-magnitude bound, and a certificate of that bound, using zero fallback and Poisson means twice the sample size gives the explicit exponential risk penalty supplied by the Poisson lower-tail inequality.hypothesesProof (Lean source)
theorem pairedPoissonHistogramRisk_two_n_exp_le {n : ℕ} {X Y : Type*} [Fintype X] [MeasurableSpace X] [MeasurableSingletonClass X] [DecidableEq X] [Fintype Y] [MeasurableSpace Y] [MeasurableSingletonClass Y] [DecidableEq Y] (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (est : (Fin n → X × Y) → ℝ) (theta B : ℝ) (htheta : |theta| ≤ B) : (∫ c, (pairedPoissonHistogramEstimator est 0 c - theta) ^ 2 ∂((countLaw P (2 * n)).prod (countLaw Q (2 * n)))) ≤ (∫ z, (est z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => P.prod Q)) + B ^ 2 * exp (-(n : ℝ) * (1 - log 2)) * 2 := by -- Chain `pairedPoissonHistogramRisk_two_n_le` with -- `poisson_two_n_lower_tail`; convert the ENNReal bound to `Measure.real` -- using `ENNReal.toReal_mono` and positivity of the exponential term. have htailENN := poisson_two_n_lower_tail n have htail : (poissonMeasure (2 * n)).real {k | k < n} ≤ exp (-(n : ℝ) * (1 - log 2)) := by rw [measureReal_def] calc ((poissonMeasure (2 * n)) {k | k < n}).toReal ≤ (ofReal (exp (-(n : ℝ) * (1 - log 2)))).toReal := ENNReal.toReal_mono ENNReal.ofReal_ne_top htailENN _ = exp (-(n : ℝ) * (1 - log 2)) := ENNReal.toReal_ofReal (Real.exp_pos _).le calc (∫ c, (pairedPoissonHistogramEstimator est 0 c - theta) ^ 2 ∂((countLaw P (2 * n)).prod (countLaw Q (2 * n)))) ≤ (∫ z, (est z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => P.prod Q)) + B ^ 2 * (poissonMeasure (2 * n)).real {k | k < n} * 2 := pairedPoissonHistogramRisk_two_n_le P Q est theta B htheta _ ≤ (∫ z, (est z - theta) ^ 2 ∂Measure.pi (fun _ : Fin n => P.prod Q)) + B ^ 2 * exp (-(n : ℝ) * (1 - log 2)) * 2 := by apply add_le_add_right exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left htail (sq_nonneg B)) (by norm_num)