All problems
Kendall's Tau-b
Problem
Return Kendall's tau-b (P - Q)/sqrt((P+Q+Tx)(P+Q+Ty)) with tie corrections, where Tx counts pairs tied on x only and Ty pairs tied on y only. Return 0.0 when there are fewer than two pairs or the denominator is zero.
Hint
Tau-b adjusts for ties in either variable.
Test cases
case 1
in: [[1,2,3],[1,2,3]]
expected: 1
case 2
in: [[1,2,3],[3,2,1]]
expected: -1
case 3
in: [[1,2,2,3],[1,2,3,4]]
expected: 0.9128709291752769
case 4
in: [[1,1,2],[1,2,2]]
expected: 0.5
case 5
in: [[1],[1]]
expected: 0
Starter codePython
def kendall_tau_b(x, y):
# Your code here
pass5 test cases · run your code against them in the editor