TL;DR
The mean tells you where a set of values is centred. The variance tells you how spread out they are around that centre: it is the average of the squared distances from the mean. Taking the square root gives the standard deviation, which measures spread in the same units as the data.
Both numbers summarise a distribution with two figures instead of the whole list of values. Where you'll see it: in error bars on lab measurements, in the z-scores used to flag unusual results, and in the two parameters that define a Gaussian.
Intuition
Suppose five friends weigh 60, 62, 64, 66 and 68 kg. You want one number for a typical weight. The mean, 64 kg, is the balance point: the values on either side of it cancel out exactly. The mean says where the data sits, but two groups can share a mean and look nothing alike. Weights of 63, 64, 64, 64, 65 and weights of 50, 58, 64, 70, 78 both average 64.
To describe the difference you need a spread measure. The obvious idea is to average the distances from the mean. But positive and negative distances cancel, so you square each distance first. Squaring also punishes large deviations more than small ones, which is useful when you care about big misses. The average of those squares is the variance. Its units are squared (kg²), which is awkward to read, so you take the square root to get the standard deviation, in kg again.
flowchart LR A[Values] --> B[Mean: the centre] B --> C[Distance of each value from the mean] C --> D[Square each distance] D --> E[Average the squares: variance] E --> F[Square root: standard deviation]
The math
Mean (expected value)
For a random variable that takes value with probability , the mean is the expected value:
Here (the Greek letter mu) is the centre of the distribution, and is the probability of outcome . For a finite list of observed values with equal weight, the sample mean is . It is the same operation with each value weighted .
Variance
The variance of a random variable with mean is
Its square root is the standard deviation.
Here is the variance and the standard deviation. The expression is the signed distance from the centre, and squaring it removes the sign.
There is a shortcut formula that is usually easier to compute. Expand the square and use linearity of expectation (the mean of a sum is the sum of the means):
So the variance is the mean of the squares minus the square of the mean.
Scaling and shifting
Adding a constant moves the data but does not change its spread. Multiplying by a constant stretches it. The rules are
The second follows because , and squaring gives . Notice that the standard deviation scales by , not .
Adding independent quantities
If and are independent, their variances add:
Expanding gives two squared terms plus a cross term . Independence makes the expected cross term zero: the average of a product of independent deviations is the product of their averages, and each of those averages is 0. Standard deviations do not add: , which is less than whenever both are positive.
Worked examples
Let be the value of one roll of a fair six-sided die. Each face has probability .
- Mean: .
- Mean of squares: .
- Variance: , which is exactly .
- Standard deviation: .
- Interpretation: a typical roll is about 1.7 faces away from 3.5. The mean is not a face you can roll, which is normal: the mean is a balance point, not an outcome.
Eight students score 2, 4, 4, 4, 5, 5, 7 and 9.
- Sum is 40, so the mean is .
- Deviations from 5 are . Their squares are , which sum to 32.
- If these eight are the whole class, the variance is and the standard deviation is 2.
- If they are a sample from a larger group, divide by instead. The variance estimate is and the standard deviation is about 2.14.
- Interpretation: the spread is about two points. Dividing by corrects the tendency of the sample to look less spread out than the full population.
A temperature sensor reports Celsius with standard deviation 2 degrees. What is the spread in Fahrenheit?
- The conversion is , so and .
- .
- , which is .
- Interpretation: the shift by 32 has no effect on spread, and the stretch by 1.8 multiplies the standard deviation by 1.8.
Tradeoffs and failure modes
Mean and variance are the right summaries when the data is roughly symmetric and free of extreme values. They are misleading when it is not.
| Situation | Problem | Better choice |
|---|---|---|
| One extreme value (an outlier) | The mean moves toward it and the variance inflates | Median and interquartile range |
| Heavy-tailed or skewed data (incomes, response times) | The mean describes no typical person; the variance may be huge or even infinite | Median, quantiles, log-transform |
| Comparing spread across different scales | Standard deviation depends on units | Coefficient of variation (for positive only) |
| Growth rates, multiplicative effects | Arithmetic mean overstates typical growth | Geometric mean |
| Very small samples | Dividing by underestimates the variance | Divide by |
Some practical warnings:
- Two numbers can hide shape. A bimodal set of values can have the same mean and variance as a flat one. Plot the data before trusting the summary.
- The shortcut formula can fail numerically. If the values are large and their spread is small, subtracts two nearly equal numbers and loses precision. Use an online method such as Welford's algorithm in code.
- Squared units are hard to read. Report the standard deviation for anything a person will interpret.
History
The arithmetic mean is far older than probability. Astronomers and surveyors averaged repeated measurements to reduce error long before anyone called it an expectation. The link to chance came from gambling. In 1657 Christiaan Huygens published a short treatise on dice games that introduced the idea of expected value, the average winnings over many plays.
Spread measures came later. Carl Friedrich Gauss, working on measurement errors in the early 1800s, relied on squared deviations in his least-squares method. The term "standard deviation" was introduced by Karl Pearson in the 1890s. The term "variance" was introduced by Ronald Fisher in 1918, in a paper on heredity. Both names stuck because the squared-deviation measure turned out to be the one that adds cleanly for independent quantities, which is what makes it so useful in later statistics.
Check yourself
QuestionWhat is the variance of a random variable that equals 3 with certainty?Show answer
The variance is 0. There is no spread: every value is the mean, so every squared distance from the mean is 0.
QuestionValues are with equal weight. What is the variance?Show answer
The mean is . The squared deviations are , which sum to 14. Dividing by 4 gives variance .
QuestionWhy do we square the deviations instead of averaging their absolute values or just averaging them?Show answer
Plain deviations average to zero for any dataset, because the positive and negative distances cancel exactly. Absolute values would work as a spread measure, but squaring gives a smooth function that is easy to differentiate and adds cleanly for independent quantities. That is why the variance, not the mean absolute deviation, underlies most of probability theory.
QuestionA measurement error is the sum of two independent sources, and each source has variance 4. What is the standard deviation of the total error, and why is it not 8?Show answer
The variances add: , so the standard deviation is . It is not 8 because standard deviations do not add. Only variances add for independent quantities.
Sources
- Variance (Wikipedia): https://en.wikipedia.org/wiki/Variance
- Standard deviation (Wikipedia): https://en.wikipedia.org/wiki/Standard_deviation
- Expected value (Wikipedia): https://en.wikipedia.org/wiki/Expected_value