Documentation

CslibFrontier.Probability.MedianTrick

The median trick #

The median trick [Chakrabarti2025, Section 2.4] amplifies the success probability of any estimator: if an estimate misses its target by more than t with probability at most 1 / 3, the median of 2 r independent estimates misses by more than t with probability at most (8 / 9) ^ r.

This holds for any estimate, whatever its distribution; algorithms such as Count-Sketch and KMV distinct elements use it for estimators that are not averages.

Main results #

References #

theorem Cslib.Probability.dens_abs_median_sub_gt_le {Ω : Type u_1} [Fintype Ω] [Nonempty Ω] (g : Ω → ℝ) {μ t : ℝ} (hg : ↑{x : Ω | t < |g x - μ|}.dens ≤ 1 / 3) (r : ℕ) :
↑{ω : Fin (2 * r) → Ω | t < |(median fun (i : Fin (2 * r)) => g (ω i)) - μ|}.dens ≤ (8 / 9) ^ r

The median trick [Chakrabarti2025, Section 2.4]: if the estimate g x misses μ by more than t for at most a third of the samples x, the median of 2 r independent estimates misses μ by more than t for at most an (8 / 9) ^ r fraction of the samples.