Variance


In probability theory and statistics, variance is the expected value of the squared deviation from the mean of a random variable. The standard deviation is obtained as the square root of the variance. Variance is a measure of dispersion, meaning it is a measure of how far a set of numbers are spread out from their average value. It is the second central moment of a distribution, and the covariance of the random variable with itself, and it is often represented by,,,, or.
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 is the expected value of the squared deviation from the mean of, :
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:
The variance is also equivalent to the second cumulant of a probability distribution that generates. The variance is typically designated as, or sometimes as or, or symbolically as or simply . The expression for the variance can be expanded as follows:
In other words, the variance of is equal to the mean of the square of minus the square of the mean of. 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 is discrete with probability mass function, then
where is the expected value. That is,
The variance of a collection of equally likely values can be written as
where is the average value. That is,
The variance of a set of 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:

Absolutely continuous random variable

If the random variable has a probability density function, and is the corresponding cumulative distribution function, then
or equivalently,
where is the expected value of given by
In these formulas, the integrals with respect to and are Lebesgue and Lebesgue–Stieltjes integrals, respectively.
If the function is Riemann-integrable on every finite interval then
where the integral is an improper Riemann integral.

Examples

Exponential distribution

The exponential distribution with parameter > 0 is a continuous distribution whose probability density function is given by
on the interval. Its mean can be shown to be
Using integration by parts and making use of the expected value already calculated, we have:
Thus, the variance of is given by

Fair die

A fair six-sided die can be modeled as a discrete random variable,, with outcomes 1 through 6, each with equal probability 1/6. The expected value of is Therefore, the variance of is
The general formula for the variance of the outcome,, of an die is

Commonly used probability distributions

The following table lists the variance for some commonly used probability distributions.
Name of the probability distributionProbability distribution functionMeanVariance
Binomial distribution
Geometric distribution
Normal distribution
Uniform distribution
Exponential distribution
Poisson distribution

Properties

Basic properties

Variance is non-negative because the squares are positive or zero:
The variance of a constant is zero.
Conversely, if the variance of a random variable is 0, then it is almost surely a constant. That is, it always has the same value:

Issues of finiteness

If a distribution does not have a finite expected value, as is the case for the Cauchy distribution, then the variance cannot be finite either. However, some distributions may not have a finite variance, despite their expected value being finite. An example is a Pareto distribution whose index satisfies

Decomposition

The general formula for variance decomposition or the law of total variance is: If and are two random variables, and the variance of exists, then
The conditional expectation of given, and the conditional variance may be understood as follows. Given any particular value y of the random variable Y, there is a conditional expectation given the event Y = y. This quantity depends on the particular value y; it is a function. That same function evaluated at the random variable Y is the conditional expectation.
In particular, if is a discrete random variable assuming possible values with corresponding probabilities, then in the formula for total variance, the first term on the right-hand side becomes
where. Similarly, the second term on the right-hand side becomes
where and. Thus the total variance is given by
A similar formula is applied in analysis of variance, where the corresponding formula is\
here refers to the Mean of the Squares. In linear regression analysis the corresponding formula is
This can also be derived from the additivity of variances, since the total score is the sum of the predicted score and the error score, where the latter two are uncorrelated.
Similar decompositions are possible for the sum of squared deviations :

Calculation from the CDF

The population variance for a non-negative random variable can be expressed in terms of the cumulative distribution function F using
This expression can be used to calculate the variance in situations where the CDF, but not the density, can be conveniently expressed.

Characteristic property

The second moment of a random variable attains the minimum value when taken around the first moment of the random variable, i.e.. Conversely, if a continuous function satisfies for all random variables, then it is necessarily of the form, where. This also holds in the multidimensional case.

Units of measurement

Unlike the expected absolute deviation, the variance of a variable has units that are the square of the units of the variable itself. For example, a variable measured in meters will have a variance measured in meters squared. For this reason, describing data sets via their standard deviation or root mean square deviation is often preferred over using the variance. In the dice example the standard deviation is, slightly larger than the expected absolute deviation of 1.5.
The standard deviation and the expected absolute deviation can both be used as an indicator of the "spread" of a distribution. The standard deviation is more amenable to algebraic manipulation than the expected absolute deviation, and, together with variance and its generalization covariance, is used frequently in theoretical statistics; however the expected absolute deviation tends to be more robust as it is less sensitive to outliers arising from measurement anomalies or an unduly heavy-tailed distribution.

Propagation

Addition and multiplication by a constant

Variance is invariant with respect to changes in a location parameter. That is, if a constant is added to all values of the variable, the variance is unchanged:
If all values are scaled by a constant, the variance is scaled by the square of that constant:
The variance of a sum of two random variables is given by
where is the covariance.

Linear combinations

In general, for the sum of random variables, the variance becomes:
see also general Bienaymé's identity.
These results lead to the variance of a linear combination as:
If the random variables are such that
then they are said to be uncorrelated. It follows immediately from the expression given earlier that if the random variables are uncorrelated, then the variance of their sum is equal to the sum of their variances, or, expressed symbolically:
Since independent random variables are always uncorrelated, the equation above holds in particular when the random variables are independent. Thus, independence is sufficient but not necessary for the variance of the sum to equal the sum of the variances.