Median
The value splitting a sorted sample into two equal parts.
- Also known as — 50th percentile, second quartile (Q2)
- Asymptotic — value where
- Complexity —
- Domain — any real numbers
- Unit — same as measurements
Notation
- order statistics (sorted sample)
Properties
- Shift equivariance
- Scale equivariance
Example
Median([1, 2, 3, 4, 5]) = 3Median([1, 2, 3, 4]) = 2.5
provides maximum protection against outliers and corrupted data. It achieves a 50% breakdown point, meaning that up to half of the data can be arbitrarily bad before the estimate becomes meaningless. However, this extreme robustness comes at a cost: the median is less precise than when data is clean. For most practical applications, offers a better tradeoff (29% breakdown with 95% efficiency). Reserve for situations with suspected contamination levels above 29% or when the strongest possible robustness guarantee is needed.
Algorithm
The algorithm sorts the sample and selects the middle element:
-
Sort Arrange the sample to obtain .
-
Select If is odd, return . If is even, return .
The time complexity is dominated by the sort. This standard algorithm is used as a building block by other estimators; no specialized implementation is needed beyond the languages built-in sort.
Tests
No reference test data exists for yet. The tests/median/ directory has not been created. Test cases will be added when the test generator is implemented.