Variance Calculator

Calculate population and sample variance from a dataset. See the mean, deviations table, standard deviation, and coefficient of variation step by step.

Calculate both population and sample variance from any dataset. See the mean, every value's deviation from the mean, squared deviations, standard deviation, coefficient of variation, and range - all with step-by-step working.

Ad
Ad

About Variance Calculator

What Is Variance?

Variance measures how spread out a dataset is. It is the average of the squared differences between each value and the mean:

Population variance: σ² = Σ(xᵢ - μ)² / N

Sample variance: s² = Σ(xᵢ - x̄)² / (n - 1)

A variance of 0 means all values are identical. Larger variance means more spread.

Worked Example

Dataset: 4, 7, 2, 9, 8

  1. Mean = (4 + 7 + 2 + 9 + 8) / 5 = 30 / 5 = 6
  2. Calculate deviations and squared deviations:
Value (xᵢ)Deviation (xᵢ - x̄)Squared (xᵢ - x̄)²
4-24
7+11
2-416
9+39
8+24
Sum034
  1. Population variance: σ² = 34 / 5 = 6.8
  2. Sample variance: s² = 34 / 4 = 8.5
  3. Population SD: σ = √6.8 = 2.608
  4. Sample SD: s = √8.5 = 2.915

Sample vs Population Variance

