Variance Calculator

Compute sample and population variance, standard deviation, and squared deviations for any dataset or grouped frequency distribution.

๐Ÿ“Š Variance Calculator
Enter Numbers (comma or space separated)
Class Midpoints (comma separated)
Frequencies (comma separated)
Sample Variance (s²)
Population Variance (σ²)
Sample SD (s)
Population SD (σ)
Mean (μ / x̅)
Count (n)
Sum of Sq. Dev. (SS)

๐Ÿ“Š What is Variance?

Variance is a statistical measure of the spread or dispersion of a dataset around its mean. It quantifies how far the individual values in a dataset are from the average. A variance of zero means all values are identical. Larger variance indicates greater variability. Variance is calculated by finding the mean of all squared deviations from the mean, which ensures that positive and negative deviations do not cancel each other out. The square root of variance gives the standard deviation, which is expressed in the same units as the original data and is more commonly reported in practice.

Variance appears throughout applied statistics and data science. In finance, portfolio variance measures how much investment returns fluctuate, and the variance of a diversified portfolio depends on the covariances between individual assets. In quality control, variance (or standard deviation) defines process capability: a tightly controlled manufacturing process has low variance in its output measurements. In A/B testing, the variance of the metric being tested determines the required sample size and the power of the statistical test. In machine learning, the bias-variance tradeoff describes how model complexity affects the balance between underfitting and overfitting.

There are two distinct types of variance: population variance and sample variance. Population variance (sigma squared) divides the sum of squared deviations by n, the total number of values, and is appropriate when your data represents the entire population. Sample variance (s squared) divides by n-1 and is appropriate when your data is a sample drawn from a larger population, which is the typical situation in research and data analysis. The n-1 denominator, known as Bessel's correction, corrects for the tendency of samples to underestimate population spread, making sample variance an unbiased estimator of population variance.

This calculator accepts raw data (a list of individual numbers) in Dataset mode, or summarized data in Grouped Frequency mode where you enter class midpoints and their corresponding frequencies. Both modes produce sample variance, population variance, standard deviations, and a complete deviation table showing the contribution of each value to the total sum of squared deviations. The deviation table is particularly useful for manually verifying calculations or for understanding how each data point influences the overall spread.

๐Ÿ“ Formula

