Sample Variance Formula - Definition, Steps, Examples

#Formula
TL;DR
The sample variance formula divides the sum of squared deviations from the mean by n−1n-1. This article covers the variable key, six worked examples, and why the denominator is not nn.
BT
Bhanzu TeamLast updated on November 4, 20268 min read

Key Points

  • The sample variance formula is s2=∑(xi−xˉ)2n−1s^2 = \frac{\sum (x_i - \bar{x})^2}{n-1}, dividing the summed squared deviations by one less than the number of observations.

  • The NIST e-Handbook of Statistical Methods prints the sample variance with N−1N-1 in the denominator, not NN, in its Measures of Scale section.

  • Dividing by n−1n-1 rather than nn corrects a downward bias, because deviations are measured from the sample mean rather than the unknown population mean.

  • Sample variance is always reported in squared units, so a variance of 9 on a set of heights in centimetres is 9 square centimetres.

  • Taking the square root of the sample variance gives the sample standard deviation, which returns the spread to the original units.

What Is the Sample Variance Formula?

The sample variance formula measures how far a set of sample values spreads from their own mean, and it is written

s2=∑i=1n(xi−xˉ)2n−1s^2 = \frac{\sum_{i=1}^{n} (x_i - \bar{x})^2}{n-1}

where xˉ\bar{x} is the sample mean and nn is the number of observations. The NIST/SEMATECH e-Handbook of Statistical Methods prints this same formula with N−1N-1 in the denominator.

The Full Definition

Variance answers a narrow question: take each value's distance from the mean, square those distances, and average them. Squaring matters because raw deviations from the mean always sum to zero, so without it every data set would appear to have no spread at all.

The sample version differs from the population version in one place only, the denominator. That single change makes s2s^2 an unbiased estimate of the population variance it stands in for, and everything else about the calculation is identical.

Why the Denominator Is n Minus 1

The sample mean is computed from the same data whose spread is being measured, and that is the problem. It sits, by construction, at the point making the sum of squared deviations as small as it can possibly be.

So deviations measured from the sample mean run systematically a little too small against deviations from the true population mean, and dividing by nn would carry that understatement into the answer. Reducing the denominator to n−1n-1 inflates the result by just enough to cancel the bias on average.

The quantity n−1n-1 is the degrees of freedom: once the mean is fixed, only n−1n-1 deviations vary freely, because the last is forced by their summing to zero.

Variable Key

Symbol

Meaning

Unit or type

Notes

s2s^2

sample variance

squared units of xx

the quantity being computed

xix_i

the iith observation

same units as the data

one value from the sample

xˉ\bar{x}

sample mean

same units as the data

xˉ=∑xin\bar{x} = \frac{\sum x_i}{n}

nn

sample size

count

the number of observations

n−1n-1

degrees of freedom

count

the divisor, not nn

∑\sum

summation over all ii

operator

runs from i=1i=1 to i=ni=n

Examples of the Sample Variance Formula

Example 1

Find the sample variance of 4, 6, 8.

The mean is xˉ=4+6+83=6\bar{x} = \frac{4+6+8}{3} = 6. The deviations are −2,0,2-2, 0, 2:

∑(xi−xˉ)2=4+0+4=8\sum (x_i - \bar{x})^2 = 4 + 0 + 4 = 8 s2=83−1=4s^2 = \frac{8}{3-1} = 4

Final answer: s2=4s^2 = 4

Example 2

Find the sample variance of 2, 4, 4, 4, 5, 5, 7, 9 by dividing by n.

Dividing by the number of observations is what "average" means everywhere else in arithmetic, so nn is the natural choice. Try it.

The mean is xˉ=408=5\bar{x} = \frac{40}{8} = 5, and the squared deviations are 9,1,1,1,0,0,4,169, 1, 1, 1, 0, 0, 4, 16, summing to 32:

328=4\frac{32}{8} = 4

That gives 4. But this is a sample standing in for a larger population, and the deviations were measured from the sample's own mean, which always sits where the squared total is smallest. So 4 understates the population spread.

The correction is to divide by n−1n-1:

s2=328−1=327≈4.571s^2 = \frac{32}{8-1} = \frac{32}{7} \approx 4.571

Final answer: s2≈4.571s^2 \approx 4.571

The two answers differ by about 14 per cent here. On a sample of 100 the gap would be about 1 per cent, which is why the correction matters most on small samples.

Example 3

A sample of five test scores is 70, 75, 80, 85, 90. Find the sample variance.

The mean is xˉ=4005=80\bar{x} = \frac{400}{5} = 80, and the deviations are −10,−5,0,5,10-10, -5, 0, 5, 10:

∑(xi−xˉ)2=100+25+0+25+100=250\sum (x_i - \bar{x})^2 = 100 + 25 + 0 + 25 + 100 = 250 s2=2505−1=62.5s^2 = \frac{250}{5-1} = 62.5

Final answer: s2=62.5s^2 = 62.5 squared marks

Example 4

Two samples have the same mean. Sample A is 49, 50, 51 and sample B is 20, 50, 80. Compare their sample variances.

Both means are 50. For A the squared deviations are 1,0,11, 0, 1, and for B they are 900,0,900900, 0, 900:

sA2=22=1,sB2=18002=900s_A^2 = \frac{2}{2} = 1, \qquad s_B^2 = \frac{1800}{2} = 900

