A variance formula is an equation used to compute or define the variance.
There are several formulae that can be used, depending on the situation.
We start with a general formula, used to define the variance of a random variable :where:
denotes the variance;
denotes the expected value operator.
This is a definition and it is useful because of its generality. However, if you need to calculate the variance in practice, you need to use the equations below.
When the random variable is discrete the above formula becomeswhere:
is the set of all possible realizations of (called the support of );
is the probability mass function of ;
the notation indicates that we need to perform a sum over all the values that can take.
In other words, we need to compute a weighted average of the squared deviations of from its mean.
Suppose that can take only two values, and , each with probability .
Then, the support of isand its probability mass function is
We first need to calculate the expected value:
Then, we can compute the variance:
When is continuous, the variance formula iswhere:
is the probability density function of ;
the notation indicates that we need to take an integral between and .
To understand the next example you need to be familiar with integration rules.
Suppose that has a uniform distribution, with probability density
We compute the expected value:
The variance is:
Instead of computing variance using the formulae above, it is often easier to use the following equivalent equation based on moments:
Let us continue with the example of the uniform distribution.
Instead of using the variance formula for continuous variables, we compute the first moment (already done!) and the second moment
Then, we plug the two moments in the equation:
When we know the moment generating function of , we can use it to compute the two moments and and then plug their values in the formula above.
Until now, we have discussed how to calculate the variance of a random variable.
However, there is another concept, that of sample variance, that applies when we need to assess the dispersion of some observations around their sample mean.
If you are interested in the formulae for sample variance, you can check the following pages:
More details about these formulae - including proofs and solved exercises - can be found in the lecture entitled Variance.
Previous entry: Unbiased estimator
Next entry: Variance inflation factor
Please cite as:
Taboga, Marco (2021). "Variance formula", Lectures on probability theory and mathematical statistics. Kindle Direct Publishing. Online appendix. https://www.statlect.com/glossary/variance-formula.
Most of the learning materials found on this website are now available in a traditional textbook format.