s² = ∑(x⊂i; − x̅)² ÷ (n − 1)
= sample variance
x⊂i; = each individual value in the dataset
= sample mean = ∑x⊂i; ÷ n
n = number of values in the sample
n − 1 = degrees of freedom (Bessel's correction)

Population variance uses n in the denominator instead of n-1:

σ² = ∑(x⊂i; − μ)² ÷ n
σ² = population variance
μ = population mean
Example: Dataset = [2, 4, 6, 8]. Mean = 5. Deviations = [-3, -1, 1, 3]. Squared = [9, 1, 1, 9]. SS = 20. Sample variance = 20 / 3 = 6.667. Population variance = 20 / 4 = 5.000.

For grouped frequency data:

σ² = ∑f⊂i;(x⊂i; − μ)² ÷ N
x⊂i; = class midpoint
f⊂i; = frequency of class i
N = total frequency = ∑f⊂i;
μ = weighted mean = ∑(f⊂i; × x⊂i;) ÷ N

๐Ÿ“– How to Use This Calculator

Steps

1
Enter your dataset or switch to Grouped mode - in Dataset mode, type or paste numbers separated by commas or spaces into the text area. Switch to Grouped Frequency if you have class midpoints and frequency counts.
2
Click Calculate - the calculator computes sample variance (n-1), population variance (n), both standard deviations, mean, count, and the sum of squared deviations. All six values appear in the results grid.
3
Review the deviation table - scroll below the summary results to see the step-by-step deviation table. Each row shows a data value, its deviation from the mean, and the squared deviation. The column sum equals the SS (sum of squared deviations) used in the variance formula.

๐Ÿ’ก Example Calculations

Example 1 - Small Dataset (Manual Verification)

Dataset: 2, 4, 6, 8, 10

1
Mean: (2 + 4 + 6 + 8 + 10) / 5 = 30 / 5 = 6. Deviations: 2-6 = -4, 4-6 = -2, 6-6 = 0, 8-6 = +2, 10-6 = +4.
2
Squared deviations: 16, 4, 0, 4, 16. Sum of squared deviations (SS) = 16 + 4 + 0 + 4 + 16 = 40.
3
Sample variance = 40 / (5-1) = 40 / 4 = 10.000. Population variance = 40 / 5 = 8.000. Sample SD = sqrt(10) = 3.1623.
Sample Variance = 10.000 | Population Variance = 8.000 | Sample SD = 3.1623
Try this example →

Example 2 - Test Scores Dataset

Exam scores: 72, 85, 91, 68, 79, 88, 76, 93, 65, 82

1
Sum = 799. Mean = 799 / 10 = 79.9. Deviations from mean: -7.9, 5.1, 11.1, -11.9, -0.9, 8.1, -3.9, 13.1, -14.9, 2.1.
2
Squared deviations: 62.41, 26.01, 123.21, 141.61, 0.81, 65.61, 15.21, 171.61, 222.01, 4.41. Sum of squared deviations = 832.9.
3
Sample variance = 832.9 / 9 = 92.544. Sample SD = sqrt(92.544) = 9.620. This means scores typically deviate about 9.6 points from the mean of 79.9.
Sample Variance = 92.544 | Sample SD = 9.620 | Mean = 79.9
Try this example →

Example 3 - Grouped Frequency Distribution

Heights grouped by 5 cm classes: midpoints 155, 160, 165, 170, 175 with frequencies 4, 9, 14, 8, 5

1
Total N = 4 + 9 + 14 + 8 + 5 = 40. Weighted sum = (155x4) + (160x9) + (165x14) + (170x8) + (175x5) = 620 + 1440 + 2310 + 1360 + 875 = 6605. Mean = 6605 / 40 = 165.125 cm.
2
Deviations from mean: -10.125, -5.125, -0.125, 4.875, 9.875. Squared: 102.52, 26.27, 0.016, 23.77, 97.52. Weighted by frequency: 4x102.52 + 9x26.27 + 14x0.016 + 8x23.77 + 5x97.52 = 410.1 + 236.4 + 0.22 + 190.1 + 487.6 = 1324.42.
3
Population variance = 1324.42 / 40 = 33.11. Sample variance = 1324.42 / 39 = 33.96. Population SD = sqrt(33.11) = 5.754 cm.
Population Variance = 33.11 | Population SD = 5.754 cm
Try this example →

โ“ Frequently Asked Questions

What is the formula for sample variance?+
Sample variance s^2 = sum((xi - x_bar)^2) / (n - 1), where xi are individual values, x_bar is the sample mean, and n is the sample size. The denominator n-1 (Bessel's correction) makes sample variance an unbiased estimator of population variance. For [2, 4, 6, 8]: mean = 5, squared deviations sum = 20, sample variance = 20 / 3 = 6.667. Population variance uses n in the denominator: 20 / 4 = 5.000.
What is the difference between sample and population variance?+
Sample variance (s^2) divides by n-1 and is used when your dataset is a sample from a larger population, which is the typical case. Population variance (sigma^2) divides by n and is used only when your dataset is the complete population. The difference becomes negligible for large n. For n = 10, sample variance is 11.1% higher than population variance. For n = 100, the difference is only 1%. Always use sample variance for descriptive statistics of sampled data.
Why does variance use squared deviations instead of absolute deviations?+
Squaring deviations has several mathematical advantages over using absolute values. Squaring penalizes larger deviations more heavily than small ones, which reflects our intuition that extreme outliers represent more spread. Squared deviations produce a differentiable function, enabling calculus-based optimization used throughout statistics and machine learning. Variance is also additive for independent random variables: Var(X + Y) = Var(X) + Var(Y), which is not true for mean absolute deviation. The tradeoff is that variance is in squared units.
How do I calculate variance for grouped data?+
For grouped frequency data: (1) Find the weighted mean: mu = sum(fi * xi) / N where fi is frequency and xi is class midpoint. (2) Compute the sum of weighted squared deviations: SS = sum(fi * (xi - mu)^2). (3) Divide by N for population variance or by N-1 for sample variance. Use the Grouped Frequency tab in this calculator: enter midpoints in one field and matching frequencies in the other. The midpoints should be the center value of each class interval.
Can variance be negative?+
No. Variance cannot be negative. Since every term in the sum is a squared value, all terms are non-negative. Variance equals zero only when all values in the dataset are identical (all deviations equal zero). A zero variance means there is no variability in the data. If you obtain a negative variance from a manual computation, there is an arithmetic error. Common errors include using n instead of n-1 or computing deviations incorrectly.
What does a high variance mean in practice?+
High variance means values in your dataset are widely spread around the mean, indicating high variability or inconsistency. Low variance means values cluster tightly near the mean, indicating consistency. What counts as "high" depends on context: a daily stock return variance of 0.0004 (SD = 2%) is considered volatile for blue-chip stocks, while an exam score variance of 100 (SD = 10 points) might be considered moderate. Always interpret variance relative to the scale and context of your data.
What is Bessel's correction and why is n-1 used?+
Bessel's correction uses n-1 instead of n in sample variance to remove bias. When you compute the sample mean and use it to calculate deviations, you lose one degree of freedom because the deviations must sum to zero. This causes the sum of squared deviations to systematically underestimate the true population spread. Dividing by n-1 instead of n inflates the estimate just enough to remove this bias. For n = 2, sample variance is exactly double the naive estimate using n.
How is variance related to standard deviation?+
Standard deviation = sqrt(variance). Variance = SD^2. Both measure spread, but variance is in squared units while SD is in the original data units. For data in kilograms, variance is in kg^2 and SD is in kg. Standard deviation is more interpretable for reporting purposes because it shares the units of the data. Variance is preferred in mathematical derivations because it is additive for independent variables: Var(X + Y) = Var(X) + Var(Y) (assuming independence).
How is variance used in ANOVA?+
ANOVA (Analysis of Variance) tests whether the means of three or more groups are equal by comparing variance between groups to variance within groups. The F-statistic = between-group variance / within-group variance. If the F-statistic is large, the variation explained by group differences exceeds random within-group variation, providing evidence that at least one group mean differs. ANOVA partitions total variance into components: SS_total = SS_between + SS_within, where each SS (sum of squares) is a variance-like quantity.
What is variance in terms of expected value?+
In probability theory, variance of a random variable X is defined as Var(X) = E[(X - E[X])^2], which equals E[X^2] - (E[X])^2. Here E[X] denotes the expected value (theoretical mean). This definition generalizes naturally to continuous distributions. For the normal distribution N(mu, sigma^2), the variance is sigma^2. For a uniform distribution on [a, b], variance = (b-a)^2 / 12. The computational formula E[X^2] - (E[X])^2 is often faster to compute than the definitional formula.
How does variance relate to covariance and correlation?+
Covariance measures how two variables vary together: Cov(X, Y) = E[(X - E[X])(Y - E[Y])]. When X = Y, covariance reduces to variance: Cov(X, X) = Var(X). Correlation (Pearson's r) standardizes covariance by both standard deviations: r = Cov(X,Y) / (SD_X * SD_Y). Variance appears on the diagonal of a covariance matrix, with covariances off the diagonal. In portfolio theory, the variance of a two-asset portfolio is Var = w1^2*Var1 + w2^2*Var2 + 2*w1*w2*Cov(1,2).