All problems
Rank-Biserial Correlation
Problem
Return the rank-biserial correlation 2*(mean_rank_x - mean_rank_y)/(n1+n2), using average ranks for ties in the combined sample. Return 0.0 if either sample is empty.
Hint
It converts a rank comparison into a correlation-scale effect size.
Test cases
case 1
in: [[1,2,3],[4,5,6]]
expected: -1
case 2
in: [[4,5,6],[1,2,3]]
expected: 1
case 3
in: [[1,2,3],[1,2,3]]
expected: 0
case 4
in: [[1,2,3],[2,2,4]]
expected: -0.3333333333333333
case 5
in: [[5],[5]]
expected: 0
Starter codePython
def rank_biserial(x, y):
# Your code here
pass5 test cases · run your code against them in the editor