Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-099

Ratio Estimator

Problem

Return the ratio estimator population_total_x * sum(y) / sum(x). Return 0.0 when either list is empty or sum(x) is zero.

Hint

Scale the known population total of x by the observed y-to-x ratio.

Test cases

case 1
in: [[2,4,6],[1,2,3],100]
expected: 200
case 2
in: [[1,2],[1,1],10]
expected: 15
case 3
in: [[1],[0],5]
expected: 0
case 4
in: [[],[1],10]
expected: 0
case 5
in: [[5,5],[2,3],10]
expected: 20
Starter codePython
def ratio_estimator(y, x, population_total_x):
    # Your code here
    pass

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