All problems
Winkler Score
Problem
Compute the Winkler interval score for an interval [lower, upper] with significance alpha: the width plus (2/alpha) times the distance outside the interval.
Return the width when y lies inside.
Hint
Narrow intervals are rewarded, but missing the observation is heavily penalized.
Test cases
case 1
in: [0,1,0.5,0.1]
expected: 1
case 2
in: [0,1,-1,0.1]
expected: 21
case 3
in: [0,1,2,0.1]
expected: 21
case 4
in: [0,1,0,0.5]
expected: 1
Starter codePython
def winkler_score(lower, upper, y, alpha):
# Your code here
pass4 test cases · run your code against them in the editor