StatsBase.jl icon indicating copy to clipboard operation
StatsBase.jl copied to clipboard

Kendall tau distance

Open frankier opened this issue 1 year ago • 1 comments

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.

frankier avatar Aug 27 '24 11:08 frankier

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

PGS62 avatar Sep 16 '24 14:09 PGS62