Population Variance (σ²)Sample Variance (s²)
Divides byN (total count)n - 1 (Bessel's correction)
Use whenYou have data for the entire populationYou have a sample from a larger population
BiasExact for the populationUnbiased estimator of population variance
Symbolσ²
ExampleTest scores of every student in a classTest scores of 30 students from a school of 500

Why Divide by n-1? (Bessel's Correction)

When you calculate variance from a sample, using the sample mean instead of the true population mean causes the sum of squared deviations to be systematically too small. Dividing by n-1 instead of n corrects this bias.

Intuition: once you know the sample mean and n-1 of the values, the last value is determined (it has to make the deviations sum to zero). So you really only have n-1 independent pieces of information - the degrees of freedom.

For large samples, the difference between dividing by n and n-1 is negligible. For small samples (n < 30), it matters significantly.

Coefficient of Variation (CV)

The coefficient of variation normalises the standard deviation relative to the mean:

CV = (s / |x̄|) × 100%

This lets you compare variability between datasets with different units or scales:

DatasetMeanSDCVInterpretation
Heights (cm)17084.7%Low variability
Weights (kg)751216.0%Moderate variability
Incomes (£)35,00015,00042.9%High variability

Without CV, you cannot tell whether a standard deviation of 8 (heights) or 12 (weights) represents more relative spread. CV shows that weights are actually more variable relative to their mean.

Variance vs Standard Deviation

VarianceStandard Deviation
FormulaAverage of squared deviationsSquare root of variance
UnitsSquared units (cm², £², etc.)Same units as the data
InterpretationHarder to interpret directlyRoughly "average distance from the mean"
Mathematical useEasier to work with in formulasEasier to explain and visualise
Additive propertyVariances of independent variables addStandard deviations do not add directly

Variance is preferred in mathematical derivations because it has nice algebraic properties (like additivity for independent variables). Standard deviation is preferred for reporting because it is in the original units.

Properties of Variance

  • Always non-negative: Variance ≥ 0, since it is a sum of squares
  • Zero only if all values are equal: Var = 0 means no spread at all
  • Adding a constant: Var(X + c) = Var(X). Shifting data does not change its spread
  • Multiplying by a constant: Var(cX) = c² × Var(X). Scaling data scales variance by the square
  • Sum of independent variables: Var(X + Y) = Var(X) + Var(Y) when X and Y are independent

How Variance Is Used in the Real World

Variance is not just a textbook exercise - it drives decisions in finance, quality control, science, and machine learning. In portfolio theory, Harry Markowitz's 1952 paper "Portfolio Selection" (Journal of Finance) used variance as the definition of investment risk, the foundation of Modern Portfolio Theory still taught today. In manufacturing, Six Sigma quality programmes target a process capability where defects sit more than six standard deviations from the specification limit, corresponding to 3.4 defects per million opportunities.

In clinical trials, the US Food and Drug Administration requires variance estimates when calculating sample sizes for drug approval studies - under-powered trials with too much variability fail to detect real effects. In education research, the Programme for International Student Assessment (PISA) reports both mean scores and variance, because a country with a mean of 500 and low variance is performing very differently from one with a mean of 500 and huge spread between top and bottom students.

What Is a "High" or "Low" Variance?

There is no absolute cut-off - variance depends entirely on the units and typical values of your data. A variance of 100 is tiny for annual household incomes (in pounds) but enormous for adult heights (in centimetres). That is exactly why the coefficient of variation exists: it divides the spread by the mean so you can compare apples with oranges.

As a rough guide across many practical domains, a CV under 10% is considered low variability (tightly controlled process or measurement), 10-30% is moderate (normal real-world variation), and above 30% is high variability (worth investigating whether subgroups or outliers are driving it). In finance, the annualised standard deviation of returns - volatility - is typically 10-20% for developed-market equities and 4-8% for investment-grade bonds, per data from NYU Stern's annual updates on asset class returns.

Common Mistakes When Calculating Variance

  • Using population variance on a sample. The most common error in student coursework. If your data is a sample and you want to estimate the underlying population, divide by n-1, not n. Excel has two functions for exactly this reason: VAR.S for samples and VAR.P for populations.
  • Ignoring outliers. Variance is very sensitive to extreme values because it squares the deviations. A single typo (entering 1000 instead of 100) can multiply variance by a factor of ten. Always plot the data or inspect the squared deviations table before trusting the result.
  • Comparing variance across different units. You cannot compare the variance of heights in centimetres with the variance of weights in kilograms. Convert both to a common scale or use the coefficient of variation.
  • Treating variance as "average distance from the mean". That description fits standard deviation, not variance. Variance is in squared units and does not correspond to any physical distance. If you want an intuitive spread measure in the original units, take the square root - the standard deviation calculator handles that directly.
  • Forgetting that variance is not additive for dependent variables. The property Var(X + Y) = Var(X) + Var(Y) only holds when X and Y are independent. If they are correlated, you also need to add 2 × Cov(X, Y). This trips people up in portfolio analysis where stocks are rarely independent.

Variance in Probability Theory

Beyond datasets, variance is a fundamental property of probability distributions. For a discrete random variable X with possible values xᵢ and probabilities pᵢ, the population variance is E[(X - μ)²] = Σ (xᵢ - μ)² × pᵢ. For continuous distributions, the sum becomes an integral.

Some common distributions and their variances:

DistributionParametersVarianceExample use
Normalμ, σ²σ²Heights, measurement errors
Binomialn, pnp(1 - p)Coin flips, survey yes/no
PoissonλλRare event counts (calls per hour)
Uniforma, b(b - a)² / 12Random number generators
Exponentialλ1 / λ²Time between events

Notice that for the Poisson distribution the mean equals the variance - that is a distinctive property used by statisticians to check whether count data is genuinely Poisson or "over-dispersed" (variance larger than the mean, common in real-world count data like insurance claims).

Worked Example: Two Shops Comparison

Say two coffee shops record daily sales (in cups) across five days. Shop A: 120, 130, 125, 128, 122. Shop B: 80, 170, 90, 160, 125. Both have the same mean of 125 cups per day, but their variance tells very different stories.

  1. Shop A deviations from 125: -5, +5, 0, +3, -3. Squared: 25, 25, 0, 9, 9. Sum = 68. Sample variance = 68 / 4 = 17. SD ≈ 4.12 cups.
  2. Shop B deviations from 125: -45, +45, -35, +35, 0. Squared: 2025, 2025, 1225, 1225, 0. Sum = 6500. Sample variance = 6500 / 4 = 1625. SD ≈ 40.31 cups.
  3. Same mean, nearly 100× the variance. Shop B's inventory manager has a much harder planning problem.

For comparing full distributions (not just spread), the z-score calculator shows where individual values sit within the distribution. For the probability of specific ranges, the probability calculator uses variance as an input.

Degrees of Freedom Explained

Dividing by n-1 when calculating sample variance is called Bessel's correction, named after German mathematician Friedrich Bessel who derived the correction in the 19th century. The intuition comes from degrees of freedom.

When you calculate the sample mean from your data, you have used up one piece of information. The deviations (xᵢ - x̄) must sum to zero by construction - once you know n-1 of them, the last is determined. So only n-1 deviations are truly free to vary, and dividing by n-1 produces an unbiased estimator of the population variance.

Without the correction (dividing by n), sample variance systematically underestimates population variance. The bias is approximately σ² / n, which is large for small samples and negligible for large ones. For n = 5, the correction increases variance by 25%. For n = 100, it increases by about 1%. This is why statisticians historically worried far more about small-sample corrections than we need to in the big-data era.

Sources

All calculations run in your browser. No data is sent to any server.

Frequently Asked Questions

What is the difference between sample and population variance?

Population variance divides the sum of squared deviations by n (the total count). Sample variance divides by n-1 instead, which corrects for the bias that occurs when estimating from a sample. Use sample variance when your data is a subset of a larger population.

What is variance in statistics?

Variance measures how spread out a dataset is from its mean. It is the average of the squared differences between each data point and the mean. A higher variance means more spread in the data.

What is the coefficient of variation?

The coefficient of variation (CV) is the sample standard deviation divided by the absolute mean, expressed as a percentage. It lets you compare variability between datasets with different units or means.

Why do we square the deviations?

Squaring ensures all deviations are positive (negative differences don't cancel out positive ones). It also gives more weight to larger deviations. The downside is the result is in squared units, which is why standard deviation (the square root) is often preferred.

How is variance related to standard deviation?

Standard deviation is the square root of variance. Variance is in squared units, while standard deviation returns to the original units. Both measure spread, but standard deviation is easier to interpret.

Link to this tool

Copy this HTML to link to this tool from your website or blog.

<a href="https://toolboxkit.io/tools/variance-calculator/" title="Variance Calculator - Free Online Tool">Try Variance Calculator on ToolboxKit.io</a>