[Home](https://learningfolio.de5.net/) / [Math](https://learningfolio.de5.net/math/) / [Math glossary](https://learningfolio.de5.net/math/glossary/) / Variance in Statistics: Population and Sample Formulas

[Math glossary](https://learningfolio.de5.net/math/glossary/)

# Variance in Statistics: Population and Sample Formulas

Calculate variance for populations, samples, and frequency tables. Learn why sample variance uses n − 1 and check six worked examples.

Written by **Learningfolio Team**

We’re subject-matter experts in math, science, parent support, and education, with 100 years of combined experience. We believe in learning, experimenting, and growing, and we review one another’s work.

## On this page

* [TL;DR](https://learningfolio.de5.net/math/variance/#tldr)
* [Key Points](https://learningfolio.de5.net/math/variance/#key-points)
* [What is variance in statistics?](https://learningfolio.de5.net/math/variance/#what-is-variance-in-statistics)
* [Which variance formula do you use?](https://learningfolio.de5.net/math/variance/#which-variance-formula-do-you-use)
* [How do you calculate variance with frequencies or grouped intervals?](https://learningfolio.de5.net/math/variance/#how-do-you-calculate-variance-with-frequencies-or-grouped-intervals)
* [What is the difference between variance and standard deviation?](https://learningfolio.de5.net/math/variance/#what-is-the-difference-between-variance-and-standard-deviation)
* [How is variance used for probability distributions?](https://learningfolio.de5.net/math/variance/#how-is-variance-used-for-probability-distributions)
* [Examples of Variance](https://learningfolio.de5.net/math/variance/#examples-of-variance)
* [Where do variance calculations lose their meaning?](https://learningfolio.de5.net/math/variance/#where-do-variance-calculations-lose-their-meaning)
* [Practice with answers](https://learningfolio.de5.net/math/variance/#practice-with-answers)
* [Frequently Asked Questions](https://learningfolio.de5.net/math/variance/#frequently-asked-questions)
* [What to Remember About Variance](https://learningfolio.de5.net/math/variance/#what-to-remember-about-variance)
* [Read More](https://learningfolio.de5.net/math/variance/#read-more)
* [Research Behind This Article](https://learningfolio.de5.net/math/variance/#research-behind-this-article)

## TL;DR

**Variance measures spread by squaring the distances from the mean.** Divide their sum by the population size for a complete population, or by one less than the sample size for the usual sample estimate.

## Key Points

* Population variance divides the squared deviations by the population size, while sample variance uses one fewer than the number of observations.
* A variance of zero means every observed value is identical, and a larger variance can reveal differences hidden by a shared mean.
* Standard deviation is the square root of variance and expresses spread in the original units rather than in squared units.
* An equal shift leaves variance unchanged, while multiplying every value by a factor multiplies the variance by that factor squared.

## What is variance in statistics?

**Variance** describes how far values spread around their arithmetic mean. Subtract the mean from each value, square those differences, then combine them using the denominator appropriate to the question. The [arithmetic mean](https://learningfolio.de5.net/math/formula/mean-median-mode-formula/) locates the centre, while variance measures how far values sit from it.

Simple deviations cancel. For values 9, 10 and 11, the differences from 10 are $-1$, $0$ and $1$. Squaring keeps each distance in the calculation and makes a value far from the centre count more.

![Variance diagram comparing two groups with mean 10 and different distances from the mean](https://learningfolio.de5.net/assets/versioned/variance-same-mean-spread.12c10a645c0a.webp)


Both groups have the same mean. Squared deviations give Group B the larger variance.

## Which variance formula do you use?

Use **population variance** when the observations represent the entire group you want to describe. Use the usual **sample variance** when you use a sample to estimate the variance of a wider population. Decide which group the question is about before counting the values.

| Purpose | Formula | Symbols |
| --- | --- | --- |
| Describe the whole population | $\sigma^2=\frac{\sum_{i=1}^{N}(x_i-\mu)^2}{N}$ | $N$ is the population count, $\mu$ its mean, and $x_i$ value number $i$. |
| Estimate population variance from a sample | $s^2=\frac{\sum_{i=1}^{n}(x_i-\bar x)^2}{n-1}$ | $n$ is the sample count, $\bar x$ its mean, and $x_i$ sample value number $i$. |

The symbol $\sum$ means to add the terms for all listed observations. The top of each fraction is the sum of squared deviations. NIST’s measures-of-scale reference explains why this gives nonnegative spread and how the square root returns to the original measurement units.

If all values are equal, every squared deviation is zero. A population of a single observation therefore has variance zero. The sample variance formula needs at least two observations.

### Why divide sample variance by one less?

The sample mean comes from the same observations, so their differences from that mean add to zero. Once you know $n-1$ of those differences, the last is fixed. Maricopa’s statistics text calls the remaining freedom to vary the **degrees of freedom**.

The correction does more than count free deviations. Across repeated independent samples from a population with finite variance, dividing by $n$ after fitting the sample mean tends to underestimate that variance. The University of Texas at Austin’s derivation can be written as the difference between two sums.

$$
\sum_{i=1}^{n}(x_i-\bar x)^2
=
\sum_{i=1}^{n}(x_i-\mu)^2
-
n(\bar x-\mu)^2
$$

The average of the first term on the right across repeated independent samples is $n\sigma^2$. The average of the second is $\sigma^2$, since the sample mean has variance $\frac{\sigma^2}{n}$. That leaves $(n-1)\sigma^2$, so dividing by $n-1$ gives an unbiased estimator under those conditions.

## How do you calculate variance with frequencies or grouped intervals?

For a [frequency table](https://learningfolio.de5.net/math/frequency-and-frequency-tables/), multiply each squared deviation by the count of that value. This does the same calculation as expanding the table into individual observations.

Let $f_i$ be the frequency of value $x_i$. The total count is $\sum_i f_i$. For a population, calculate the weighted mean $\mu$ first, then use the population sum of squares.

$$
\mu=\frac{\sum_i f_i x_i}{\sum_i f_i}
$$

$$
\sigma^2=\frac{\sum_i f_i(x_i-\mu)^2}{\sum_i f_i}
$$

For a sample, use the weighted sample mean in the numerator and divide the result by $\sum_i f_i-1$. When the table gives intervals, use class midpoints for an **estimate** of variance. The midpoint stands in for every reading in the bin, so the result depends on how the observations are actually distributed within each class. OpenStax explains that loss of detail in its treatment of grouped frequency tables.

## What is the difference between variance and standard deviation?

Variance uses squared units. Standard deviation is $\sqrt{\sigma^2}$ for a population or $\sqrt{s^2}$ for a sample. If arrival times are in minutes, the variance uses minutes squared and the standard deviation uses minutes.

Because distances are squared, both measures respond strongly to an extreme value. For a dataset with a long tail or potential outliers, also look at the [median and range](https://learningfolio.de5.net/math/median-range-and-outliers/) and consider the interquartile range. OpenStax’s measurements of variation separate these ideas because they describe different parts of the distribution.

### What happens if you change the scale or add a constant?

Adding $b$ to each observation shifts the mean by the same amount. The deviations stay unchanged. Multiplying each observation by $a$ multiplies its deviation by $a$ and its squared deviation by $a^2$.

$$
\operatorname{Var}(aX+b)=a^2\operatorname{Var}(X)
$$

Here $X$ is the original variable and $\operatorname{Var}$ denotes its variance. To compare relative spread across measurements with positive, meaningful means, the coefficient of variation uses standard deviation divided by the mean. A mean near zero can make that ratio unstable.

## How is variance used for probability distributions?

For a random variable $X$ with mean $\mu$ and finite variance, take the expected value of its squared distance from that mean. Expanding the square also gives a useful computational identity.

$$
\operatorname{Var}(X)=E[(X-\mu)^2]=E[X^2]-\mu^2
$$

Here $E$ denotes the expectation, or probability-weighted average, and $\mu=E[X]$. The NIST handbook’s distribution gallery gives the mean and spread for several common cases.

| Distribution | What its parameters mean | Variance |
| --- | --- | --- |
| Binomial | $n$ trials with independent outcomes and success probability $p$ per trial | $np(1-p)$ |
| Poisson | $\lambda$ is the expected count over the interval | $\lambda$ |
| Continuous uniform | $a$ and $b$ are the lower and upper limits, with $a<b$ | $\frac{(b-a)^2}{12}$ |

Covariance describes how two variables vary together. Expanding the squared deviation for a sum gives

$$
\operatorname{Var}(X+Y)=\operatorname{Var}(X)+\operatorname{Var}(Y)+2\operatorname{Cov}(X,Y).
$$

Here $\operatorname{Cov}(X,Y)$ is the covariance of $X$ and $Y$. If the variables are independent and both variances are finite, the covariance is zero and their variances add. If the variables move together, leaving out the covariance can change the result.

## Examples of Variance

Work through a complete population, a sample, exact frequency counts, grouped estimates, and a change of reporting units.

### Example 1

**Find the population variance of 2, 4, 6 and 8.**

1. The mean is $\frac{2+4+6+8}{4}=5$.
2. The deviations are $-3$, $-1$, $1$ and $3$. Their squares add to $9+1+1+9=20$.
3. Divide by four to get $\sigma^2=5$.

### Example 2

**Find the sample variance of 10, 12 and 14.**

1. The mean is 12 and the squared deviations sum to $4+0+4=8$.
2. Dividing by three gives $\frac83$, the variance when you describe these three readings as the entire population.
3. This question uses the readings to estimate variance from a sample. Divide by $3-1$ to get $s^2=4$. The sample standard deviation is 2.

### Example 3

**Groups A and B contain 9, 10, 11 and 6, 10, 14 respectively. Which complete group has more spread?**

1. Both means are 10. Group A gives squared deviations $1$, $0$ and $1$.
2. Group B gives $16$, $0$ and $16$.
3. Dividing each sum by three gives variances $\frac23$ and $\frac{32}{3}$. Group B has sixteen times the variance even though both centres match.

### Example 4

**A population has one zero, two ones and one two. Find the variance from the counts.**

1. The mean is $\frac{1\times0+2\times1+1\times2}{4}=1$.
2. The frequency-weighted squared deviations total $1\times1+2\times0+1\times1=2$.
3. Divide by four to get population variance $0.5$.

### Example 5

**Estimate the sample variance for intervals 0 to under 10, 10 to under 20 and 20 to under 30, with counts 1, 2 and 1.**

1. The midpoints are 5, 15 and 25. Their frequency-weighted mean is 15.
2. The squared deviations weighted by their counts total $100+0+100=200$.
3. With four sampled observations, the estimated sample variance is $\frac{200}{3}\approx66.67$.

### Example 6

**A collection of lengths has sample variance $0.04\,\mathrm{m}^2$. What are its variance and standard deviation in centimetre units?**

1. Multiply every length by 100 to convert to centimetres.
2. Multiply the variance by $100^2$ to get $400\,\mathrm{cm}^2$.
3. The standard deviation is $\sqrt{400}=20\,\mathrm{cm}$, which also equals $0.20\,\mathrm{m}$.

## Where do variance calculations lose their meaning?

Check the target population, the measurement unit, and whether the input gives individual values or groups before choosing the equation.

### Mistake 1. Choosing the denominator by the size of the dataset

**Where it slips in**

A large survey can feel like a population because it contains many responses.

**The tempting calculation**

Dividing by the number of survey responses describes their realized spread. It does not use the standard sample estimator if the question asks about the wider population.

**The correction**

Name the group you want to describe. Use $N$ for a complete grouping and $n-1$ for the usual sample estimate from a subset.

### Mistake 2. Comparing raw variances across measurement scales

**Where it slips in**

You see two variances on the same page and rank the numbers before checking their units.

**The tempting calculation**

A variance of $400\,\mathrm{cm}^2$ appears far larger than $0.04\,\mathrm{m}^2$.

**The correction**

Convert the scales before comparing. The two values describe the same spread.

## Practice with answers

1. Treat 3, 5 and 7 as the population. Calculate the variance and standard deviation.
2. A measurement sample has variance 9. Add 12 to every observation, then double every resulting observation. What is the new variance?
3. A sample contains two observations, 4 and 10. Find the sample variance.

### Check your solutions

1. The mean is 5, so the squared deviations add to 8. The variance is $\frac83$ and the standard deviation is $\sqrt{\frac83}\approx1.63$.
2. Adding 12 leaves the variance at 9. Doubling multiplies it by four, so the new variance is 36.
3. The sample mean is 7 and the squared deviations add to 18. Divide by $2-1$ to get 18.

## Frequently Asked Questions

### Can variance be negative?

A variance built from squared deviations and a positive denominator is nonnegative. A tiny negative result from the shortcut with large floating-point values can mean the two large terms lost precision when subtracted.

### Does sample variance require a normal distribution?

The formula can be used without a normal distribution. Its unbiasedness for the population variance holds for independent draws from the same distribution with finite variance. Specific tests or confidence intervals may add distribution assumptions.

### What is the easiest way to check a variance calculation?

Check that the deviations from the mean add to zero, then verify the squared deviations and the denominator. For repeated values, a frequency table reduces the amount of arithmetic without changing the result.

## What to Remember About Variance

* Match the denominator to a complete population or a sample estimate.
* Square deviations so spread cannot cancel, then take the square root if you need the original units.
* Multiply variance by the square of a scale factor when converting measurements.
* Treat variance from grouped interval midpoints as an estimate.

## Read More

* [How the normal distribution uses variance](https://learningfolio.de5.net/math/normal-distribution/)

## Research Behind This Article

1. OpenStax, *Introductory Statistics, Measures of the Spread of the Data*. [OpenStax](https://openstax.org/books/introductory-statistics/pages/2-7-measures-of-the-spread-of-the-data).
2. National Institute of Standards and Technology, *Measures of Scale*. [NIST Engineering Statistics Handbook](https://www.itl.nist.gov/div898/handbook/eda/section3/eda356.htm).
3. Maricopa Open Digital Press, *Why Are the Variance Formulas Different?* [Introductory Statistics](https://open.maricopa.edu/haasstatistics/chapter/4-5/).
4. University of Texas at Austin, *Population and Sample Variance: A Derivation*. [UT Austin statistics notes](https://web.ma.utexas.edu/users/mks/M358KInstr/SampleSDPf.pdf).
5. OpenStax, *Principles of Data Science, Measures of Variation*. [OpenStax](https://openstax.org/books/principles-data-science/pages/3-2-measures-of-variation).
6. National Institute of Standards and Technology, *Gallery of Distributions*. [NIST Engineering Statistics Handbook](https://www.itl.nist.gov/div898/handbook/eda/section3/eda366.htm).
