Documentation

CslibFrontier.Foundations.Data.Finset.Median

The median of a finite family of reals #

Cslib.median v is the lower median of a finite family v : ι → ℝ: the least value v i that is weakly above at least half of the family (and 0 for an empty family). It is characterized by majorities: if more than half of the family lies weakly below b, so does the median (Cslib.median_le), and if more than half lies weakly above a, so does the median (Cslib.le_median). Hence a majority within t of μ forces the median within t of μ (Cslib.abs_median_sub_le), the step that turns estimates that are good with probability above a half into one that is good with high probability [AlonMatiasSzegedy1999, Theorem 2.2].

Finset.exists_median (CslibFrontier.Foundations.Data.Finset.Quantile) only asserts that a median element exists; Cslib.median is a chosen value, so it can appear in an algorithm's output. It is unrelated to Cslib.BitString.median, the coordinatewise majority of three bit strings; under open Cslib.BitString write Cslib.median explicitly.

Main definitions #

Main results #

References #

noncomputable def Cslib.median {ι : Type u_1} [Fintype ι] (v : ι → ℝ) :

The lower median of a finite family of reals: the least value v i with at least half of the family weakly below it (zero for an empty family).

Instances For
    theorem Cslib.median_le {ι : Type u_1} [Fintype ι] {v : ι → ℝ} {b : ℝ} (hb : Fintype.card ι < 2 * {j : ι | v j ≤ b}.card) :

    If more than half of the family lies weakly below b, so does the median.

    theorem Cslib.le_median {ι : Type u_1} [Fintype ι] {v : ι → ℝ} {a : ℝ} (ha : Fintype.card ι < 2 * {j : ι | a ≤ v j}.card) :

    If more than half of the family lies weakly above a, so does the median.

    theorem Cslib.abs_median_sub_le {ι : Type u_1} [Fintype ι] {v : ι → ℝ} {μ t : ℝ} (hv : Fintype.card ι < 2 * {j : ι | |v j - μ| ≤ t}.card) :
    |median v - μ| ≤ t

    The median of a majority: if more than half of the family lies within t of μ, so does the median.

    @[simp]
    theorem Cslib.median_const {ι : Type u_1} [Fintype ι] [Nonempty ι] (c : ℝ) :
    (median fun (x : ι) => c) = c

    The median of a nonempty constant family is the constant.