Documentation

CslibFrontier.Foundations.Data.Finset.KthLargest.Stability

Full-slice error bounds for padded ranks #

Both ranks use the same finite set. Signed, unbounded values and empty sets are allowed. Division retains its actual positive normalization rate.

theorem Finset.abs_kthLargest_sub_le_kthLargest_one {V : Type u_1} {k : ℕ} (hk : 0 < k) (S : Finset V) (a b : V → ℝ) :
|kthLargest k S a - kthLargest k S b| ≤ kthLargest 1 S fun (x : V) => |a x - b x|

Rank perturbations are bounded by the padded maximum absolute input error.

theorem Finset.abs_kthLargest_div_sub_div_le {V : Type u_1} {k : ℕ} (hk : 0 < k) {r : ℝ} (hr : 0 < r) (S : Finset V) (a b : V → ℝ) :
|(kthLargest k S fun (x : V) => a x / r) - kthLargest k S fun (x : V) => b x / r| ≤ (kthLargest 1 S fun (x : V) => |a x - b x|) / r

Dividing both signed inputs by the same positive rate divides the full-slice error maximum by that rate. No scalar clipping is applied before ranking.

theorem Finset.kthLargest_eq_zero_of_card_lt {V : Type u_1} {R : Type u_2} [LinearOrder R] [Zero R] {k : ℕ} {S : Finset V} (hk : S.card < k) (a : V → R) :
kthLargest k S a = 0

A padded rank above the size of its actual set is zero, including for signed inputs.