You're offered a bet: pay $5 to play. Flip a coin. Heads, you win $12. Tails, you win nothing. Do you take it?
Most people size this up by gut feeling. But there's an actual number that answers the question, and once you know how to compute it, "should I take this bet" stops being a feeling and starts being arithmetic.
That number is the expected value. Let's build it up from scratch.
What does "expected" even mean here?
Here's the trap. "Expected value" sounds like it should mean "the outcome you expect to happen." But flip that coin once, and you get $12 or $0. You never get some in-between number. So whatever expected value is, it isn't a prediction about any single flip.
Instead, picture playing that same game a thousand times. Add up every dollar you won, then divide by a thousand. That average, the payout per play if you played forever, is what expected value actually measures.
For our coin game: half the time you get $12, half the time you get $0. Averaged over many plays, you'd expect to land near $6 per play. That $6 is the expected value, even though $6 never once shows up as an actual outcome of a single flip.
Why does averaging outcomes by how likely they are work?
Think of it as a balancing act. Imagine every possible outcome as a weight sitting on a number line, at the position equal to its value. Outcomes that happen more often get placed with more weight. Expected value is where that whole setup balances, the fulcrum point.
Two outcomes, 2 and 8, sit on a beam. Their weight is how likely they are. Drag the fulcrum (the triangle) and watch the probabilities shift underneath it to keep the beam level, or drag the slider directly.
Drag the fulcrum and notice what happens: the probabilities shift underneath it so the beam stays level. Load up more weight on the outcome at 8, and the balance point slides toward 8. Load up more weight on 2, it slides back. The balance point is never one of the two weights themselves. It's pulled between them, in proportion to how heavy each one is.
That's the whole intuition. Now for the notation: if a random outcome can take values with probabilities , we write the expected value as:
Each outcome contributes its value, scaled down by how rarely it happens. Add up all those contributions and you get the balance point. For our coin game, that's , exactly what we guessed.
Does the average of real plays actually land on that number?
Let's not just trust the formula, let's watch it happen. Here's a slightly meaner game: lose $5 half the time, win $4 thirty percent of the time, win $20 twenty percent of the time.
A game: lose $5 half the time, win $4 30% of the time, win $20 20% of the time. Press play and watch the running average of many plays. It's noisy at first, then it locks onto E[X], the dashed line.
Press play. Early on, the running average jumps around a lot, one lucky $20 win can spike it. But keep playing, and the noise gets diluted. The average settles down and locks onto the dashed line, which is exactly computed from the formula.
Notice it never "aims" for that line. No play secretly nudges toward it. It's just that a thousand ordinary plays outweigh any one streak, and what they average out to is, by definition, the expected value. This is the same mechanism behind the law of large numbers, expected value is the specific number that averages converge to.
How do you decide if a bet is actually worth playing?
This is where expected value stops being an abstract exercise and starts being useful. Once you can compute for a bet, "is this worth it" has a real answer: positive expected value means the bet pays you, on average, over the long run. Negative means it costs you.
Try a raffle: pay to lose $5 sixty percent of the time, win $2 thirty percent of the time, or hit a jackpot ten percent of the time.
A raffle: pay to lose $5 sixty percent of the time, win $2 thirty percent of the time, or hit a jackpot ten percent of the time. Each bar is x times p(x). Drag the jackpot and watch it single-handedly flip the total.
Watch what a single rare outcome can do. Even with a 60% chance of losing money, dragging the jackpot high enough flips the entire sum from negative to positive. That's not your intuition failing, it's the math doing exactly what it's supposed to: a huge payout, even a rare one, gets weighted by its size and can outpull everything else combined.
This is exactly how casinos, insurance companies, and lotteries stay profitable while individual players sometimes win big. The house doesn't need to win every round. It just needs tilted in its favor.
If two bets have the same expected value, are they the same bet?
Not even close. And this is the part people miss most often. Expected value collapses an entire spread of outcomes into a single number, which means two very different situations can share the exact same .
All three of these random processes have the exact same E[X] = 3.5. Switch between them and watch how differently the probability actually spreads out underneath that one number.
All three of these have . A fair die, spread evenly from 1 to 6. A coin flip between $0 and $7. A "near-certain" bet that pays $3 ninety percent of the time but occasionally spikes to $18.50. Switch between them and look at the standard deviation readout, it swings wildly even while the expected value stays frozen.
Expected value tells you where the average lands. It says nothing about how far outcomes can swing from that average. That's a separate question, measured by variance and standard deviation, not by alone. Two investments can have identical expected returns while one is a coin flip and the other is a sure thing with an occasional surprise. Expected value alone can't tell them apart.
Putting the formula to work
Now that the balance-point idea is solid, here's the general definition. For a discrete random variable with possible values and probabilities (with ):
If is continuous instead, described by a probability density function , the sum becomes an integral:
Same idea in both cases: weight every possible value by how likely it is, then add. Discrete outcomes get summed, continuous ones get integrated, because there are infinitely many of them to weigh.
One more useful fact: expected value is linear. For any random variables and and constants :
This holds even when and depend on each other, which is part of why expected value shows up everywhere from insurance pricing to machine learning loss functions. You can compute the expected value of a complicated sum by just adding up the expected values of its simpler pieces.
The short version
Expected value is not a guess at what will happen next. It's the long-run average payout of a random process, the point where all possible outcomes balance when weighted by how often they occur. You compute it by multiplying each outcome by its probability and adding the results up.
A positive expected value means a bet pays off over time. A negative one means it costs you, no matter how good any single round feels. And because expected value is just one number, it can never tell you the full story on its own, two wildly different distributions of risk can share the exact same . For that, you need variance too.
But as a first filter for "is this random thing worth it," expected value is the tool. Weight every outcome by its probability, add them up, and you know exactly where the balance point sits.
All visualizations are interactive React components running entirely in your browser, generating fresh random draws on every load. No libraries beyond React.