Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-292

CUPED Adjusted Difference

Problem

Return the CUPED-adjusted difference in means: estimate theta = cov(covariate, outcome)/var(covariate), replace each outcome with y - theta*(x - mean_x), then return the treated mean minus the control mean of the adjusted outcomes. Return 0.0 for empty or mismatched input or an empty arm; theta is 0 when the covariate has no variance.

Hint

Center the covariate before using it to adjust the outcomes.

Test cases

case 1
in: [[1,0,1,0],[12,5,10,7],[10,4,8,6]]
expected: 0.20000000000000284
case 2
in: [[1,0],[5,5],[1,1]]
expected: 0
case 3
in: [[1,0],[10,2],[2,0]]
expected: 0
case 4
in: [[1],[3],[7]]
expected: 0
case 5
in: [[],[],[]]
expected: 0
Starter codePython
def cuped_adjusted_diff(treatment, outcome, covariate):
    # Your code here
    pass

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