Expected value and variance are the two summary numbers every random variable comes with. Expected value is the long-run average; variance measures how spread out the outcomes are around that average. For a discrete random variable, both are weighted sums over the probability distribution — there is no calculus, just careful bookkeeping. This guide walks the formulas and applies them to two examples that show exactly where students lose marks.
What E(X) Actually Is
The expected value of a discrete random variable X is
E(X) = Σ x · P(X = x)
summed over every value x that X can take. Each outcome contributes its value weighted by how often it occurs. The result is the mean of the probability distribution — what X averages to over the long run, even though X never has to equal E(X) on any single trial.
A quick example: roll one fair six-sided die. Each face 1 through 6 has probability 1/6.
E(X) = 1(1/6) + 2(1/6) + 3(1/6) + 4(1/6) + 5(1/6) + 6(1/6) = 21/6 = 3.5
You will never roll a 3.5 — that is the point. E(X) is a long-run average across many rolls, not a possible outcome of a single roll.
What Var(X) Actually Is
The variance measures the spread of X around its expected value. Its formula is the expected squared deviation:
Var(X) = E[(X − μ)²] = Σ (x − μ)² · P(X = x)
where μ = E(X). Larger variance means outcomes are spread further from the mean.
There is a shortcut formula that is usually faster to compute:
Var(X) = E(X²) − [E(X)]²
E(X²) is the expected value of the squared values, computed the same way as E(X) but with x² in the sum: E(X²) = Σ x² · P(X = x). Subtract the squared mean and you have Var(X). The two formulas always give the same answer; the shortcut just avoids computing each (x − μ)² by hand.
Standard deviation is the square root of variance: σ = √Var(X). Variance is in squared units; standard deviation is in the original units of X.
Worked Example: The Fair Die
Stick with the fair die for one more lap to see Var(X) in action.
E(X) is 3.5, from above.
E(X²) = 1²(1/6) + 2²(1/6) + 3²(1/6) + 4²(1/6) + 5²(1/6) + 6²(1/6) = (1 + 4 + 9 + 16 + 25 + 36)/6 = 91/6 ≈ 15.167
Var(X) = E(X²) − [E(X)]² = 15.167 − (3.5)² = 15.167 − 12.25 = 2.917
σ = √2.917 ≈ 1.708
The die has a long-run average of 3.5 and a standard deviation of about 1.71. About two-thirds of rolls fall within one σ of the mean — between roughly 1.8 and 5.2 — which checks visually against the uniform distribution on 1 to 6.
Worked Example: A Lottery Ticket
A ticket costs $5. It has a 1% chance of winning $100, a 5% chance of winning $20, and a 94% chance of winning nothing. Let X be the net dollar amount per ticket (winnings minus the $5 cost). Find E(X) and Var(X).
The outcomes for X are 100 − 5 = 95, 20 − 5 = 15, and 0 − 5 = −5, with probabilities 0.01, 0.05, and 0.94 respectively. A sanity check: the probabilities sum to 1. Good.
E(X) = 95(0.01) + 15(0.05) + (−5)(0.94) = 0.95 + 0.75 − 4.70 = −$3.00 per ticket
Each ticket loses $3 on average. The expected value of winnings alone is 100(0.01) + 20(0.05) + 0(0.94) = $2.00, and subtracting the $5 cost gives the same −$3. Either accounting works as long as you do not double-count the cost.
E(X²) = (95)²(0.01) + (15)²(0.05) + (−5)²(0.94) = 9025(0.01) + 225(0.05) + 25(0.94) = 90.25 + 11.25 + 23.50 = 125.00
Var(X) = 125.00 − (−3.00)² = 125.00 − 9.00 = 116.00 dollars²
σ = √116.00 ≈ $10.77
So the lottery has an expected loss of $3 per ticket but a standard deviation of nearly $11 — most tickets pay you nothing (and cost $5), but the occasional $100 winner creates a wide spread. That contrast between expected value and variance is exactly why lotteries feel exciting even though they are losing bets on average.
Linear Transformations
When you scale or shift a random variable, E and Var follow simple rules. For constants a and b:
- E(aX + b) = a · E(X) + b
- Var(aX + b) = a² · Var(X)
A constant b shifts every outcome by the same amount, so the mean shifts by b but the spread does not change. A scale factor a multiplies every outcome by a, so the mean multiplies by a too — and the variance multiplies by a², because variance is in squared units. The standard deviation multiplies by |a|.
A worked check: if Y = 2X + 10 on the fair die, then E(Y) = 2(3.5) + 10 = 17, and Var(Y) = 4 × 2.917 ≈ 11.67, with σ_Y ≈ 3.42. You can verify by computing E(Y) and Var(Y) directly from the seven equally likely values of 2X + 10 — the rule saves the work.
Common Mistakes
The first is forgetting to weight by probability. Students sometimes average the values of X without using P(X = x), which gives the mean of the support, not the expected value. For a fair die the two happen to coincide because the probabilities are equal; for a non-uniform distribution they will not.
The second is using the wrong variance formula. The shortcut Var(X) = E(X²) − [E(X)]² is fast but requires both E(X²) and E(X) — students who compute only E(X) and then square it get [E(X)]² where they should have E(X²), which is always different unless X is constant.
The third is dropping the negative sign. In the lottery problem, ignoring that one outcome is −$5 (the net loss when you do not win) gives a positive E(X). Always work in net outcomes so the cost is folded into the values themselves.
Getting Help
Expected value of a discrete random variable is the gateway to specific distributions — once you have it, the binomial distribution walkthrough gives you a formula for E and Var without the sum, and the Poisson distribution explained does the same for counts of rare events.
Conclusion
Expected value and variance for a discrete random variable are weighted sums over its probability distribution: E(X) = Σ x · P(X = x), and Var(X) = E(X²) − [E(X)]². The expected value is what X averages to over the long run; the variance measures how widely outcomes spread around that average. The lottery example shows why both numbers matter — a losing average with a wide spread looks very different from a losing average with no spread. Compute E first, then E(X²), then Var; everything else follows.