Order statistics and medians of finite families #
Defines rank-k order statistics (Fintype.IsOrderStatistic, Fintype.orderStatistic), lower
median x_((n - 1) / 2) (Fintype.lowerMedian), and upper median x_(n / 2)
(Fintype.upperMedian) for finite families x : ι → α, bridging to List.IsOrderStatistic and
proving that any median minimizes ∑ i, |x i - y| over ℝ.
Main definitions #
Fintype.IsOrderStatistic:yis thek-th order statistic (0-indexed) ofx : ι → α.Fintype.orderStatistic: thek-th order statistic ofx : ι → α(clamped at|ι| - 1).Fintype.lowerMedian,Fintype.upperMedian: the lower and upper medians ofx : ι → α.
Main results #
Fintype.IsOrderStatistic.unique,Fintype.orderStatistic_isOrderStatistic,Fintype.orderStatistic_eq_of_isOrderStatistic,Fintype.orderStatistic_fin_eq_mergeSort,Fintype.lt_orderStatistic_iff,Fintype.orderStatistic_comp_equiv: uniqueness, rank and threshold characterizations, merge-sort correspondence, and permutation invariance.Fintype.sum_abs_sub_le_of_median_counts,Fintype.sum_abs_sub_lowerMedian_le,Fintype.sum_abs_sub_upperMedian_le: onℝ, any point with at most|ι| / 2elements strictly on each side (and in particularlowerMedian xandupperMedian x) minimizes∑ i, |x i - y|.
y is the k-th order statistic (0-indexed) of the profile x : ι → α: y lies in the
image of x, at most k indices satisfy x i < y, and strictly more than k satisfy
x i ≤ y.
The k-th order statistic (0-indexed) of x : ι → α, clamped to Fintype.card ι - 1 when
k ≥ Fintype.card ι.
The lower median x_((n - 1) / 2) of a nonempty finite family x.
The upper median x_(n / 2) of a nonempty finite family x.
Threshold characterization of the k-th order statistic: t < orderStatistic x k if and only
if at most k indices satisfy x i ≤ t.
Any point y : ℝ having at most |ι| / 2 points strictly to its left and at most |ι| / 2
points strictly to its right minimizes ∑ i, |x i - y|.