All problems
Horvitz Thompson Total
Problem
The Horvitz-Thompson estimator of a population total weights each sampled unit by the reciprocal of its inclusion probability: sum_i y_i / pi_i.
Given the values and their inclusion probabilities, return the estimated total.
Hint
Rarely sampled units carry more weight.
Test cases
case 1
in: [[10,20],[0.5,0.5]]
expected: 60
case 2
in: [[5],[0.1]]
expected: 50
case 3
in: [[2,4,6],[0.25,0.5,1]]
expected: 22
Starter codePython
def horvitz_thompson_total(values, probabilities):
# Your code here
pass3 test cases · run your code against them in the editor