Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-285

IPW Average Treatment Effect

Problem

Return the Horvitz-Thompson inverse probability weighted ATE: (1/n) * (sum(t_i*y_i/e_i) - sum((1-t_i)*y_i/(1-e_i))). Return 0.0 for empty or mismatched input, a treated unit with e <= 0, or a control with e >= 1.

Hint

Each unit stands in for 1/e or 1/(1-e) look-alikes.

Test cases

case 1
in: [[1,1,0,0],[10,12,4,6],[0.5,0.5,0.5,0.5]]
expected: 6
case 2
in: [[1,0],[5,1],[0.5,0.5]]
expected: 4
case 3
in: [[1,0],[5,1],[0,0.5]]
expected: 0
case 4
in: [[1,0],[5,1],[0.5,1]]
expected: 0
case 5
in: [[],[],[]]
expected: 0
Starter codePython
def ipw_ate(treatment, outcome, propensity):
    # Your code here
    pass

5 test cases · run your code against them in the editor