All problems
Score-Function Estimator
Problem
For a Gaussian distribution N(mu, sigma^2), the score function is (z - mu) / sigma^2, so the score-function (REINFORCE) estimator of d/dmu E[f(z)] is the sample average of f(z_i) * (z_i - mu) / sigma^2.
Given the function values f_values and the corresponding samples z_values, return that estimate.
Hint
The score-function estimator needs only function evaluations, not derivatives of f.
Test cases
case 1
in: [[1,1],[0,2],1,1]
expected: 0
case 2
in: [[2,4],[1,3],1,2]
expected: 1
case 3
in: [[1,2,3],[0,1,2],1,1]
expected: 0.6666666666666666
Starter codePython
def score_function_estimator(f_values, z_values, mu, sigma):
# Your code here
pass3 test cases · run your code against them in the editor