Final answer: sA2=1s_A^2 = 1 and sB2=900s_B^2 = 900

Equal means tell you nothing about spread, which is the gap variance exists to fill.

Example 5

A sample of four measurements in centimetres is 12.1, 12.4, 12.2, 12.5. Find the sample variance, keeping four decimal places.

The mean is xˉ=49.24=12.3\bar{x} = \frac{49.2}{4} = 12.3, and the deviations are −0.2,0.1,−0.1,0.2-0.2, 0.1, -0.1, 0.2:

∑(xi−xˉ)2=0.04+0.01+0.01+0.04=0.10\sum (x_i - \bar{x})^2 = 0.04 + 0.01 + 0.01 + 0.04 = 0.10 s2=0.104−1=0.0333s^2 = \frac{0.10}{4-1} = 0.0333

Final answer: s2≈0.0333s^2 \approx 0.0333 square centimetres

The unit is square centimetres, which has no physical meaning as a length. That is why the standard deviation, about 0.18 cm here, is usually reported instead.

Don't Confuse This With the Population Variance or the Standard Deviation

Quantity

Symbol

Formula

When to use

Sample variance

s2s^2

∑(xi−xˉ)2n−1\frac{\sum (x_i - \bar{x})^2}{n-1}

Data is a sample from a larger population

Population variance

σ2\sigma^2

∑(xi−μ)2N\frac{\sum (x_i - \mu)^2}{N}

Data is the entire population

Sample standard deviation

ss

∑(xi−xˉ)2n−1\sqrt{\frac{\sum (x_i - \bar{x})^2}{n-1}}

You need the spread in original units

Mean deviation

∑∣xi−xˉ∣n\frac{\sum \lvert x_i - \bar{x} \rvert}{n}

You want absolute, not squared, distances

The decision between s2s^2 and σ2\sigma^2 is about what the data represents, not about its size. Twenty thousand values are still a sample if drawn from something larger, and five values are a population if those five are all that exist.

Where Do Students Trip Up on Sample Variance?

Mistake 1: Dividing by n instead of n minus 1

Where it slips in: Every other average in school divides by the count, so nn is the reflex, and calculators often offer both without labelling which is which.

Don't do this: s2=∑(xi−xˉ)2ns^2 = \frac{\sum (x_i - \bar{x})^2}{n} for sample data.

The correct way: s2=∑(xi−xˉ)2n−1s^2 = \frac{\sum (x_i - \bar{x})^2}{n-1}. Ask first whether the data is a sample or the whole population, and let that choose the denominator.

Students who write the denominator before computing anything else make this error far less often, because the choice gets made deliberately rather than at the end when attention has moved on. On a calculator, the sample version is usually the key marked ss or σn−1\sigma_{n-1}.

Mistake 2: Forgetting to square the deviations

Where it slips in: The subtraction is the visible work, so the squaring step gets skipped when the arithmetic is done mentally.

Don't do this: ∑(xi−xˉ)n−1\frac{\sum (x_i - \bar{x})}{n-1}, whose numerator is always zero.

The correct way: Square each deviation before summing. A numerator of zero on data that visibly varies is the signature of this slip.

Mistake 3: Reporting variance in the original units

Where it slips in: The answer is a number and the data had units, so the units get carried across unchanged.

Don't do this: Describe a variance of 62.5 as 62.5 marks.

The correct way: Variance is in squared units, so it is 62.5 squared marks. If the original units are wanted, take the square root and report the standard deviation instead.

Key Takeaways

  • The sample variance formula is s2=∑(xi−xˉ)2n−1s^2 = \frac{\sum (x_i - \bar{x})^2}{n-1}, the summed squared deviations over the degrees of freedom.

  • The n−1n-1 divisor exists because deviations taken from the sample mean understate the true spread, and it corrects that bias.

  • Variance is always non-negative and always in squared units, which is why the standard deviation is usually reported instead.

  • Choosing between n−1n-1 and NN depends on whether the data is a sample or an entire population, not on how much data there is.

  • To work through spread and dispersion with a teacher, explore a high school math tutor or math classes online.

A Practical Next Step

Find the sample variance of 3, 7, 7, 19. Then compute it again dividing by nn instead, and note how much smaller the second answer is on a sample this small.

Want a live Bhanzu trainer to walk through more statistics problems? Book a free demo class.

Read More

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is the sample variance formula?
s2=∑(xi−xˉ)2n−1s^2 = \frac{\sum (x_i - \bar{x})^2}{n-1}. Subtract the mean from each value, square the results, add them up, then divide by one less than the number of observations.
Why does the sample variance formula divide by n minus 1?
Because the deviations are measured from the sample mean, which always sits at the point minimising the sum of squares. That makes the squared total slightly too small, and dividing by n−1n-1 instead of nn compensates on average. The quantity n−1n-1 is the degrees of freedom.
Can sample variance be negative?
No. It is a sum of squared values divided by a positive number, so the smallest it can be is zero, which happens only when every observation is identical.
What is the difference between sample variance and population variance?
The denominator. Sample variance divides by n−1n-1 and population variance divides by NN.
How do I get the standard deviation from the sample variance?
Take the square root. The sample standard deviation formula is exactly s=s2s = \sqrt{s^2}.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →