Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-405

Law of Total Variance Decomposition

Problem

The law of total variance splits Var(X) = E[Var(X | Y)] + Var(E[X | Y]).

Given the expected conditional variance and the variance of the conditional expectation, return Var(X).

Hint

Within-group plus between-group variance.

Test cases

case 1
in: [2,3]
expected: 5
case 2
in: [0,1]
expected: 1
case 3
in: [5.5,4.5]
expected: 10
Starter codePython
def law_of_total_variance_decomposition(expected_variance, variance_of_expectation):
    # Your code here
    pass

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