Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kendall tau distance #937

Open
frankier opened this issue Aug 27, 2024 · 1 comment
Open

Kendall tau distance #937

frankier opened this issue Aug 27, 2024 · 1 comment

Comments

@frankier
Copy link

frankier commented Aug 27, 2024

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.

@PGS62
Copy link
Contributor

PGS62 commented Sep 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants