All problems
Control Variate Step
Problem
Take one gradient step with a control variate.
Form the unbiased estimate est = grad_sample - grad_control + grad_control_mean, then return [w - lr * est, est]. The control variate reduces variance when grad_control tracks grad_sample.
Hint
The control variate is mean-zero, so the estimator stays unbiased.
Test cases
case 1
in: [[1,2],[0.5,0.5],[0.4,0.6],[0.45,0.55],0.1]
expected: [[0.945,1.955],[0.55,0.45000000000000007]]
case 2
in: [[0,0],[1,-1],[0.5,-0.5],[0.25,-0.25],0.5]
expected: [[-0.375,0.375],[0.75,-0.75]]
case 3
in: [[2,-1],[1,0.5],[0.5,1],[0.25,0.5],0.2]
expected: [[1.85,-1],[0.75,0]]
Starter codePython
def control_variate_step(w, grad_sample, grad_control, grad_control_mean, lr):
# Returns [w_new, est]
# Your code here
pass3 test cases · run your code against them in the editor