Sample Variance Calculator: How to Calculate s² Step by Step
Find the sample variance and standard deviation of your data with s² = Σ(x − x̄)² / (n − 1). Live step table, shortcut formula, a 100,000-sample n − 1 simulation, and Excel, TI-84, Python and R functions.
How to calculate sample variance by hand (5 steps)
Use when your data represents a subset of a larger population. Applies Bessel's correction.
No Data Detected
Enter your numbers above to see the mean, standard deviation, variance and other statistics.
How to use this sample variance calculator
- Paste or type numeric values separated by whitespace (spaces, tabs or new lines), commas, semicolons or vertical bars (|). Use a dot for decimals and do not use thousands separators. A single column of numbers copied from Excel or Google Sheets pastes fine in this format.
- Leave the mode on Sample (n − 1). Switch to Population (N) only if your data is the whole group.
- Read s² in the highlighted box. The steps below show the mean, deviations and sum of squares. The table shows only the first 50 rows; sums use all values. “Copy steps” copies the mean, squared deviations, sum of squares, variance and SD as text. For more than 50 values, it replaces the individual squared deviations with a count summary.
How to calculate sample variance in 5 steps
Worked example with the five values 12, 15, 11, 14, 18:
- Find the mean: x̄ = 70 / 5 = 14.
- Subtract the mean from each value: -2, 1, -3, 0, 4.
- Square each deviation: 4, 1, 9, 0, 16.
- Add the squares: Σ(x − x̄)² = 30.
- Divide by n − 1: s² = 30 / 4 = 7.5. The sample standard deviation is s = √7.5 ≈ 2.7386.
| x | x − x̄ | (x − x̄)² |
|---|---|---|
| 12 | -2 | 4 |
| 15 | 1 | 1 |
| 11 | -3 | 9 |
| 14 | 0 | 0 |
| 18 | 4 | 16 |
| Σ = 70 | 0 | 30 |
Load these five values into the calculator to see the same table generated for your own data.
Sample variance formula and the shortcut formula
Definition: s² = Σ(x − x̄)² / (n − 1)
Shortcut: s² = [Σx² − (Σx)² / n] / (n − 1)
x̄ is the sample mean and n is the number of values. The shortcut (computational) formula skips the deviation column and is handy on paper or in a spreadsheet: here Σx = 70 and Σx² = 1010, so s² = [1010 − 70² / 5] / 4 = [1010 − 980] / 4 = 7.5, the same answer. With very large or very precise numbers the shortcut can lose accuracy to rounding, which is why this calculator uses the definition.
Why divide by n − 1? A 100,000-sample simulation
We drew 100,000 random samples of each size from a normal distribution with mean 50 and standard deviation 10, so the true variance is exactly 100. For every sample we computed the sum of squared deviations from the sample mean and divided it by n and by n − 1, then averaged the results.
Sample size n: 2
Average of Σ/n: 49.6
Theory (n − 1)/n × 100: 50
Average of s² = Σ/(n − 1): 99.3
Average s (true SD 10): 7.95
Σ/n below 100: 84.4%
s² below 100: 68.5%
Sample size n: 3
Average of Σ/n: 66.3
Theory (n − 1)/n × 100: 66.7
Average of s² = Σ/(n − 1): 99.4
Average s (true SD 10): 8.84
Σ/n below 100: 77.9%
s² below 100: 63.5%
Sample size n: 5
Average of Σ/n: 80.2
Theory (n − 1)/n × 100: 80
Average of s² = Σ/(n − 1): 100.3
Average s (true SD 10): 9.41
Σ/n below 100: 71.2%
s² below 100: 59.4%
Sample size n: 10
Average of Σ/n: 90.1
Theory (n − 1)/n × 100: 90
Average of s² = Σ/(n − 1): 100.2
Average s (true SD 10): 9.73
Σ/n below 100: 64.7%
s² below 100: 56.1%
Sample size n: 30
Average of Σ/n: 96.7
Theory (n − 1)/n × 100: 96.7
Average of s² = Σ/(n − 1): 100
Average s (true SD 10): 9.92
Σ/n below 100: 58.5%
s² below 100: 53.5%
- Averaged over many repeated samples of independent values, dividing by n is too small by the factor (n − 1)/n: about half the true variance at n = 2 and 80.2 instead of 100 at n = 5. The simulated averages come out close to the theoretical values.
- Dividing by n − 1 removes that bias when averaged over many repeated samples of independent values: in this simulation, the average s² is within 1% of 100 at every sample size.
- Unbiased does not mean close. The below-100 percentages come from the normal model used in this simulation. Even with n − 1, a single s² from a small sample came out below 100 in 68.5% of samples at n = 2, because a few large values pull the average up. Small samples give noisy variances whichever formula you use.
- The square root brings back a downward bias: in the normal model used in this simulation, the average s was 9.41 rather than 10 at n = 5.
Run on 2026-11-07 (UTC) with Node.js v24.10.0 and seed 20261107; download the script to reproduce these numbers. For the reasoning behind the correction, see Bessel’s correction (n − 1) explained.
Sample vs population variance: which one to use
- Use sample variance (s², n − 1) when your values are a subset and you want to describe the larger group: survey responses, lab replicates, a batch of parts pulled from production, a random sample of orders from a larger order log.
- Use population variance (σ², N) only when you have every member of the group you care about and are not generalising beyond it, such as the final grades of one class you are reporting on.
- If you are unsure, use the sample formula. It is the default in this calculator, Excel’s VAR.S, R and pandas, and the difference shrinks as n grows (5 / 4 = 1.25× at n = 5, 1.03× at n = 30).
More examples: sample vs population standard deviation. For the population formula, or to switch between both on the same data, use the variance calculator.
Sample variance in Excel, Google Sheets, TI-84, Python and R
The common trap is NumPy, whose np.var() uses the population formula unless you pass ddof=1. We checked the Python rows on 2026-11-07 with the data 4, 8, 6, 5, 7: statistics.variance, np.var(ddof=1) and pandas .var() all return 2.5, while np.var() and statistics.pvariance return 2.0.
Excel
Sample s²: =VAR.S(A2:A6)
Population σ²: =VAR.P(A2:A6)
Older =VAR() is the sample version too. Docs
Google Sheets
Sample s²: =VAR.S(A2:A6) or =VAR(A2:A6)
Population σ²: =VAR.P(A2:A6) or =VARP(A2:A6)
Same split as Excel. Docs
TI-84
Sample s²: STAT → CALC → 1-Var Stats, then square Sx
Population σ²: Square σx
Shows SDs, not variances: Sx is the sample SD.
Python statistics
Sample s²: statistics.variance(x)
Population σ²: statistics.pvariance(x)
Standard library. Docs
NumPy
Sample s²: np.var(x, ddof=1)
Population σ²: np.var(x)
Default ddof=0 is the population formula. Docs
pandas
Sample s²: df["x"].var()
Population σ²: df["x"].var(ddof=0)
Default ddof=1 is the sample formula. Docs
How outliers and units affect sample variance
Because deviations are squared, one extreme value dominates. Adding a single 40 to 12, 15, 11, 14, 18 raises the mean from 14 to 18.33, but the sample variance jumps from 7.5 to 118.67, about 16 times larger. Load the data with the outlier to see which row contributes most. Check extreme values before reporting s²: correct or remove a value that is a recording error, and if the extreme value is real, report it and consider the median and IQR alongside s².
Variance is in squared units (cm², $², points²), so it is hard to read on its own. Report the standard deviation s alongside it, which is back in the data’s units.
Sample variance FAQ
How do you find the sample variance and standard deviation?
Find the mean, subtract it from every value, square each difference, add the squares, and divide by n − 1. That gives the sample variance s²; its square root is the sample standard deviation s. For 12, 15, 11, 14, 18 the squares add up to 30, so s² = 30 / 4 = 7.5 and s = √7.5 ≈ 2.7386.
Is sample variance always larger than population variance?
For the same data, yes, unless every value is identical. Both use the same sum of squares, and dividing by n − 1 instead of n multiplies the result by n / (n − 1). For the five values above that is 5 / 4: s² = 7.5 versus σ² = 6.
Can you calculate sample variance from one value?
No. With a single value n − 1 = 0, so the formula divides by zero and the sample variance is undefined. You need at least two values; Excel’s VAR.S returns #DIV/0! in that case and R’s var() returns NA.
If s² is unbiased, is the sample standard deviation unbiased too?
No. Sample variance is unbiased when averaged over many repeated random samples of independent values from the same population (with finite variance). Taking the square root reintroduces a downward bias. In the normal model used in our simulation with a true SD of 10, the average s was 7.95 at n = 2 and 9.41 at n = 5, even though the average s² was close to 100. The bias shrinks as n grows; for small n some fields apply a c4 correction factor.
What symbol and units does sample variance use?
Sample variance is written s² (population variance is σ²). It is in squared units of the data: if the values are in centimetres, s² is in square centimetres. Take the square root to get back to the original units.
Background reading: variance explained and standard deviation vs variance.