Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-230

Sobol First-Order Index

Problem

First-order Sobol sensitivity index from conditional means, conditional variances and probabilities of a conditioning variable:

S = Var(E[Y | X]) / (E[Var(Y | X)] + Var(E[Y | X])).

Return 0.0 when the total variance is 0 or the inputs are empty.

Hint

Use the law of total variance decomposition and take the fraction explained by the conditioning variable.

Test cases

case 1
in: [[0,10],[1,1],[0.5,0.5]]
expected: 0.9615384615384616
case 2
in: [[2,4],[3,5],[0.25,0.75]]
expected: 0.14285714285714285
case 3
in: [[1,1],[2,3],[0.5,0.5]]
expected: 0
case 4
in: [[],[],[]]
expected: 0
Starter codePython
def sobol_first_order_index(cond_means, cond_vars, probs):
    # Your code here
    pass

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