Variance Calculator
Run a calculation in the Sample or Population tab first, then return here to see the full step-by-step solution.
No data yet — enter values in the Sample or Population tab first.
What Is Variance?
Variance is a measure of how spread out a set of values is, calculated as the average of the squared differences between each value and the mean. When you subtract each value from the mean and sum those differences directly, the result is always zero — positive and negative deviations cancel each other out. Squaring each deviation before summing solves three problems at once: every value stays positive, nothing cancels, and extreme values get weighted more heavily than values close to the mean.
A simple example shows why squaring matters. For the dataset {2, 4, 6} with mean 4, the deviations are −2, 0, and +2. Sum them directly: −2 + 0 + 2 = 0, which tells you nothing. Square them first: 4 + 0 + 4 = 8. Divide by n−1 = 2 to get a sample variance of 4. That number describes real spread. Because variance uses squared units (dollars², cm², score-points²), standard deviation — its square root — is preferred when communicating results to others since it restores the original measurement scale.
Population vs. Sample Variance — Which Should You Use?
Use sample variance when your data is a subset of a larger group. Use population variance only when your data covers every single value you care about — and when in doubt, always use sample mode.
Table: Sample Variance vs. Population Variance — Direct Comparison
| Sample Variance (s²) | Population Variance (σ²) | |
|---|---|---|
| Divisor | n − 1 | N |
| Symbol | s² | σ² |
| Mean symbol used | x̄ (sample mean) | μ (population mean) |
| Use when | Data is a sample from a larger population | Data IS the entire population |
| Excel formula | =VAR.S() | =VAR.P() |
| Python (NumPy) | np.var(data, ddof=1) | np.var(data, ddof=0) |
| When in doubt | Use this | — |
Why n − 1? (Bessel’s Correction)
When we compute the mean from the sample data itself, the deviations (xᵢ − x̄) are systematically a bit smaller than they would be if we knew the true population mean. This means dividing by n produces a variance estimate that is too small — biased downward. Dividing by n−1 inflates the result slightly, correcting for that bias. The practical effect shrinks as the sample grows: with n = 1,000, dividing by 999 versus 1,000 barely changes the answer. With n = 5, using n−1 versus n shifts the result by 25%.
Variance Formula
There are two variance formulas — one for a sample (s²) and one for a full population (σ²). They are identical except for the divisor and the mean symbol used.
Sample Variance (s²)
s² = Σ(xᵢ − x̄)² / (n − 1)
Where:
x̄ = sample mean (Σxᵢ / n)
xᵢ = each individual value
n = number of values in sample
n−1 = degrees of freedom
Population Variance (σ²)
σ² = Σ(xᵢ − μ)² / N
Where:
μ = population mean (Σxᵢ / N)
xᵢ = each individual value
N = total number of values
SS = Σ(xᵢ − μ)² = sum of squares
Never mix notation: using x̄ with N or μ with n−1 is a notation error. While the number produced may be arithmetically correct, the notation tells readers which formula you applied, and mixing symbols signals a misunderstanding of the distinction between sample and population statistics.
📊 How to Calculate Variance Step by Step
Variance requires five steps regardless of whether you are computing sample or population variance. The only difference is the divisor in Step 5.
Case Study — Sample Variance
(4 + 7 + 13 + 2 + 1) ÷ 5 = 27 ÷ 5 = 5.4
4−5.4 = −1.4 7−5.4 = 1.6 13−5.4 = 7.6 2−5.4 = −3.4 1−5.4 = −4.4
1.96 2.56 57.76 11.56 19.36
1.96 + 2.56 + 57.76 + 11.56 + 19.36 = 93.2
93.2 ÷ (5−1) = 93.2 ÷ 4 = s² = 23.3 | s = √23.3 ≈ 4.83
Population version: using the same data but dividing by N = 5 instead gives σ² = 93.2 ÷ 5 = 18.64. Population variance is always smaller than sample variance because we divide by the larger number N rather than the corrected n−1.
📐 How to Interpret Variance Results
The Squared-Units Problem
Here is what that conversion looks like in practice. Daily temperatures in °C: {18, 20, 22, 19, 21}. Sample variance = 2.5 °C². Standard deviation = √2.5 ≈ 1.58 °C. The sentence to say is: “Daily temperatures varied by about 1.6 °C from the mean.” The variance (2.5 °C²) is used inside formulas; the standard deviation (1.58 °C) is what you say out loud.
High vs. Low Variance — Context Decides
There is no universal threshold that separates “high” variance from “low” variance. A variance of 10,000 is tiny for annual salaries in dollars; it is enormous for adult heights in centimetres. The Coefficient of Variation (CV = SD ÷ Mean × 100%) solves this by expressing spread as a percentage of the mean, making it unit-free. As rough benchmarks: CV below 10% is low relative variability, 10–30% is moderate, and above 30% is high.
Table: CV Benchmark — Manufacturing Example
| Production Line | Target Diameter | Std Dev (s) | CV | Verdict |
|---|---|---|---|---|
| Line A | 50 mm | 1 mm | 2% | Excellent consistency |
| Line B | 50 mm | 8 mm | 16% | Quality issue — recalibrate |
Special Cases in Variance Interpretation
| Situation | Result | Meaning |
|---|---|---|
| All values identical | Variance = 0 | Zero spread; every observation equals the mean exactly |
| Only 1 value (sample) | Undefined | Sample variance divides by n−1 = 0, which is undefined; at least 2 values required |
| One extreme outlier | Variance inflated | Squaring amplifies large deviations; a single outlier can dominate the entire result |
| Very large variance | Inspect units first | Use CV or SD for context; also check for data-entry errors |
Variance vs. Standard Deviation — What Is the Difference?
Variance and standard deviation both measure spread around the mean. Variance uses squared units; standard deviation converts it back to the original measurement scale by taking the square root.
Table: Variance vs. Standard Deviation — Direct Comparison
| Property | Variance (s² or σ²) | Standard Deviation (s or σ) |
|---|---|---|
| Formula | Σ(xᵢ − x̄)² ÷ (n−1) | √variance |
| Units | Squared units (e.g. cm²) | Same as data (e.g. cm) |
| Interpretability | Lower — squared units are abstract | Higher — same scale as the data |
| Use in statistics | ANOVA, F-test, regression formulas | Confidence intervals, z-scores, reporting |
| Relationship | s² = s × s | s = √s² |
The practical rule: use variance inside formal statistical analyses and formulas; use standard deviation when communicating results to others. See our standard deviation calculator to explore both measures side by side.
📏 Variance vs. IQR vs. MAD — When to Use Each
Variance is not the only way to measure spread. The right choice depends on whether your data has outliers, how you will use the result, and whether you need the measurement to be in the original units.
Table: Four Spread Measures Compared
| Measure | Formula sketch | Units | Outlier sensitivity | Best for |
|---|---|---|---|---|
| Variance (s²) | Σ(x−x̄)² ÷ (n−1) | Squared | High | ANOVA, regression, formal models |
| Std Dev (s) | √variance | Same as data | High | Reporting spread, confidence intervals |
| IQR | Q3 − Q1 | Same as data | None | Skewed data, robust spread, boxplots |
| MAD | Σ|x−x̄| ÷ n | Same as data | Moderate | Intuitive; less sensitive than variance |
• Data has significant outliers → use IQR or MAD
• Running ANOVA or regression → use variance (it’s built into those formulas)
• Communicating to a general audience → use standard deviation
• Comparing datasets with different scales or units → use CV (SD ÷ Mean × 100%)
Common Mistakes When Calculating Variance
1. Using n Instead of n − 1 for Sample Data
Dividing by n produces a variance estimate that is biased downward. This is not a rounding issue — it is a systematic underestimate. In Excel, use =VAR.S() and in Python use np.var(data, ddof=1). Both correct for this bias automatically.
2. Mixing Up μ and x̄ in the Formula
μ is the population mean and belongs in the population variance formula. x̄ is the sample mean and belongs in the sample formula. Using μ notation alongside n−1 is a notation error that appears on a number of published statistics pages. The number computed may be correct, but the notation signals a misunderstanding.
3. Forgetting to Square the Deviations
If you subtract the mean and sum directly without squaring, positive and negative deviations cancel and the result is always zero. The squaring step is not arbitrary — it is what makes variance a non-trivial measure.
4. Treating Variance as a Directly Interpretable Number
A variance of 16 is not “16 units” of spread — it is 16 squared units. Report standard deviation (the square root) if you need an interpretable figure. Variance stays inside formulas; standard deviation travels in reports.
5. np.var() in Python Without ddof=1
NumPy’s default is ddof=0 (population variance). For sample variance you must write np.var(data, ddof=1). Python returns a number either way with no warning, making this one of the most common silent bugs in data-science code.
🌍 Real-World Applications of Variance
Finance and Investment
Portfolio managers calculate portfolio risk using variance and covariance together. The portfolio’s overall variance is not simply the average of individual asset variances — correlations between holdings change the picture. This is why a diversified portfolio can have lower total risk than any single asset it contains.
Quality Control and Manufacturing
A bolt specification requiring a 10 mm diameter ± 0.1 mm tolerance requires the standard deviation to stay well below 0.1 mm. If s² = 0.001 mm² (s ≈ 0.032 mm), the process is within tolerance. If s² = 0.05 mm² (s ≈ 0.22 mm), parts are failing specification. The Coefficient of Variation makes it straightforward to compare two machines producing the same part at the same target diameter.
Education and Research
Psychologists and social scientists use variance ratios in ANOVA to test whether group means differ by more than would be expected from random sampling alone. The F-statistic in ANOVA is literally the ratio of between-group variance to within-group variance. For a complete descriptive picture of your data, see our descriptive statistics calculator.
📊 How Sample Size Affects Variance Estimates — Benchmark Data
One of the most practically important aspects of sample variance is how Bessel’s correction becomes less significant as sample size grows. The table below shows this for a dataset with true population variance σ² = 100 (σ = 10).
Table: Divisor Effect by Sample Size (σ² = 100)
| Sample Size (n) | Divisor (n−1) | Correction factor (n÷(n−1)) | Impact on s² |
|---|---|---|---|
| 5 | 4 | 1.25 | 25% larger than biased estimate |
| 10 | 9 | 1.11 | 11% larger than biased estimate |
| 30 | 29 | 1.03 | 3% larger than biased estimate |
| 100 | 99 | 1.01 | 1% larger than biased estimate |
| 1,000 | 999 | 1.001 | Negligible difference |
The correction matters most for small samples. With n = 5, using n instead of n−1 underestimates variance by 20%. With n = 100, the error drops to 1%. This is why the choice of divisor is taught carefully in introductory statistics courses but rarely discussed in large-sample data science contexts.
How to Calculate Variance in Excel, Python, and R
Excel
Enter your data in a column (e.g., A1:A10), click an empty cell, and type your formula:
Avoid the legacy
=VAR() and =VARP() functions; the named versions make the sample/population choice explicit.
Python (NumPy)
import numpy as np
data = [4, 7, 13, 2, 1]
# Sample variance (ddof=1) — use this by default
sample_variance = np.var(data, ddof=1)
print(f"Sample variance: {sample_variance}") # 23.3
# Population variance (ddof=0) — only if data IS the full population
pop_variance = np.var(data, ddof=0)
print(f"Population variance: {pop_variance}") # 18.64
# Standard library — always returns sample variance (n-1)
import statistics
print(statistics.variance(data)) # 23.3
np.var() without ddof=1 divides by n, not n−1. Python returns a result either way with no warning. Always write ddof=1 explicitly when you need sample variance.
R
data <- c(4, 7, 13, 2, 1)
# Sample variance (n-1) — R's var() always uses n-1
sample_var <- var(data)
print(sample_var) # 23.3
# Population variance — no built-in; use manual conversion
n <- length(data)
pop_var <- var(data) * (n - 1) / n
print(pop_var) # 18.64
R’s var() always returns sample variance (n−1). There is no built-in function for population variance in base R, so the manual conversion above is the standard approach.
Variance: Complete Formula and Entity Reference
The table below covers every key symbol and concept associated with variance, structured for quick reference and AI extraction.
Table: Variance Glossary — 10 Key Entities
| Term | Symbol / Formula | Plain-English Definition |
|---|---|---|
| Sample Variance | s² = Σ(x−x̄)²/(n−1) | Average squared deviation from the sample mean; uses n−1 to correct for estimation bias |
| Population Variance | σ² = Σ(x−μ)²/N | Average squared deviation from the true population mean; divides by N |
| Standard Deviation | s = √s² | Square root of variance; expressed in the same units as the original data |
| Mean | x̄ = Σxᵢ/n | Arithmetic average of all values; the reference point for all deviations |
| Sum of Squares | SS = Σ(xᵢ−x̄)² | Sum of all squared deviations from the mean; the numerator of the variance formula |
| Degrees of Freedom | df = n−1 | Sample size minus 1; the denominator for sample variance after Bessel’s correction |
| Bessel’s Correction | ÷ (n−1) | Dividing by n−1 instead of n makes sample variance an unbiased estimator of population variance |
| Coeff. of Variation | CV = (s / x̄) × 100% | Standard deviation as a percentage of the mean; allows comparison across different scales |
| Deviation | xᵢ − x̄ | Difference between an individual value and the mean |
| Squared Deviation | (xᵢ − x̄)² | Deviation multiplied by itself; always non-negative; outliers receive disproportionately large values |
Related Calculators and Guides
Variance connects to nearly every area of descriptive and inferential statistics. These resources build the complete picture.
Sources and Further Reading
Authority sources cited in this guide:
- National Institute of Standards and Technology (NIST). Engineering Statistics Handbook — Measures of Scale. itl.nist.gov
- Penn State STAT 500. Applied Statistics — Descriptive Statistics. online.stat.psu.edu
- MIT OpenCourseWare. 18.650 Statistics for Applications, Fall 2016. ocw.mit.edu
- OpenStax. Introductory Statistics, Chapter 2: Descriptive Statistics. openstax.org
- Devore, J.L. Probability and Statistics for Engineering and the Sciences, 9th ed. Cengage Learning, 2016.
Frequently Asked Questions
Variance measures how spread out a set of values is around their mean. It is the average of the squared differences between each data point and the mean. A variance of 0 means all values are identical; higher variance means greater spread. Because variance uses squared units, standard deviation (its square root) is often preferred when communicating results directly to others.
Sample variance (s²) uses n−1 as the divisor and applies when your data is a subset of a larger group. Population variance (σ²) divides by N and applies only when your data contains every value in the group of interest. In practice, most real-world data is a sample, so s² is the more common choice. When in doubt, use sample mode.
Dividing by n−1 (Bessel’s correction) corrects for a systematic bias. When we estimate the population mean from the sample, the sample deviations are smaller than the true population deviations. Dividing by n would produce a variance that is too small — biased downward. Dividing by n−1 inflates the result slightly to produce an unbiased estimate. The correction matters most for small samples; with n = 1,000, dividing by 999 versus 1,000 makes almost no difference.
No. Variance is always zero or positive. Each deviation is squared before being summed, and squaring any real number yields a non-negative result. Variance equals exactly zero only when every value in the dataset is identical. If your calculation produces a negative variance, there is an arithmetic error somewhere in the working — most often a subtraction or division mistake.
There is no universal threshold — it depends entirely on your data’s scale, units, and context. A variance of 10,000 is tiny for annual salaries in dollars; it is enormous for heights in centimetres. Use the Coefficient of Variation (CV = SD ÷ Mean × 100%) to compare spread across datasets with different scales. As rough benchmarks: CV below 10% is low variability; CV above 30% is high.
Standard deviation is the square root of variance. They measure the same thing — spread around the mean — but standard deviation is expressed in the same units as the original data, making it more interpretable. Use variance inside statistical formulas and models (ANOVA, regression, F-tests); use standard deviation when reporting results to a general audience or producing charts and summaries.
For sample data: s² = Σ(xᵢ − x̄)² ÷ (n−1). For population data: σ² = Σ(xᵢ − μ)² ÷ N. The five steps: (1) find the mean, (2) subtract the mean from each value, (3) square each difference, (4) sum the squared differences to get SS, (5) divide SS by n−1 for samples or by N for populations.
Use =VAR.S(range) for sample variance (divides by n−1) or =VAR.P(range) for population variance (divides by N). For example, if your data is in cells A1:A20, enter =VAR.S(A1:A20) in an empty cell and press Enter. The legacy =VAR() and =VARP() functions work correctly but use the named versions for clarity.
Use NumPy: np.var(data, ddof=1) for sample variance, np.var(data, ddof=0) for population variance. The default ddof=0 gives population variance, so always specify ddof=1 for samples to avoid a silent error. Alternatively, Python’s statistics.variance(data) always returns sample variance without needing to set a parameter.
Use IQR (Q3 − Q1) when your data is skewed or contains significant outliers. Variance squares each deviation, so a single extreme value can dominate the entire result. IQR ignores the outer 25% on each side, making it a robust measure unaffected by extreme values. For symmetric data without outliers, variance or standard deviation is preferred because it uses all data points.
The coefficient of variation (CV = standard deviation ÷ mean × 100%) expresses spread as a percentage of the mean, making it unit-free. It is useful when comparing the relative variability of datasets with different units or scales — for example, comparing the spread of exam scores (out of 100) with the spread of incomes (in dollars). Raw variance cannot be meaningfully compared across different measurement scales; CV solves that problem.
Sample variance is used to estimate population spread from a subset of observations. It is the foundational measure in t-tests (comparing means), ANOVA (comparing group variances), confidence intervals (quantifying estimation uncertainty), and regression analysis (measuring residual spread). Whenever you have sampled data and want to draw inferences about the broader population, sample variance (with n−1) is the correct measure to use.