Documentation

CslibFrontier.Probability.MedianOfMeans

The median-of-means estimator #

Given an estimator g : Ω → ℝ of its mean 𝔼 g, with sample x drawn uniformly from a finite type Ω, the median-of-means estimator Cslib.Probability.medianOfMeans g ω draws 2 r groups of k independent samples ω i l, averages each group, and reports the median of the 2 r averages. An average of k samples has k times smaller variance (Cslib.Probability.expect_expect_sub_sq), so by Chebyshev's inequality at most a third of the groups miss 𝔼 g by more than t once the variance of g is at most k t² / 3; the median misses only when at least half of the groups do, which happens for at most an (8 / 9) ^ r fraction of the samples (Cslib.Probability.dens_abs_medianOfMeans_sub_gt_le). This is the amplification step of the frequency moment estimators of Alon, Matias and Szegedy [AlonMatiasSzegedy1999, Theorem 2.2]. Probabilities over the samples are densities Finset.dens.

The last step is the median trick [Chakrabarti2025, Section 2.4] (Cslib.Probability.dens_abs_median_sub_gt_le, in CslibFrontier.Probability.MedianTrick), which holds for any estimate that misses by more than t with probability at most 1 / 3, whatever its distribution; the Count-Sketch uses it for estimates that are not averages.

Main definitions #

Main results #

References #

noncomputable def Cslib.Probability.medianOfMeans {Ω : Type u_1} {r k : ℕ} (g : Ω → ℝ) (ω : Fin (2 * r) → Fin k → Ω) :

The median-of-means estimate from 2 r groups of k samples of g: the median of the 2 r group averages.

Instances For
    theorem Cslib.Probability.expect_expect_sub_sq {Ω : Type u_1} [Fintype Ω] [Nonempty Ω] {k : ℕ} [NeZero k] (g : Ω → ℝ) :
    (Finset.univ.expect fun (ω : Fin k → Ω) => ((Finset.univ.expect fun (l : Fin k) => g (ω l)) - Finset.univ.expect fun (x : Ω) => g x) ^ 2) = (Finset.univ.expect fun (x : Ω) => (g x - Finset.univ.expect fun (y : Ω) => g y) ^ 2) / ↑k

    The average of k independent samples of g has k times smaller variance.

    theorem Cslib.Probability.dens_abs_medianOfMeans_sub_gt_le {Ω : Type u_1} [Fintype Ω] [Nonempty Ω] {r k : ℕ} [NeZero k] (g : Ω → ℝ) {t : ℝ} (ht : 0 < t) (hvar : (3 * Finset.univ.expect fun (x : Ω) => (g x - Finset.univ.expect fun (y : Ω) => g y) ^ 2) ≤ ↑k * t ^ 2) :
    ↑{ω : Fin (2 * r) → Fin k → Ω | t < |medianOfMeans g ω - Finset.univ.expect fun (x : Ω) => g x|}.dens ≤ (8 / 9) ^ r

    Median of means [AlonMatiasSzegedy1999, Theorem 2.2]: if g has variance at most k t² / 3, the median of 2 r averages of k independent samples of g is farther than t from the mean of g for at most an (8 / 9) ^ r fraction of the samples.