AJ Designer

Variance Calculator

Sample variance s squared equals the sum of squared deviations from the mean divided by n minus 1.
6 values
x1
x2
x3
x4
x5
x6

Sample Variance (s²) =

182 (units²)

Sample SD (s) = 13.490738 · n = 6 · mean = 18

Show Your Work

s² = Σ(xᵢ − x̄)² / (n − 1)
x̄ = (4 + 8 + 15 + 16 + 23 + 42) / 6 = 18
Σ(xᵢ − x̄)² = 196 + 100 + 9 + 4 + 25 + 576 = 910
s² = 910 / (6 − 1) = 910 / 5
s² ≈ 182
Share:

Sample Variance (Bessel-corrected)

Use sample variance when your data is a random subset of a larger population and you want to estimate the unknown population variance. Dividing by n − 1 (Bessel's correction) compensates for the downward bias that arises from using the sample mean in place of the true mean.

s² = Σ(xᵢ − x̄)² / (n − 1)

Population Variance

Use population variance when you have measured every member of the group — no estimation, no Bessel correction. The divisor is N, the full count of items, and the result is the exact average squared deviation of the population.

σ² = Σ(xᵢ − x̄)² / N

How It Works

Variance measures how spread out a set of numbers is around their mean. Compute it in three steps: (1) find the mean x̄ by adding the values and dividing by n; (2) compute each value's deviation from the mean and square it — squaring removes the sign so positives and negatives can't cancel, and it amplifies large deviations more than small ones; (3) average those squared deviations. The average uses divisor n for population variance (σ², full data set) or n − 1 for sample variance (s², a random subset estimating a larger population). The squaring is what makes variance distinct from mean absolute deviation: it makes the math analytically tractable (derivatives work cleanly) and it weights outliers more heavily, which matches the behavior most scientific and financial applications want.

Example Problem

Find the sample variance of the data set {4, 8, 15, 16, 23, 42}. This is the canonical 'Lost' numbers example and a textbook Wolfram Alpha verification case.

  1. Compute the mean: x̄ = (4 + 8 + 15 + 16 + 23 + 42) / 6 = 108 / 6 = 18.
  2. Compute each squared deviation: (4 − 18)² = 196, (8 − 18)² = 100, (15 − 18)² = 9, (16 − 18)² = 4, (23 − 18)² = 25, (42 − 18)² = 576.
  3. Sum the squared deviations: 196 + 100 + 9 + 4 + 25 + 576 = 910.
  4. Sample variance uses divisor n − 1 = 5: s² = 910 / 5 = 182.
  5. Take the square root to get the sample standard deviation: s = √182 ≈ 13.49.
  6. Switching to population variance instead uses divisor N = 6: σ² = 910 / 6 ≈ 151.67, and σ = √(910/6) ≈ 12.32.

Sample variance is always larger than population variance for the same data because the divisor (n − 1) is smaller. The gap shrinks as n grows — by n = 100 the two differ by about 1 %, by n = 1000 by 0.1 %.

Key Concepts

Three distinctions are worth keeping straight. First, units: variance is in the squared units of the input. If your data is in meters, the variance is in m². That's the main reason standard deviation (the square root of variance) is reported in practice — it's in the same units as the data. Second, sample vs population: divide by N when your data is the full population, divide by n − 1 (Bessel's correction) when your data is a random sample meant to estimate a larger population. The Bessel correction exists because using the sample mean x̄ in place of the unknown true mean μ systematically underestimates the spread; dividing by n − 1 instead of n unbiases the estimator. Third, variance vs standard deviation: variance is the squared average deviation; SD is its square root. SD is reported when communicating spread to humans (same units as data); variance shows up in the math underneath (ANOVA, regression, error propagation, portfolio theory) because squared quantities add cleanly while square roots do not.

Applications

  • Financial risk and portfolio theory — variance of asset returns is the central measure of volatility in Markowitz mean-variance optimization, the Sharpe ratio, and the capital asset pricing model.
  • Analysis of variance (ANOVA) — partitions total variance into between-group and within-group components to test whether group means differ significantly.
  • Quality control — process capability indices (Cp, Cpk) compare the variance of a manufacturing process to the tolerance band; lower variance means more consistent parts.
  • Signal processing — the variance of a signal estimates its power, and noise variance sets the floor in signal-to-noise ratio calculations.
  • Evolutionary biology and quantitative genetics — heritability is defined as the ratio of genetic variance to total phenotypic variance.
  • Experimental science — variance of replicate measurements quantifies measurement uncertainty and propagates through derived quantities via error propagation rules.

Common Mistakes

  • Forgetting to square the deviations — averaging the raw (xᵢ − x̄) values always gives zero (positives and negatives cancel by definition of the mean). Averaging the absolute deviations gives the mean absolute deviation, not variance.
  • Using divisor n when you wanted Bessel's sample correction — for any meaningful sample (n ≥ 2) this slightly underestimates the population variance. Use n − 1 when your data is a sample, N only when it's the full population.
  • Reporting variance without noting the units are squared — a variance of 25 m² is very different from an SD of 5 m. If you mean the latter, take the square root.
  • Computing variance by subtracting two large numbers — the textbook 'sum of squares minus (sum)²/n' shortcut can lose precision catastrophically when the mean is large compared to the spread. The two-pass method used here (compute the mean first, then sum squared deviations) is numerically stable.
  • Treating variance as additive without checking independence — Var(X + Y) = Var(X) + Var(Y) only when X and Y are uncorrelated. For correlated variables you must include the covariance term.
  • Mixing weighted and unweighted variance — if data points have different weights (frequencies, importance), use the weighted-variance formula. This calculator computes the unweighted form, where every value counts equally.

Frequently Asked Questions

What is variance?

Variance is a statistical measure of how spread out a set of numbers is around their mean. It's defined as the average of the squared deviations from the mean — large variance means values are far from the mean on average, small variance means they cluster tightly around it. Variance is always non-negative and is zero only when every value equals the mean.

How do you calculate variance?

First compute the mean by adding the values and dividing by the count. Then for each value, subtract the mean and square the result. Sum those squared deviations and divide — by n for population variance (σ²) or by n − 1 for sample variance (s²). The square root of the variance is the standard deviation.

What's the difference between variance and standard deviation?

Standard deviation is the square root of variance. They measure the same thing — spread around the mean — but in different units. If your data is in meters, the variance is in m² (meters squared) and the standard deviation is in meters. Standard deviation is preferred when communicating spread to humans because it's in the original units; variance shows up in the math because squared quantities add cleanly across independent sources.

Why is variance always positive?

Because every deviation is squared before averaging. Squaring turns negative deviations into positive numbers, so the sum can never go below zero. Variance is exactly zero only when every value in the data set equals the mean — i.e., the data has no spread at all.

When do I use sample variance vs population variance?

Use sample variance (divide by n − 1) when your data is a random subset meant to estimate the spread of a larger population. Use population variance (divide by N) when your data is the entire population and you don't need to estimate anything beyond it. The n − 1 divisor — called Bessel's correction — compensates for the bias of using the sample mean in place of the unknown true mean. For large n the two values are nearly identical; for small n the difference matters.

What are the units of variance?

Variance is in the squared units of the input data. If the data is in meters, the variance is in m² (meters squared). If the data is in dollars, the variance is in dollars squared. This is one reason standard deviation (the square root of variance) is more commonly reported — it shares the same units as the original data, which makes it easier to interpret.

How is variance related to standard deviation?

Standard deviation is the positive square root of variance: σ = √σ² and s = √s². If you know one, you know the other. Variance is the primitive quantity in the math (it adds cleanly for independent variables, partitions naturally in ANOVA, and has clean derivatives for optimization); standard deviation is the human-friendly quantity for reporting because it's in the original units.

Why do we square the deviations instead of taking absolute values?

Two reasons. Mathematically, squaring is differentiable everywhere while the absolute value isn't — which matters for least-squares regression, gradient methods, and most of mathematical statistics. Statistically, squaring weights large deviations more than small ones, which matches what scientific and financial applications usually want: an outlier should affect a spread measure more than a near-mean point. The version that averages absolute deviations is called the mean absolute deviation (MAD); it's used occasionally but variance and standard deviation dominate practice.

Reference: Standard textbook definitions per the NIST/SEMATECH e-Handbook of Statistical Methods (§1.3.5.1 Measures of Location and Variability) and Wolfram MathWorld's articles on Variance and Sample Variance. Canonical example {4, 8, 15, 16, 23, 42} verified against Wolfram Alpha (sample variance = 182, population variance = 910/6).

Variance Formulas

Variance is the average squared deviation from the mean. Two forms exist depending on whether your data is a sample or the full population:

x̄ = Σxᵢ / n
σ² = Σ(xᵢ − x̄)² / N
s² = Σ(xᵢ − x̄)² / (n − 1)

Where:

  • xᵢ — each value in the data set
  • — the arithmetic mean of the data
  • n, N — sample size (n) or full population size (N)
  • σ² — population variance (divide by N)
  • — sample variance (divide by n − 1, Bessel's correction)

Squaring the deviations is what makes variance distinct from a simple average: it forces every contribution to be non-negative (so positives and negatives can't cancel) and it amplifies outliers more than near-mean points. The result is always in the squared units of the input — m² if your data is in meters, dollars² if it's in dollars — which is the main reason standard deviation (the square root of variance) is what most reports show to humans.

Worked Examples

Statistics — Classroom Test Scores

How do you find the sample variance of six exam scores?

A small class scores 72, 78, 85, 88, 92, 95 on a midterm. Treat the class as a sample of all possible students and find the sample variance.

  • Sum = 510, n = 6 → x̄ = 510 / 6 = 85.
  • Squared deviations: (72−85)² = 169, (78−85)² = 49, (85−85)² = 0, (88−85)² = 9, (92−85)² = 49, (95−85)² = 100.
  • Σ(xᵢ − x̄)² = 169 + 49 + 0 + 9 + 49 + 100 = 376.
  • Sample variance: s² = 376 / (6 − 1) = 376 / 5 = 75.2 (points²).
  • Sample standard deviation: s = √75.2 ≈ 8.67 points.

Sample variance = 75.2 points², SD ≈ 8.67 points.

The variance is in points² — squared test points. The standard deviation, in plain points, is what you would report on a grade-distribution summary.

Finance — Monthly Stock Returns

How do you measure the population variance of monthly returns?

A stock's monthly returns over six months (%) are: 2.1, −1.3, 3.4, 0.8, −0.5, 1.9. Treat this six-month window as the complete population for the period and compute the population variance.

  • Sum = 6.4, N = 6 → x̄ ≈ 1.0667 %.
  • Squared deviations sum to Σ(xᵢ − x̄)² ≈ 15.7333 (%²).
  • Population variance: σ² = 15.7333 / 6 ≈ 2.622 (%²).
  • Population standard deviation: σ = √2.622 ≈ 1.619 %.

Population variance ≈ 2.62 %², SD ≈ 1.62 %.

Annualized monthly variance ≈ 2.62 × 12 ≈ 31.5 %² → annualized SD ≈ 5.6 %. Variance scales with the time horizon; standard deviation scales with the square root of time.

Quality Control — CNC Machined Parts

Is the population variance of part diameters tight enough for the tolerance?

A CNC machine cuts shafts with a target diameter of 25.00 mm. Eight consecutive parts measure (mm): 24.98, 25.02, 25.00, 24.99, 25.01, 25.00, 24.97, 25.03. Treat these eight as the complete population for this run and compute the population variance.

  • Sum = 200.00, N = 8 → x̄ = 25.00 mm.
  • Squared deviations: 0.0004, 0.0004, 0, 0.0001, 0.0001, 0, 0.0009, 0.0009.
  • Σ(xᵢ − x̄)² = 0.0028 mm².
  • Population variance: σ² = 0.0028 / 8 = 0.00035 mm².
  • Population SD: σ = √0.00035 ≈ 0.0187 mm.

Population variance = 0.00035 mm², SD ≈ 0.0187 mm.

For a tolerance of ±0.05 mm, Cpk ≈ 0.05 / (3σ) ≈ 0.89 — borderline capable. A higher Cpk requires tightening the process to reduce variance.

Related Calculators

Related Sites