Skip to content
DeepForgeby svx
All problems
EasyOptimizationop-213

Expected Value Lite

Problem

Compute the expected value of a discrete random variable.

Return sum(values[i] * probs[i]).

Hint

Weight each outcome by its probability.

Test cases

case 1
in: [[1,3],[0.5,0.5]]
expected: 2
case 2
in: [[2,4,6],[0.2,0.3,0.5]]
expected: 4.6
case 3
in: [[0],[1]]
expected: 0
Starter codePython
def expected_value_lite(values, probs):
    # Your code here
    pass

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