Calculate the Manhattan (L1) distance between two vectors.
Manhattan distance (L1 norm) measures the sum of absolute differences along each dimension, like navigating a grid of city blocks. It is more robust to outliers than Euclidean distance and commonly used in high-dimensional sparse feature spaces.
Manhattan Distance
d(a, b) = sum(|a_i - b_i|)
It resembles the distance a taxi would travel on a grid-based street layout (like Manhattan), where you can only move along axes rather than diagonally.
Manhattan distance is preferred when features are on different scales or when the data is sparse and high-dimensional, as it is less affected by large differences in a single dimension.