Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-394

Mann Whitney U Statistic

Problem

Given the combined ranks of the first sample (ties resolved externally) and its size n1, the Mann-Whitney statistic is U1 = sum(ranks of sample 1) - n1 (n1 + 1) / 2.

Given the rank list and n1, return U1.

Hint

Subtract the minimum possible rank sum from the observed rank sum.

Test cases

case 1
in: [[1,3],2]
expected: 1
case 2
in: [[2,4],2]
expected: 3
case 3
in: [[1,2,3],3]
expected: 0
Starter codePython
def mann_whitney_u_statistic(ranks, n1):
    # Your code here
    pass

3 test cases · run your code against them in the editor