Expand description
Also known as rectilinear distance, city block distance, taxicab metric.
Manhattan Distance
The Manhattan distance between two points \(x \in ℝ^n \) and \( y \in ℝ^n \) in n-dimensional space is the sum of the distances in each dimension.
\[ d(x, y) = \sum_{i=0}^n \lvert x_i - y_i \rvert \]
Example:
use smartcore::metrics::distance::Distance;
use smartcore::metrics::distance::manhattan::Manhattan;
let x = vec![1., 1.];
let y = vec![2., 2.];
let l1: f64 = Manhattan::new().distance(&x, &y);
Structs
- Manhattan distance