Explain median vs mean for L1/L2
SnapchatSoftware Engineer · Technical ScreenLast updated
This question evaluates understanding of central tendency and loss functions—specifically the roles of median and mean under L1 (absolute) and L2 (squared) norms—and the geometric extension of these concepts to two-dimensional data.
Explain, with intuition and a brief derivation, why the median minimizes the sum of absolute deviations (L
- while the mean minimizes the sum of squared deviations (L 2). How does this extend to selecting an optimal point in two dimensions under Manhattan versus Euclidean distance, and when is the average a poor choice due to outliers?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.