Explore Library
Code QuizIntermediate

Expected Value of a Discrete Distribution

Spotting why an expected-value function adds instead of multiplies.

Codepython
def expected_value(values, probs):
    total = 0
    for v, p in zip(values, probs):
        total += v + p
    return total

print(expected_value([1, 2, 3], [0.2, 0.3, 0.5]))

What is the bug in this expected-value calculation?