Skip to content
DeepForgeby svx
All problems
EasyOptimizationop-161

Variance Reduction Factor for Gradient Estimators

Problem

Compute the variance reduction factor achieved by an estimator.

Return 1 - var_after / var_before, or 0.0 when var_before is zero. A factor of 1 means the variance was completely eliminated.

Hint

The factor is the fraction of variance removed relative to the baseline.

Test cases

case 1
in: [1,0.25]
expected: 0.75
case 2
in: [4,1]
expected: 0.75
case 3
in: [2,2]
expected: 0
case 4
in: [0,1]
expected: 0
Starter codePython
def variance_reduction_factor(var_before, var_after):
    # Your code here
    pass

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