Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-380

Tower Property Nested Expectations

Problem

By the tower property E[E[X | Y]] = E[X]. Given conditional means and the probabilities of the conditioning events, return the overall mean.

Given the conditional means and the probability weights, return the weighted average.

Hint

Iterated expectation collapses to the marginal mean.

Test cases

case 1
in: [[2,4],[0.5,0.5]]
expected: 3
case 2
in: [[0,10,20],[0.2,0.3,0.5]]
expected: 13
case 3
in: [[-1,1],[0.5,0.5]]
expected: 0
Starter codePython
def tower_property_nested_expectations(conditional_means, weights):
    # Your code here
    pass

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