All problems
Propensity Overlap Fraction
Problem
Return the fraction of propensity scores that fall inside [lower, upper] inclusive, a positivity check. Return 0.0 for empty input or when lower is greater than upper.
Hint
Count scores in the interval, then divide by the sample size.
Test cases
case 1
in: [[0.1,0.2,0.9,0.5],0.05,0.95]
expected: 1
case 2
in: [[0.01,0.2,0.99],0.05,0.95]
expected: 0.3333333333333333
case 3
in: [[],0.05,0.95]
expected: 0
case 4
in: [[0.5],0.6,0.4]
expected: 0
case 5
in: [[0,1],0,1]
expected: 1
Starter codePython
def overlap_fraction(propensity, lower, upper):
# Your code here
pass5 test cases · run your code against them in the editor