Lably
Skip to content

Variance

Statistical measure of how far values spread from their average

  • 22 min read
  • 10 chapters
  • 3 labs on Lably

Learn it on Lably

An advantage of variance as a measure of dispersion is that it is more amenable to algebraic manipulation than other measures of dispersion such as the expected absolute deviation; for example, the variance of a sum of uncorrelated random variables is equal to the sum of their variances. A disadvantage of the variance for practical applications is that, unlike the standard deviation, its units differ from the random variable, which is why the standard deviation is more commonly reported as a measure of dispersion once the calculation is finished. Another disadvantage is that the variance is not finite for many distributions.

There are two distinct concepts that are both called "variance". One, as discussed above, is part of a theoretical probability distribution and is defined by an equation. The other variance is a characteristic of a set of observations. When variance is calculated from observations, those observations are typically measured from a real-world system. If all possible observations of the system are present, then the calculated variance is called the population variance. Normally, however, only a subset is available, and the variance calculated from this is called the sample variance. The variance calculated from a sample is considered an estimate of the full population variance. There are multiple ways to estimate the population variance on the basis of the sample variance, as discussed in the section below.

The two kinds of variance are closely related. To see how, consider that a theoretical probability distribution can be used as a generator of hypothetical observations. If an infinite number of observations are generated using a distribution, then the sample variance calculated from that infinite set will match the value calculated using the distribution's equation for variance. Variance has a central role in statistics, where some ideas that use it include descriptive statistics, statistical inference, hypothesis testing, goodness of fit, and Monte Carlo sampling.

Definition

The variance of a random variable X is the expected value of the squared deviation from the mean of ⁠X⁠, ⁠μ=E⁡[X]⁠: Var⁡(X)=E⁡[(X−μ)2]. This definition encompasses random variables that are generated by processes that are discrete, continuous, neither, or mixed. The variance can also be thought of as the covariance of a random variable with itself: Var⁡(X)=Cov⁡(X,X).

The variance is also equivalent to the second cumulant of a probability distribution that generates ⁠X⁠. The variance is typically designated as ⁠Var⁡(X)⁠, or sometimes as V(X) or ⁠V(X)⁠, or symbolically as ⁠σX2⁠ or simply σ2 (pronounced "sigma squared"). The expression for the variance can be expanded as follows: Var⁡(X)=E⁡[(X−E⁡[X])2]=E⁡[X2−2XE⁡[X]+E⁡[X]2]=E⁡[X2]−2E⁡[X]E⁡[X]+E⁡[X]2=E⁡[X2]−2E⁡[X]2+E⁡[X]2=E⁡[X2]−E⁡[X]2

In other words, the variance of ⁠X⁠ is equal to the mean of the square of ⁠X⁠ minus the square of the mean of ⁠X⁠. This equation should not be used for computations using floating-point arithmetic, because it suffers from catastrophic cancellation if the two components of the equation are similar in magnitude. For other numerically stable alternatives, see Algorithms for calculating variance.

Discrete random variable

If the generator of random variable X is discrete with probability mass function x1↦p1,x2↦p2,…,xn↦pn, then Var⁡(X)=∑i=1npi⋅(xi−μ)2, where μ is the expected value. That is, μ=∑i=1npixi. (When such a discrete weighted variance is specified by weights whose sum is not 1, then one divides by the sum of the weights.)

The variance of a collection of n equally likely values can be written as Var⁡(X)=1n∑i=1n(xi−μ)2, where μ is the average value. That is, μ=1n∑i=1nxi.

The variance of a set of n equally likely values can be equivalently expressed, without directly referring to the mean, in terms of squared deviations of all pairwise squared distances of points from each other: Var⁡(X)=1n2∑i=1n∑j=1n12(xi−xj)2=1n2∑i∑j>i(xi−xj)2.

Absolutely continuous random variable

If the random variable X has a probability density function ⁠f(x)⁠, and F(x) is the corresponding cumulative distribution function, then Var⁡(X)=σ2=∫R(x−μ)2f(x)dx=∫Rx2f(x)dx−2μ∫Rxf(x)dx+μ2∫Rf(x)dx=∫Rx2dF(x)−2μ∫RxdF(x)+μ2∫RdF(x)=∫Rx2dF(x)−2μ⋅μ+μ2⋅1=∫Rx2dF(x)−μ2, or equivalently, Var⁡(X)=∫Rx2f(x)dx−μ2, where μ is the expected value of X given by μ=∫Rxf(x)dx=∫RxdF(x).

In these formulas, the integrals with respect to dx and dF(x) are Lebesgue and Lebesgue–Stieltjes integrals, respectively.

If the function x2f(x) is Riemann-integrable on every finite interval [a,b]⊂R, then Var⁡(X)=∫−∞+∞x2f(x)dx−μ2, where the integral is an improper Riemann integral.

Sign in to keep reading

9 more chapters are free with a Lably account.

More in Statistics and probability