Equal totals can hide different baskets
![Illustrative vectors [3,0] and [0,3] both total 3, yet their Manhattan distance is 6. Equal totals do not imply equal profiles.](/images/computational-thinking/week-7/totals-not-distance.png)
Abhinav totals 14 rows and Srivatsan totals 21. The absolute difference of totals is 7, but their five-category Manhattan distance is 13. Taking only |21−14| allows gains and losses in different categories to cancel. Compute absolute gaps first, then add them.
An alternative mentioned in the discussion is Euclidean distance: square each category gap, add the squares, then take the square root. For Abhinav versus Akshaya this is √(25+4)=√29≈5.3852, while Manhattan distance is 7. The lab labels Euclidean distance as an extension. Do not compare thresholds across different definitions as though their units were identical.
A category can be given a larger weight if the question calls for it, but that is a new declared distance rule. Coarse categories, raw row counts and the observed time period all affect what “similar” means.
Try it yourself
Why is |sum(A)−sum(B)| not the lecture’s distance?
Show explained answer
It combines columns before taking an absolute value, allowing category differences to cancel.
Try it yourself
For [3,0] and [0,3], what are total difference and Manhattan distance?
Show explained answer
The total difference is 0. The Manhattan distance is |3−0|+|0−3|=6.
Try it yourself
Must Euclidean and Manhattan distances be numerically equal?
Show explained answer
No. They are different definitions. State the chosen one before ranking or thresholding pairs.
