Topics
Median Minimizes the L1 Norm
Suppose we have a set of real numbers. The L1 norm:
is minimized when is a median of .
Proof
Consider two real numbers . The objective function for this pair is:
This expression is minimized when . To verify, analyze three cases:
- If : The sum becomes , which decreases as increases toward .
- If : The sum simplifies to , a constant.
- If : The sum becomes , which increases as increases.
Thus, the minimum occurs when .
For the general case with elements, sort as . Pair the smallest and largest elements: , , etc. Each pair constrains to lie within their interval. Remove these pairs iteratively:
- If is odd, one element remains, and (the median) minimizes the sum.
- If is even, all elements are paired, and can be any value within the innermost pairβs interval .
Thus, the median (or interval of medians) minimizes the L1 norm.
Mean Minimizes the L2 Norm
For the same set , the L2 norm (squared Euclidean distance):
is minimized when is the mean of .
Proof
Define the objective function:
To find the minimum, compute the derivative with respect to :
Set :
This is the mean of .
To confirm this critical point is a minimum, check the second derivative:
which ensures convexity. Hence, uniquely minimizes the L2 norm.
Warning
If we are asked integer solution only, and mean is say,
7.6
, then we need to round it to the nearest int. Example problem, where we domean = round(sum / n)
.
Comparison
-
Robustness vs. Sensitivity:
- The median minimizes the L1 norm and is robust to outliers
- The mean minimizes the L2 norm but is sensitive to outliers
-
Uniqueness:
- The L1 minimizer (median) may be an interval for even-sized datasets
- The L2 minimizer (mean) is always unique