All problems
Importance Sampling Estimate Mean
Problem
With samples x_i drawn from a proposal q and target density proportional to p, the importance sampling estimate of E_p[f] is mean_i f(x_i) p(x_i) / q(x_i).
Given the f values, the p values, and the q values, return the estimate.
Hint
Each sample is reweighted by the density ratio.
Test cases
case 1
in: [[1,2],[0.5,0.5],[0.25,0.25]]
expected: 3
case 2
in: [[1],[2],[1]]
expected: 2
case 3
in: [[0,4],[0.1,0.2],[0.05,0.1]]
expected: 4
Starter codePython
def importance_sampling_estimate_mean(f_values, p_values, q_values):
# Your code here
pass3 test cases · run your code against them in the editor