StatsBase.jl
StatsBase.jl copied to clipboard
Kendall tau distance
It would be nice to export a function for the Kendall tau distance/bubble-sort distance as well as the Kendall tau correlation. In some situations it has a clearer interpretation.
https://en.wikipedia.org/wiki/Kendall_tau_distance
I believe it is already calculated as an intermediate result by the Kendall tau correlation code.
A simple solution would be:
using StatsBase
function kendall_distance(x, y=x)
n = first(size(x))
return (1 .- corkendall(x, y)) .* (n * (n - 1) / 4)
end