Back to Calculators

Variance Calculator

Calculate variance of a dataset with step-by-step solution.

You can copy and paste data from spreadsheet applications.

Sample variance uses (n-1) in the denominator and is used when data represents a sample of a larger population.

Advertisement

What is Variance?

Variance is a statistical measure that quantifies how spread out a dataset is relative to its mean (average). It measures the average squared deviation of each data point from the mean of the dataset.

A low variance indicates that the data points tend to be close to the mean (and to each other), while a high variance indicates that the data points are spread out over a wider range.

How to Calculate Variance

There are two types of variance: sample variance and population variance.

Population Variance (σ²)

When you have data for an entire population, you use the population variance formula:

σ² = Σ(xᵢ - μ)² / N

Where:

  • σ² is the population variance
  • xᵢ is each value in the population
  • μ is the population mean
  • N is the size of the population

Sample Variance (s²)

When you have data for only a sample of the population, you use the sample variance formula:

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

Where:

  • s² is the sample variance
  • xᵢ is each value in the sample
  • x̄ is the sample mean
  • n is the size of the sample

Note that the sample variance uses (n-1) in the denominator rather than n. This is known as Bessel's correction and is done to make the sample variance an unbiased estimator of the population variance.

Step-by-Step Calculation

  1. Calculate the mean (average) of your data.
  2. Subtract the mean from each data point to get the deviations from the mean.
  3. Square each of these deviations.
  4. Sum all the squared deviations.
  5. Divide this sum by the total number of data points (for population variance) or by the number of data points minus one (for sample variance).

Example:

For the dataset: 2, 4, 4, 4, 5, 5, 7, 9

  1. Calculate the mean: (2 + 4 + 4 + 4 + 5 + 5 + 7 + 9) ÷ 8 = 40 ÷ 8 = 5
  2. Find the deviations: 2-5=-3, 4-5=-1, 4-5=-1, 4-5=-1, 5-5=0, 5-5=0, 7-5=2, 9-5=4
  3. Square the deviations: (-3)²=9, (-1)²=1, (-1)²=1, (-1)²=1, 0²=0, 0²=0, 2²=4, 4²=16
  4. Sum the squared deviations: 9 + 1 + 1 + 1 + 0 + 0 + 4 + 16 = 32
  5. For population variance: 32 ÷ 8 = 4
  6. For sample variance: 32 ÷ 7 = 4.57

Variance vs. Standard Deviation

Variance and standard deviation are closely related measures of dispersion:

  • Variance measures the average squared deviation from the mean.
  • Standard deviation is the square root of the variance, representing the average deviation from the mean.

While both measure the spread of data, standard deviation is often preferred because it's in the same units as the original data, making it more interpretable. Variance is in squared units, which can be difficult to directly relate to the original data.

Standard Deviation = √Variance

Applications of Variance

In Finance

Variance is used to measure risk in financial investments. Higher variance implies higher volatility and risk. It's a key component in portfolio theory, where it helps determine the optimal allocation of assets.

In Quality Control

Manufacturing processes use variance to monitor and control product quality. Lower variance indicates more consistent production quality.

In Machine Learning

Variance is a fundamental concept in machine learning, used to evaluate model performance, as part of the bias-variance tradeoff, and in algorithms like Principal Component Analysis (PCA).

In Experimental Design

Scientists use variance to determine the statistical significance of experimental results and to optimize experimental designs.

In Social Sciences

Researchers use variance to understand the distribution of characteristics across populations, such as income inequality or educational outcomes.

Properties of Variance

  • Non-negative: Variance is always greater than or equal to zero. It equals zero only when all data points are identical.
  • Scale changes: If all values in a dataset are multiplied by a constant c, the variance is multiplied by c².
  • Shift invariance: Adding a constant to all data points doesn't change the variance.
  • Additivity of independent variables: The variance of the sum of independent random variables equals the sum of their variances.

Var(X + Y) = Var(X) + Var(Y) + 2·Cov(X,Y)

Where Cov(X,Y) is the covariance between X and Y. If X and Y are independent, then Cov(X,Y) = 0.

Variance Formulas

Population Variance:

σ² = Σ(xᵢ - μ)² / N

Sample Variance:

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

Computational Formula:

s² = (Σxᵢ² - (Σxᵢ)²/n) / (n-1)

Variance of Linear Transformation:

Var(aX + b) = a²·Var(X)

Quick Tips

  • • Use sample variance when working with a sample from a larger population
  • • Use population variance when you have data for the entire population
  • • Variance is always non-negative
  • • High variance indicates more spread out data
  • • Low variance indicates data clustered around the mean
  • • The units of variance are the square of the original units
  • • For normal distributions, about 68% of values lie within one standard deviation of the mean