All problems
Positivity Violation Indices
Problem
Return the sorted indices of propensity scores violating positivity: e < eps or e > 1 - eps.
Empty input returns [].
Hint
Near 0 or 1 propensities make inverse weighting explode.
Test cases
case 1
in: [[0.01,0.5,0.99,0.05],0.05]
expected: [0,2]
case 2
in: [[0.1,0.9],0.05]
expected: []
case 3
in: [[0.5,0.5],0.5]
expected: []
case 4
in: [[],0.05]
expected: []
Starter codePython
def positivity_violations(propensities, eps):
# Your code here
pass4 test cases · run your code against them in the editor