[−][src]Module smartcore::math::distance::manhattan
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::math::distance::Distance; use smartcore::math::distance::manhattan::Manhattan; let x = vec![1., 1.]; let y = vec![2., 2.]; let l1: f64 = Manhattan {}.distance(&x, &y);
Structs
Manhattan | Manhattan distance |