All problems
Huber Weight
Problem
Return the Huber weight for a residual given a scale estimate: 1.0 when abs(residual) <= c*scale, otherwise c*scale/abs(residual). Return 0.0 when scale <= 0.
Hint
Huber weights downweight large residuals linearly.
Test cases
case 1
in: [1,1,1.345]
expected: 1
case 2
in: [2.69,1,1.345]
expected: 0.5
case 3
in: [0,1,1.345]
expected: 1
case 4
in: [5,0,1.345]
expected: 0
case 5
in: [1.345,1,1.345]
expected: 1
Starter codePython
def huber_weight(residual, scale, c):
# Your code here
pass5 test cases · run your code against them in the editor