When you calculate variance, the most common mistake is treating (E[X^2]) as though it were ((E[X])^2). They are not interchangeable: averaging outcomes before squaring can erase the volatility that makes a result seem unusually lucky or unlucky.
Variance is (/operatorname{Var}(X)=E[X^2]-(E[X])^2): find the average of (X), find the average of (X^2), and subtract the squared average.
Calculate variance with E[X²] − (E[X])²
Calculate E[X²] and (E[X])² separately, then subtract the second from the first.
Which value gets squared first?
For E[X²], square X before expectation acts. If X can be 0 or 2 with equal probability, E[X²] is ((0² /times 0.5)+(2² /times 0.5)=2). For ((E[X])²), first calculate E[X] = 1, then square it to get 1. Therefore, variance is (2-1=1).
How do I calculate it from a table?
For a discrete random variable, use columns for outcome x, probability P(X = x), xP(X = x), x², and x²P(X = x). Add the xP(X = x) column for E[X] and the x²P(X = x) column for E[X²].
Keep this sequence visible: outcomes → square each outcome → weight by probability → add. That gives E[X²]. Separately, outcomes → weight by probability → add → square. That gives (E[X])².
Expected value is a probability-weighted average determined by a probability distribution: for a discrete random variable, each possible value is weighted by P(X = x), while for a continuous variable, values are weighted through its density. In this language, E[X] is the population mean, and E[X²] is the probability-weighted average of the squared outcomes. Keeping those descriptions separate helps organize a variance calculation: compute the mean and variance from the same distribution, but square each outcome only for E[X²], not the already averaged mean.
This is the variance formula stated in words as well as symbols.
Why E[X²] is not (E[X])²
E[X²] retains information about spread, while ((E[X])²) compresses outcomes into one mean before squaring.
Why does averaging erase volatility?
Positive and negative deviations cancel when averaged. For outcomes 0 and 2 around a mean of 1, deviations are −1 and +1, whose average is 0. Squaring makes both distances equal to 1, so cancellation cannot hide the spread.
Can the two expressions ever match?
They match only when there is no spread. If X always equals 7, then E[X] = 7, E[X²] = 49, and ((E[X])² = 49, so variance is zero. More formally, variance is zero when X is constant almost surely.
A single big win does not prove superior skill. In gambling, investing, job searches, and habit building, high variance can create streaks that feel meaningful long before there are enough observations to judge skill.
Derive the shortcut from squared distance
The expected-value formula follows by expanding Var(X) = E[(X − μ)²], where μ = E[X].
Var(X) = E[(X − μ)²]
= E[X² − 2μX + μ²]
Where does the cross term go?
Apply linearity of expectation, then substitute μ = E[X]:
E[X² − 2μX + μ²] = E[X²] − 2μE[X] + μ²
E[X²] − 2μE[X] + μ² = E[X²] − 2μ² + μ² = E[X²] − μ² = E[X²] − (E[X])²
The cross term does not disappear by magic; it combines with μ² after replacing E[X] with μ.
Why can expectation pass through sums?
Linearity says E[aX + b] = aE[X] + b when the expectations exist. Here, μ is fixed once X’s distribution is set, so it can be treated as a constant. Do not confuse μ, the population mean, with a sample mean, written x̄.
Work discrete and continuous examples
The workflow is the same in both formats: find E[X], find E[X²], and subtract the squared first result from the second.
How does the discrete table work?
Let X be a payout of $0 with probability 0.5 or $20 with probability 0.5. Its expected payout is $10, but neither actual outcome equals that average.
| x | P(X=x) | xP(X=x) | x² | x²P(X=x) |
|---|
| 0 | 0.5 | 0 | 0 | 0 |
| 20 | 0.5 | 10 | 400 | 200 |
| Total | 1 | 10 | | 200 |
Here E[X] = 10 and E[X²] = 200. Thus Var(X) = (200-10²=100) dollars squared, and the standard deviation is $10.
How does the continuous integral work?
Let X be uniformly distributed from 0 to 2 hours, with density (f(x)=1/2). Then E[X] = (/int_0^2x(1/2)/,dx=1), while E[X²] = (/int_0^2x²(1/2)/,dx=4/3). Therefore, variance is (4/3-1=1/3) hour².
One method, two probability formats
Discrete outcomes
Multiply each x by its probability.
ΣxP(X=x) gives E[X]
Σx²P(X=x) gives E[X²]
Continuous outcomes
Multiply x by density f(x).
∫xf(x)dx gives E[X]
∫x²f(x)dx gives E[X²]
Final line in both cases: Var(X) = E[X²] − (E[X])².
Use E[(X − μ)²] when learning what variance means or when deviations from the mean are already available. Use E[X²] − (E[X])² when a table or distribution makes both expected values easy to calculate.
What variance says about luck and risk
High variance means outcomes are farther from their expected value on average; it describes spread, not whether the expected value is favorable.
Why is standard deviation easier to read?
Variance uses squared units. If X is measured in dollars, variance is dollars squared, while standard deviation is its square root and returns to dollars. For the $0-or-$20 example, the variance is 100 dollars squared and the standard deviation is $10.
Does repeated trial erase luck?
The law of large numbers says averages tend to approach expected value as independent trials increase. It does not guarantee that short runs will look smooth, nor does it make a streak proof of skill or a hidden cause.
“Choose the highest expected value” is complete advice only when you can tolerate the variance, losses, and time horizon. A steady contract may be preferable to a volatile commission role even when their average incomes are similar.
When this formula is not enough: variance alone cannot describe asymmetric losses, rare extreme events, or dependence between variables. For those cases, examine the full distribution, quantiles, downside risk, and covariance. Also, do not treat a variance calculated from a sample as if it were automatically the population variance, and do not use the computational formula as a finite number unless E[X²] is finite. A random variable can have a finite E[X] but an infinite second moment, so its variance is not finite.
Your questions answered
How do I calculate variance from expected value?
Calculate E[X²], then subtract (E[X])²: Var(X) = E[X²] − (E[X])². For discrete variables, use Σx²P(X=x); for continuous variables, use ∫x²f(x)dx.
Is variance always positive?
Variance is always nonnegative when it exists. It equals zero when the random variable is constant almost surely, and it can fail to be finite when E[X²] is infinite.
Is expected value the same as mean?
Expected value is the population mean of a random variable, usually written E[X] or μ. A sample mean, x̄, estimates that population quantity from observed data.
Why is E[X²] bigger than (E[X])²?
E[X²] is at least (E[X])² whenever the second moment is finite. Their difference is variance, which is zero only when there is no random spread.
Can a positive expected value still lose money?
A positive expected value can still lose money in one trial or many short runs. Higher variance makes large departures from the average more common.
Should I report variance or standard deviation?
Report standard deviation when readers need familiar units such as dollars, hours, or points. Report variance for algebra and statistical formulas requiring squared units.
Keep E[X²] and (E[X])² on separate lines, then ask whether the resulting spread fits the loss you can absorb and the number of trials you can realistically make.
The essential points:- Variance equals E[X²] − (E[X])² because squared distance expands exactly into that expression.
- Square before averaging for E[X²]; average before squaring for (E[X])².
- A high expected value and high variance can exist together, so average payoff is not the full risk picture.
- Use standard deviation for an interpretation in original units, and use more than variance for tail losses or linked risks.
Related sources
These articles can help you explore the topic in more depth: