Kendall tau distance

The Kendall tau rank distance is a metric that counts the number of pairwise disagreements between two ranking lists. The larger the distance, the more dissimilar the two lists are. Kendall tau distance is also called bubble-sort distance since it is equivalent to the number of swaps that the bubble sort algorithm would take to place one list in the same order as the other list. The Kendall tau distance was created by Maurice Kendall.

Definition

The Kendall tau ranking distance between two lists and is

where

  • and are the rankings of the element in and respectively.

will be equal to 0 if the two lists are identical and (where is the list size) if one list is the reverse of the other. Often Kendall tau distance is normalized by dividing by so a value of 1 indicates maximum disagreement. The normalized Kendall tau distance therefore lies in the interval [0,1].

Kendall tau distance may also be defined as

where

  • P is the set of unordered pairs of distinct elements in and
  • = 0 if i and j are in the same order in and
  • = 1 if i and j are in the opposite order in and

Kendall tau distance can also be defined as the total number of discordant pairs.

Kendall tau distance in Rankings: A permutation (or ranking) is an array of N integers where each of the integers between 0 and N-1 appears exactly once. The Kendall tau distance between two rankings is the number of pairs that are in different order in the two rankings. For example, the Kendall tau distance between 0 3 1 6 2 5 4 and 1 0 3 6 4 2 5 is four because the pairs 0-1, 3-1, 2-4, 5-4 are in different order in the two rankings, but all other pairs are in the same order.[1]

If Kendall tau function is performed as instead of (where and are the rankings of and elements respectively), then triangular inequality is not guaranteed. The triangular inequality fails in cases where there are repetitions in the lists. So then we are not dealing with a metric anymore.

Example

Suppose one ranks a group of five people by height and by weight:

PersonABCDE
Rank by height 12345
Rank by weight 34125

Here person A is tallest and third-heaviest, and so on.

In order to calculate the Kendall tau distance, pair each person with every other person and count the number of times the values in list 1 are in the opposite order of the values in list 2.

PairHeightWeightCount
(A,B) 1 < 23 < 4
(A,C) 1 < 33 > 1X
(A,D) 1 < 43 > 2X
(A,E) 1 < 53 < 5
(B,C) 2 < 34 > 1X
(B,D) 2 < 44 > 2X
(B,E) 2 < 54 < 5
(C,D) 3 < 41 < 2
(C,E) 3 < 51 < 5
(D,E) 4 < 52 < 5

Since there are four pairs whose values are in opposite order, the Kendall tau distance is 4. The normalized Kendall tau distance is

A value of 0.4 indicates that 40% of pairs differ in ordering between the two lists.

Computing the Kendall tau distance

Given two rankings , it is possible to rename the items such that . Then, the problem of computing the Kendall tau distance reduces to computing the number of inversions in --- the number of index pairs such that while . There are several algorithms for calculating this number.

  • A simple algorithm based on merge sort requires time .[2]
  • A more advanced algorithm requires time .[3]

See also

References

  1. http://algs4.cs.princeton.edu/25applications/
  2. Ionescu, Vlad. "calculating the number of "inversions" in a permutation". Stack overflow. Retrieved 24 February 2017.
  3. Chan, Timothy M.; Pătraşcu, Mihai (2010). "Counting Inversions, Offline Orthogonal Range Counting, and Related Problems". Proceedings of the Twenty-First Annual ACM-SIAM Symposium on Discrete Algorithms. p. 161. CiteSeerX 10.1.1.208.2715. doi:10.1137/1.9781611973075.15. ISBN 978-0-89871-701-3.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.