Random Variables and Expected Value
What You’ll Learn
Section titled “What You’ll Learn”In this lesson you’ll learn what a random variable is, how to write a probability distribution, how to compute expected value and interpret it, and how to find the variance of a random variable.
The Concept
Section titled “The Concept”Random variables
Section titled “Random variables”A random variable assigns a number to each outcome of an experiment.
Flipping three coins, let = the number of heads. Then can be 0, 1, 2, or 3. The randomness is in the experiment; just translates outcomes into numbers so we can do arithmetic.
Two kinds, matching the data types from earlier:
- Discrete - countable values. Number of heads, number of defects, dice totals.
- Continuous - any value in an interval. Height, time, temperature. These need calculus and come in a later lesson.
This lesson handles discrete.
Probability distributions
Section titled “Probability distributions”A probability distribution lists every value the variable can take and its probability.
For = heads in three flips, from the 8 equally likely outcomes:
| 0 | 1 | 2 | 3 | |
|---|---|---|---|---|
| 1/8 | 3/8 | 3/8 | 1/8 |
Every valid distribution satisfies two rules:
- Each
Check the second one every time. It catches errors instantly. Here ✓
Notice the coefficients 1, 3, 3, 1 are a row of Pascal’s triangle. That’s not a coincidence, and it’s the bridge to the binomial distribution next lesson.
Expected value
Section titled “Expected value”The expected value is the long-run average value of the random variable, weighting each outcome by its probability:
It’s a weighted mean, with probabilities as the weights.
For the three-coin example:
The expected value need not be a possible outcome. You can never flip 1.5 heads. Expected value describes the average of many repetitions, not any single trial. A family can’t have 2.3 children either.
This is the most common misunderstanding of the term. “Expected” doesn’t mean “the result to expect.” It means “the long-run mean.”
Variance and standard deviation of a random variable
Section titled “Variance and standard deviation of a random variable”Spread works the same way as before, weighted by probability:
There’s an algebraically equivalent shortcut that’s usually less work:
where . Compute the mean of the squares, subtract the square of the mean.
Then as always:
Fair games and expected value of money
Section titled “Fair games and expected value of money”A game is fair if . If it’s positive the bet favors you; negative and it favors the house.
Essentially every commercial gambling product has negative expected value for the player, and that’s the business model. The house edge is expressed as a percentage of the wager.
Expected value is also the right lens for insurance, which has negative expected value for the buyer and is still often rational to purchase. Buying insurance means accepting a small expected loss to avoid a small chance of a catastrophic one. Expected value alone doesn’t capture how much worse a ruinous loss is than its numeric size, which is why economists add the idea of utility.
Worked Examples
Section titled “Worked Examples”Example 1: Verify a distribution and find E(X).
| 1 | 2 | 3 | 4 | |
|---|---|---|---|---|
| 0.1 | 0.3 | 0.4 | 0.2 |
Solution. Check: ✓
Example 2: Variance both ways.
Using the distribution above, find and .
Solution, definition method.
| 1 | −1.7 | 2.89 | 0.1 | 0.289 |
| 2 | −0.7 | 0.49 | 0.3 | 0.147 |
| 3 | 0.3 | 0.09 | 0.4 | 0.036 |
| 4 | 1.3 | 1.69 | 0.2 | 0.338 |
Solution, shortcut method.
Both routes agree, and the shortcut needed one table instead of four columns.
Example 3: A dice game.
You pay 2 dollars to roll one die and win the number of dollars shown. Is this a good bet?
Solution. Winnings average:
Net gain per play:
Positive expected value, so it’s a good bet for you. Over 100 plays you’d expect to profit about 150 dollars. No casino would offer this.
Example 4: Roulette.
An American roulette wheel has 38 pockets: 18 red, 18 black, 2 green. You bet 10 dollars on red, winning 10 dollars if red comes up and losing 10 otherwise. Find the expected value.
Solution.
You lose about 53 cents per 10 dollars wagered, a house edge of 5.26%. The two green pockets are the entire source of it: without them the game would be exactly fair.
Example 5: The lottery.
A ticket costs 2 dollars. The jackpot is 10 million with probability 1 in 20 million, and there’s a 100 dollar prize with probability 1 in 50,000. Ignoring other prizes, find the expected value.
Solution.
You lose about 1.50 dollars per ticket, so the game returns roughly 25 cents per dollar. Even when a jackpot grows large enough to make the raw expected value positive, splitting the prize among multiple winners and taxes usually pull it back down.
Example 6: Insurance from both sides.
A policy costs 300 dollars per year. There’s a 1.5% chance of a claim, in which case the insurer pays 15,000 dollars. Find the expected value for each side.
Solution. For the insurer:
For the customer:
The insurer expects 75 dollars profit per policy, and the customer expects to lose 75. Yet buying may still be sensible: the customer is paying 75 dollars to convert a 1.5% chance of a 15,000 dollar disaster into a certain, survivable 300 dollar cost. The insurer can accept the risk because the Law of Large Numbers makes its aggregate outcome predictable across many policies.
Expected value tells you the average. It deliberately says nothing about whether you can survive the bad case, which is why it isn’t the only thing that matters.
Real-World Applications
Section titled “Real-World Applications”Insurance pricing is expected value plus a margin. Actuaries estimate claim probabilities and severities, compute the expected payout, and add loading for expenses and profit. The entire industry is this lesson applied at scale.
Business decisions use expected monetary value to compare options with uncertain payoffs. A project with a 30% chance of 1 million and a 70% chance of losing 200,000 has an EV of 160,000, which makes it worth considering, though a company that can’t absorb the loss might still decline.
Machine learning trains models by minimizing expected loss, and reinforcement learning agents choose actions to maximize expected future reward. Expected value is the objective function.
Sports analytics is saturated with it. Expected goals in soccer, expected points added in football, and win probability models all assign values to situations by averaging over outcomes.
Portfolio theory pairs expected return with variance, which is exactly the two quantities from this lesson. Modern finance is largely about the tradeoff between them.
And the negative expected value of gambling is why casinos are profitable, reliable businesses rather than gambles themselves. The house doesn’t need luck; it needs volume.
Retrying will remove your ✅ checkmark until you pass again.