All problems
Tukey Bisquare Weight
Problem
Compute the Tukey bisquare robust weight.
Return 0.0 when abs(residual) >= c or c is not positive; otherwise return (1 - (residual / c) ** 2) ** 2. The weight decreases smoothly to 0 at the cutoff c.
Hint
The weight reaches zero exactly at the cutoff.
Test cases
case 1
in: [0.5,4]
expected: 0.968994140625
case 2
in: [0,4]
expected: 1
case 3
in: [4,4]
expected: 0
case 4
in: [-2,4]
expected: 0.5625
Starter codePython
def tukey_bisquare_weight(residual, c):
# Your code here
pass4 test cases · run your code against them in the editor