Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-310

Rao-Blackwellized Estimator Variance

Problem

A Rao-Blackwellized estimator averages conditional expectations instead of raw samples, so its variance is (1 / n^2) times the sum over samples of (g[i] - mean)^2, where mean is the average conditional expectation. Return that variance, or 0.0 for an empty list.

Hint

Conditioning on auxiliary variables removes their contribution to the estimator variance.

Test cases

case 1
in: [[1,2,3,4]]
expected: 0.3125
case 2
in: [[2,2,2]]
expected: 0
case 3
in: [[0,1]]
expected: 0.125
case 4
in: [[1]]
expected: 0
case 5
in: [[0,0,1,1]]
expected: 0.0625
Starter codePython
def rao_blackwellized_variance(conditional_means):
    # Your code here
    pass

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