Distances.jl
Distances.jl copied to clipboard
Minkowski with p<1 not a metric
julia> using Distances
julia> d = Minkowski(0.5);
julia> a=[1.0,0.0]; b=[0.0,1.0]; c=[0.0,0.0];
julia> evaluate(d, a, b) - evaluate(d,a,c) - evaluate(d,c,b)
2.0
julia> d isa Metric
true
This violates the triangle inequality. For p<1 we should probably throw in the constructor, or skip the outer root (then L^p for p<1 can be considered a metric vector space, albeit not locally convex). Skipping the outer root means something like
julia> using Distances
julia> import Distances.evaluate
julia> struct M<:Metric end
julia> evaluate(::M, x, y) = sum(t->sqrt(abs(t)) , x-y)