All problems
Judge Position Bias Rate
Problem
Given outcomes where 1 means the response shown first was selected and 0 means the second was selected, return the position bias (first_rate - second_rate) = (2 * first - n) / n. Return 0.0 for an empty list.
Test cases
case 1
in: [[1,1,0,1]]
expected: 0.5
case 2
in: [[1,0]]
expected: 0
case 3
in: [[]]
expected: 0
case 4
in: [[1,1,1,1]]
expected: 1
Starter codePython
def position_bias_rate(outcomes):
# Your code here
pass4 test cases · run your code against them in the editor