secondsmallest
Secondsmallest, often written as the second smallest or as the second order statistic, denotes the second element in the sorted arrangement of a sample or set. In statistics, if X1, X2, ..., Xn are observations, the second smallest value is X_(2) when the sample is ordered nondecreasingly. If the smallest value occurs more than once, X_(2) may equal X_(1).
Many programming problems distinguish between two interpretations: the second smallest value (allowing duplicates) and the second
To compute it, you can sort and take the second element, or use a one-pass method that
Edge cases include when the sample size n < 2, or when all values are equal and no
Example: data [5, 1, 3, 1, 2] yields a second order statistic of 1 (sorted: 1, 1,
Applications appear in descriptive statistics, robust estimators, and algorithms that rely on order statistics. Related concepts