STAT 200 · Statistics for Economics
Random Variables and Expected Value
Turn uncertain outcomes into numbers, find their long-run average and spread, and see why expected value alone does not decide.
Key takeaways
- A random variable is a number whose value depends on chance, such as tomorrow's pastry sales.
- A probability distribution lists the possible values and their probabilities, which must add up to 1.
- Expected value is the probability-weighted average, and it describes the long-run average, not any single day.
- Variance and standard deviation measure how far outcomes tend to land from the expected value.
- Good decisions compare expected values but also consider risk, because a bad outcome may be one you cannot survive.
Picture Theo, who runs a coffee cart outside a train station. Every evening he orders pastries for the next morning. He has no idea how many commuters will want one. Rain keeps people hurrying past. A delayed train strands a hungry crowd.
If he orders too few, he loses sales. If he orders too many, he feeds the pigeons at a loss. Is there a smart order size when tomorrow is a mystery?
There is, and it starts with a simple move. Stop asking "what will happen?" Ask "what could happen, how likely is each case, and what is each case worth?" That list is the raw material for one of the most useful ideas in economics.
From events to numbers
A random variable is a quantity that takes a number as its value, where chance decides which number. We usually name it with a capital letter such as X. Tomorrow's number of pastry buyers is one. So is the total on two dice, or the number of late payments among Theo's catering clients.
Some random variables are discrete: you can list their values one by one, like 0, 1, 2 or 3 late payments. Others are continuous: they can take any value in a range, like the exact minutes a train is delayed. This lesson sticks to discrete ones. The normal distribution handles a famous continuous case.
A probability distribution is the full list of values with the chance of each. Theo studies his notes and builds this invented one for daily pastry demand:
| Demand (pastries) | Probability |
|---|---|
| 20 | 0.2 |
| 30 | 0.5 |
| 40 | 0.3 |
Every probability sits between 0 and 1, and together they add to 1. If yours add to 0.9, you have forgotten a case. If they add to 1.2, you have counted something twice. The rules come from probability basics.
The three chances add to 100%. Hypothetical example: the numbers are made up to show the method, not a quote or an average.
Expected value: the weighted average
The expected value of a random variable, written E(X), is the average of its possible values, with each value weighted by its probability. Multiply each value by its chance, then add.
E(X) = 20 × 0.2 + 30 × 0.5 + 40 × 0.3
= 4 + 15 + 12
= 31 pastries Theo will never sell 31 on a day when demand can only be 20, 30 or 40. That is fine. Expected value is not a prediction of one morning. It is what the daily average settles toward if the same situation repeats many times. Across 100 days he would expect about 20 quiet days, 50 normal days and 30 busy ones, for about 3,100 pastries wanted in all.
Notice how this differs from the plain average of 20, 30 and 40, which is 30. The plain average treats each case as equally likely. Expected value leans toward the cases that happen more. It is the same idea as a weighted mean.
Worked example: how many should Theo order?
Suppose each pastry costs Theo $1 and sells for $3. Unsold pastries are thrown out. He is choosing among orders of 20, 30 or 40.
The key point is that profit is also a random variable. It depends on both his order and the day's demand. He sells the smaller of the two numbers, and he pays for everything he ordered.
Order 20. Demand is always at least 20, so he sells all 20 every day. Revenue is $60, cost is $20, and profit is $40 for certain.
Order 30. Cost is $30. On a quiet day he sells 20 for $60, so profit is $30. On normal and busy days he sells 30 for $90, so profit is $60.
E(profit) = 30 × 0.2 + 60 × 0.8
= 6 + 48
= $54 Order 40. Cost is $40. Quiet day: sell 20, profit $60 − $40 = $20. Normal day: sell 30, profit $90 − $40 = $50. Busy day: sell 40, profit $120 − $40 = $80.
E(profit) = 20 × 0.2 + 50 × 0.5 + 80 × 0.3
= 4 + 25 + 24
= $53 | Order | Quiet (0.2) | Normal (0.5) | Busy (0.3) | Expected profit |
|---|---|---|---|---|
| 20 | $40 | $40 | $40 | $40 |
| 30 | $30 | $60 | $60 | $54 |
| 40 | $20 | $50 | $80 | $53 |
Ordering 30 wins, by a nose. Look at why. Moving from 30 to 40 means 10 extra pastries. Each earns $2 more if it sells and loses $1 if it does not. They only sell on busy days, so the extra batch adds less than it costs on average. This is thinking at the margin with probabilities attached.
Expected profit is highest at 30, but only by $1 over ordering 40.
Spread: how bumpy is the ride?
Two choices can share nearly the same expected value and feel very different. To measure the bumpiness, use the variance of a random variable: the probability-weighted average of squared distances from the expected value. Its square root is the standard deviation, which is back in ordinary units. You met both for data in the lesson on spread.
For an order of 30, the expected profit is $54:
| Profit | Distance from 54 | Squared | Probability | Product |
|---|---|---|---|---|
| 30 | −24 | 576 | 0.2 | 115.2 |
| 60 | 6 | 36 | 0.8 | 28.8 |
Variance is 115.2 + 28.8 = 144, so the standard deviation is $12.
For an order of 40, with expected profit $53, the distances are −33, −3 and 27. The weighted squares are 1089 × 0.2 = 217.8, then 9 × 0.5 = 4.5, then 729 × 0.3 = 218.7. The variance is 441 and the standard deviation is $21.
So ordering 40 earns a dollar less on average and swings almost twice as widely. Ordering 20 earns much less but has a standard deviation of zero. There is no free lunch here, only free pigeon food.
Handy rules for combining
Three rules save a lot of arithmetic.
- Adding a fixed amount shifts the expected value by that amount: E(X + c) = E(X) + c. The spread does not change.
- Multiplying by a fixed number scales both the expected value and the standard deviation by that number (use its positive size for the standard deviation).
- The expected value of a sum is the sum of the expected values: E(X + Y) = E(X) + E(Y). This holds even if X and Y are related.
Suppose Theo pays a $15 daily pitch fee. With an order of 30, his expected profit drops from $54 to $39, and the standard deviation stays at $12. If he opens a second cart expecting $25 a day, the two together expect $64.
Variances are fussier. You can add them only when the variables are independent. If both carts suffer on the same rainy mornings, their combined risk is bigger than that simple sum suggests.
Where economists use this
Expected value shows up wherever people must choose before they know what will happen. A farmer picks a crop before knowing the weather. A student picks a major before knowing the job market. A firm decides whether to research a product that may flop.
Take a lender. Suppose she lends $1,000 for a year. With probability 0.95 the borrower repays $1,100. With probability 0.05 the borrower repays nothing. (To keep it simple, there is no partial repayment.)
Expected repayment = 1,100 × 0.95 + 0 × 0.05
= $1,045
Expected gain = 1,045 − 1,000 = $45, or 4.5% The loan advertises 10% interest, but its expected return is only 4.5%. The gap pays for the chance of default. If the chance of default rose to 10%, the expected repayment would be $990, and the lender would expect to lose money. She would need to charge more or walk away. This helps explain why riskier borrowers usually pay higher interest rates.
You can find the break-even rate too. With 5% default, the lender needs 0.95 × repayment = $1,000, so the repayment must be about $1,052.63. That is an interest rate of about 5.3% just to get her money back on average, before any reward for waiting or for bearing risk.
Information has a value you can compute this way as well. Suppose a perfect forecaster told Theo each evening what tomorrow's demand would be. He would order exactly that number and earn $2 on every pastry demanded. His expected profit would be 2 × 31 = $62. Without the forecast, his best plan earns $54. So a perfect forecast is worth up to $8 a day to him. A forecast that costs $10 is a bad buy, even if it is never wrong.
Real forecasts are imperfect, so they are worth less than that ceiling. To value one, you would update the demand probabilities using the forecast, as in Bayes' rule, and then find the best order for each thing the forecaster might say.
The common mistake: treating the average as a promise
Imagine someone offers Theo a coin flip. Heads, he wins $60,000. Tails, he loses $40,000. The expected value is 0.5 × 60,000 + 0.5 × (−40,000) = $10,000. Positive! Should he take it?
If losing would cost him the cart and his rent, many sensible people would refuse. He gets one flip, not a thousand. The long-run average never arrives if the first bad result ends the game. People who prefer a sure thing over a gamble with the same expected value are called risk averse.
This is why insurance sells. Suppose a $5,000 espresso machine has a 2% yearly chance of being destroyed. The expected loss is $100. An insurer might charge $130. On average Theo pays $30 more than he expects to lose. He may still buy it, because $130 is easy to bear and a surprise $5,000 is not. The insurer, with thousands of mostly unrelated policies, faces a far steadier average.
Made-up prices. Real policies have deductibles and exclusions.
A second mistake is plugging the average input into the problem. Average demand is 31, but that does not mean profit equals what you would earn if demand were always exactly 31. When you order 30, a quiet day hurts you and a busy day cannot make up for it, because you have no extra pastries to sell. Work out the profit in each case first, then average.
Words to know
Random variable a numerical quantity whose value is decided by chance.
Probability distribution the possible values of a random variable together with their probabilities.
Expected value the probability-weighted average of all possible values.
Variance the expected squared distance of a random variable from its expected value.
Standard deviation the square root of the variance, measured in the original units.
Discrete variable a variable whose possible values can be listed one at a time.
Risk averse preferring a certain amount to a gamble with the same expected value.
Check yourself
- What two things does a probability distribution list, and what must the probabilities add up to?
- A raffle ticket pays $50 with probability 0.04 and nothing otherwise. What is its expected payout?
- A variable equals 10 with probability 0.5 and 30 with probability 0.5. Find its expected value and standard deviation.
- If E(X) = 31, what is E(2X + 5)?
- Explain why someone might sensibly pay more for insurance than the expected loss.
Show the answers
- It lists the possible values and the probability of each value, and the probabilities must add to 1.
- The expected payout is 50 × 0.04 + 0 × 0.96 = $2.
- The expected value is 20, each distance is 10, the variance is 100, and the standard deviation is 10.
- Double the expected value and add 5: 2 × 31 + 5 = 67.
- A small certain premium removes the chance of a large loss that could be very hard to recover from, which a risk-averse person values.