The Minkowski distance between two vectors is d_p(x, y) = (sum_i |x_i - y_i|^p)^(1/p). The exponent p sets the geometry: p = 1 is Manhattan, p = 2 is Euclidean, and p = infinity is the largest coordinate difference.
Implement minkowski(x, y, p).
x and y are 1-D float arrays of the same length. p is a real number with p >= 1, or float('inf').x and y must be 1-D and the same length. Otherwise raise ValueError.p < 1 raises ValueError. Values below 1 do not satisfy the triangle inequality.For p = inf, the limit of the formula is the maximum of the absolute differences.
No results yet
Run your code to check it against the examples, or submit to run every test.