Expected Value
The long-run average.
If you rolled a die forever, what would the average roll be? It's not a value you can actually roll. It's three and a half. That's the expected value. The long run average of a random variable.

- Roll a die forever
- Average roll?
- 3.5, the expected value
Weighted by probability
The expected value is each value times its probability, all added up. It's a weighted mean, with probabilities as weights. Let's check it by rolling a million dice. Run it. The formula says three point five, and the simulation agrees.
import numpy as np
faces = np.arange(1, 7)
probs = np.full(6, 1 / 6)
print("expected:", (faces * probs).sum())
rng = np.random.default_rng(0)
print("simulated:", rng.integers(1, 7, 1_000_000).mean().round(3))expected: 3.5 simulated: 3.502
Is this game worth playing?
A game costs one dollar to play. You roll a die, and if it's a six, you win four dollars. Should you play? The expected winnings are four dollars times a sixth, minus the dollar you paid. Run it. On average, you lose about thirty three cents every game.
cost = 1
prize = 4
p_win = 1 / 6
expected = prize * p_win - cost
print(f"expected value: {expected:.2f} dollars per game")expected value: -0.33 dollars per game
Summary
The expected value is the probability weighted average, what you'd get on average in the long run. Next, the binomial distribution.
Key takeaways- E[X] = Σ value × prob
- A weighted mean
- Negative EV: don't play