Variation Formula: How to Calculate It
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This calculator works out the statistical variance of a set of numbers, which measures how spread out the values are from their average. You enter your data points, and the calculator returns the variance (and standard deviation) using the formula you choose. It handles both sample and population data, so you get the correct result for your situation.
Formula
The variance formula is the average of the squared differences from the mean. The symbol is σ² for a population and s² for a sample.
- Population variance: σ² = Σ(xᵢ − μ)² / N
- Sample variance: s² = Σ(xᵢ − x̄)² / (n − 1)
Where:
- xᵢ = each individual value in the dataset
- μ = population mean (average of all N values)
- x̄ = sample mean (average of the n sampled values)
- N = total number of values in the population
- n = number of values in the sample
- Σ = sum of all the squared differences
The only difference between the two formulas is the denominator: N for a population, n−1 for a sample. The sample formula uses n−1 (called Bessel’s correction) to give an unbiased estimate of the population variance when you only have a subset of data.
Worked Example
Using the default data values from the calculator: 4, 8, 15, 16, 23, 42. First, find the mean: (4 + 8 + 15 + 16 + 23 + 42) / 6 = 108 / 6 = 18.
Now compute each squared difference from the mean:
- (4 − 18)² = (−14)² = 196
- (8 − 18)² = (−10)² = 100
- (15 − 18)² = (−3)² = 9
- (16 − 18)² = (−2)² = 4
- (23 − 18)² = (5)² = 25
- (42 − 18)² = (24)² = 576
Sum of squared differences = 196 + 100 + 9 + 4 + 25 + 576 = 910.
For a population (N = 6): σ² = 910 / 6 = 151.67. The standard deviation is √151.67 ≈ 12.32.
For a sample (n = 6): s² = 910 / (6 − 1) = 910 / 5 = 182.00. The standard deviation is √182 ≈ 13.49.
The calculator shows these same values when you select the data type.
When to Use Which Formula
Choosing the right formula depends on whether your data is a full population or a sample.
- Population variance (σ²): Use when your dataset includes every member of the group you’re studying. For example, the test scores of all 30 students in one class.
- Sample variance (s²): Use when your data is a random subset of a larger group. For example, the heights of 50 randomly selected adults from a city of 100,000. The n−1 correction makes the sample variance a better estimate of the true population variance.
If you’re unsure, ask: “Do I have data on every single item I care about, or just a portion?” If it’s a portion, use the sample formula.
Interpreting the Result
The variance is in squared units of the original data. If your data is in meters, the variance is in square meters, which can be hard to picture. That’s why the standard deviation (the square root of variance) is often reported instead—it’s in the same units as the data.
A variance of 0 means all values are identical. A larger variance means the data points are more spread out from the mean. For example, the set {10, 10, 10} has variance 0, while {0, 10, 20} has variance 100 (population) or 100 (sample, since n=3: (100+0+100)/2=100). The variance is never negative because it’s based on squared differences.
One common misconception: variance is not the average distance from the mean. The average absolute deviation is a different measure. Variance gives more weight to outliers because the differences are squared, so a single extreme value can dramatically increase the variance.
Common Mistakes and How to Avoid Them
- Using the wrong denominator: Forgetting to subtract 1 for a sample is the most frequent error. Always check whether your data is a sample or population.
- Mixing up variance and standard deviation: Variance is the squared value; standard deviation is its square root. Report the one that makes sense for your audience.
- Forgetting to square the differences: If you sum the differences without squaring, you always get 0. That’s a quick check to catch arithmetic mistakes.
- Rounding too early: Keep full precision in intermediate steps. Round only the final result to avoid significant errors.
- Ignoring units: Variance is in squared units, so label it correctly. A variance of 25 kg² is not the same as 25 kg.
Limitations and Alternatives
Variance is sensitive to outliers because squaring amplifies extreme values. If your data has heavy outliers, consider the median absolute deviation (MAD) or the interquartile range (IQR) as more robust measures of spread. Also, variance only describes the spread around the mean; it doesn’t capture skewness or shape.
For data with different units (e.g., comparing height in cm and weight in kg), variance is not directly comparable. The coefficient of variation (standard deviation divided by the mean) is a dimensionless measure that allows such comparisons.
When dealing with grouped data (e.g., frequency tables), you can approximate variance using class midpoints, but this introduces some error. For exact calculations, use the raw data whenever possible.
Frequently Asked Questions
What is the difference between variance and standard deviation?
Variance is the average of the squared differences from the mean. Standard deviation is the square root of the variance. Standard deviation is in the same units as the original data, making it easier to interpret. For example, if data is in dollars, variance is in dollars squared, but standard deviation is in dollars.
Why do we use n−1 for sample variance?
Using n−1 (Bessel’s correction) corrects the bias in estimating the population variance from a sample. With n in the denominator, the sample variance tends to underestimate the true population variance, especially for small samples. Subtracting 1 gives a slightly larger value that is a better estimate.
Can variance be negative?
No. Variance is the average of squared differences, and squares are always non-negative. The smallest possible variance is 0, which occurs when all data points are identical.
How do I calculate variance in Excel?
In Excel, use VAR.S for a sample and VAR.P for a population. For example, =VAR.S(A1:A10) calculates the sample variance of the numbers in cells A1 through A10. The older VAR function also works for samples but is kept for compatibility.
What is the variance of a constant?
If all values are the same (e.g., 5, 5, 5), the mean is 5, and every difference is 0. Squaring 0 gives 0, so the variance is 0. This makes sense: there is no spread.
Related
Formula used
in list | Data values | 4, 8, 15, 16, 23, 42 | 0 sel type | Data type | Sample=1, Population=2 out variance | Variance | - | (type=1 ? var(list) : pvar(list)) | 2 out std_dev | Standard deviation | - | (type=1 ? sd(list) : psd(list)) | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.