Variance Calculator

The variance calculator is a great educational tool that teaches you how to calculate the variance of a dataset. The calculator works for both population and sample datasets.

Read on to learn:

What is the definition of variance?

Variance is a measure of the variability of the values in a dataset.

A high variance indicates that a dataset is more spread out.

A low variance indicates that the data is more tightly clustered around the mean, or less spread out.

Learning how to calculate variance is a key step in computing standard deviation. These two measures are the foundation to calculating relative standard deviation and confidence intervals.

Not sure about the two last notions we used? Discover them by visiting our dedicated tools: the relative standard deviation calculator and the confidence interval calculator!

Variance formula

Variance (denoted as σ 2 ) is defined as the average squared difference from the mean for all data points. We write it as:

σ 2 = 1 N ∑ i = 1 N ( x i − μ ) 2 \sigma^2 = \frac 1N \sum_^N(x_i - \mu)^2 σ 2 = N 1 ​ ∑ i = 1 N ​ ( x i ​ − μ ) 2

You can calculate variance in three steps:

  1. Find the difference from the mean for each point. Use the formula: x i − μ x_i - \mu x i ​ − μ
  2. Square the difference from the mean for each point: ( x i − μ ) 2 (x_i - \mu)^2 ( x i ​ − μ ) 2
  3. Find the average of the squared differences from the mean which you found in step 2: 1 N ∑ i = 1 N ( x i − μ ) 2 \frac 1N \sum_^N(x_i - \mu)^2 N 1 ​ ∑ i = 1 N ​ ( x i ​ − μ ) 2 This is the population variance formula. Note, that this formula is slightly different for sample data (see the next section) and for grouped data. In fact, for the latter, we have the dedicated grouped data variance calculator.

Population vs. sample variance formula

In many scientific experiments, only a sample of the population is measured for practical reasons. This sample allows us to make inferences about the population. However, when we use sample data to estimate the variance of a population, the regular variance formula, σ 2 = 1 N ∑ i = 1 N ( x i − μ ) 2 \sigma^2 = \frac 1N \sum_^N(x_i - \mu)^2 σ 2 = N 1 ​ ∑ i = 1 N ​ ( x i ​ − μ ) 2 , underestimates the variance of the population.

To avoid underestimating the variance of a population (and consequently, the standard deviation), we replace N with N - 1 in the variance formula when sample data is used. This adjustment is known as Bessels' correction.

The sample variance formula becomes:

s 2 = 1 N − 1 ∑ i = 1 N ( x i − x ˉ ) 2 s^2 = \frac 1 \sum_^N(x_i - \bar)^2 s 2 = N − 1 1 ​ ∑ i = 1 N ​ ( x i ​ − x ˉ ) 2

Example calculation

Let's calculate variance of eight students' quiz scores: 5, 5, 5, 7, 8, 8, 9, 9. Follow these steps:

1. Calculate the mean

To calculate the mean (x̄), divide the sum of all numbers by the number of data points:

x ‾ = 1 8 ( 5 + 5 + 5 + 7 + 8 + 8 + 9 + 9 ) \overline = \frac 18 (5 + 5 + 5 + 7 + 8 + 8 + 9 + 9) x = 8 1 ​ ( 5 + 5 + 5 + 7 + 8 + 8 + 9 + 9 )

x ‾ = 7 \overline = 7 x = 7

2. Calculate the difference from the mean, and the squared differences from the mean

Now that we know the mean is 7, we will calculate the difference from the mean using the formula:

x i − x ‾ x_i - \overline x i ​ − x

The first point has a value of 5, so the difference from the mean is 5 - 7 = -2.

The squared difference (or "squared deviation") from the mean is simply the square of the previous step:

( x i − x ‾ ) 2 (x_i - \overline)^2 ( x i ​ − x ) 2

so, the squared deviation would be:

( 5 − 7 ) 2 = ( − 2 ) 2 = 4 (5 - 7)^2 = (-2)^2= 4 ( 5 − 7 ) 2 = ( − 2 ) 2 = 4

We show the calculated squared deviations from the mean for all quiz scores in the table below. The "Deviation" column is the score minus 7, and the "Deviation 2 " column is the previous column squared.