All problems
Overlap Fraction
Problem
Compute the fraction of propensity scores inside the overlap region [lower, upper] (inclusive).
Empty input returns 0.0.
Hint
Only units in the overlap region support causal comparisons.
Test cases
case 1
in: [[0.05,0.5,0.95,0.2],0.1,0.9]
expected: 0.5
case 2
in: [[0.2,0.3,0.4],0.1,0.9]
expected: 1
case 3
in: [[0.05],0.1,0.9]
expected: 0
case 4
in: [[],0.1,0.9]
expected: 0
Starter codePython
def overlap_fraction(propensities, lower, upper):
# Your code here
pass4 test cases · run your code against them in the editor