|Sample variance (s²):||0|
|Standard deviation (s):||0|
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:
- The definition of variance in statistics;
- The variance formula;
- Examples of variance calculations; and
- A quick method to calculate variance by hand.
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.
Variance (denoted as σ2) is defined as the average squared difference from the mean for all data points. We write it as:
σ2 = ∑(xi - μ)2 / N
- σ2 is the variance;
- μ is the mean; and
- xᵢ represents the ith data point out of N total data points.
You can calculate variance in three steps:
Find the difference from the mean for each point. Use the formula:
xi - μ
Square the difference from the mean for each point:
(xi - μ)2
Find the average of the squared differences from the mean which you found in step 2:
∑(xi - μ)2 / N.
This is the population variance formula. Note, that this formula is slightly different for sample data (see the next section).
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 = ∑(xi - μ)2 / N, underestimates the variance of the population.
To avoid underestimating the variance of a population (and consequently, the standard deviation), we replace
N - 1 in the variance formula when sample data is used. This adjustment is known as Bessels' correction.
The sample variance formula becomes:
s2 = ∑(xi - x̄)2 / (N - 1)
- s2 is the estimate of variance;
- x̄ (pronounced as "x-bar") is the sample mean; and
- xi is the iith data point out of N total data points.
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̄ = (5 + 5 + 5 + 7 + 8 + 8 + 9 + 9) / 8
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:
xi - 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:
(xi - x̄)2
so, the squared deviation would be:
(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 from the mean" column is the score minus 7, and the "Squared deviation" column is the previous column squared.
|Score||Deviation from the mean||Squared deviation|
3. Calculate the variance and standard deviation
Next, we use the squared deviations from the mean we found in step 2 in the variance equation:
σ2 = ∑(xi - x̄)2 / N
σ2 = (4 + 4 + 4 + 0 + 1 + 1 + 4 + 4) / 8
σ2 = 2.75
The quiz scores' variance was 2.75.
Note, that if we used sample data to estimate the variance of a population, we would use the sample variance equation instead:
s2 = ∑(xi - x̄)2 / (N - 1)
Now that you know how to find variance, try calculating it yourself, then check your answer using our calculator!
How to calculate variance by hand?
If you are calculating variance with a handheld calculator, there is an easier formula you should use. This alternative formula is mathematically equivalent, but easier to type into a calculator.
The easy-to-type formula for variance (for population data) is:
σ2 = ( ∑(xi2) - (∑xi)2/N ) / N
The easy-to-type formula for sample variance is:
s2 = ( ∑(xi2) - (∑xi)2/N ) / (N - 1)
For example, with a sample dataset of 1, 2, 4, 6, the calculation for sample variance would be:
s2 = (( 12 + 22 + 42 + 62) - (1 + 2 + 4 + 6)2/4 ) / (4 - 1)
= (57 - (169 / 4)) / 3 = 4.9167
Try it yourself, then check your answer with our variance calculator!
Summary of variables and equations
Table 1. Variables for population data
|Number of observations||N|
|Population mean||μ||∑(xi) / N|
|Sum of squares||SS||∑(xi - μ)2|
|Variance||σ2||SS / N|
Table 2. Variables for sample data
|Sample mean||x̄||∑(xi) / N|
|Sum of squares||SS||∑(xi - x̄)2|
|Sample variance||s2||SS / (N - 1)|