Why Compute Variance This Way?
Variance measures the average squared distance of a random variable from its mean. That definition is direct, but calculations can become cumbersome when the mean is not one of the possible values or when the distribution has many outcomes. An equivalent formula lets us calculate variance using the first and second raw moments instead. This tutorial derives that identity and applies it to discrete and continuous models.
The identity is useful only when the relevant expectations are finite. For a random variable \(X\), we require a finite second moment, \(E[X^2]<\infty\). This condition also ensures that \(E[X]\) is finite. No interest or mortality assumptions are involved in the examples below: they concern probability models for measurements or scores, with no discounting or life-contingent payments.
Deriving the Computational Formula
Write \(\mu=E[X]\), which is a fixed number rather than a random variable. Expand the square in the definition, then use linearity of expectation. The condition \(E[X^2]<\infty\) makes these expectations well-defined.
Variance is the expectation of the squared deviation from the mean.
Use \((X-\mu)^2=X^2-2\mu X+\mu^2\).
Since \(\mu\) is constant, \(E[2\mu X]=2\mu E[X]\) and \(E[\mu^2]=\mu^2\).
Use \(E[X]=\mu\) to simplify the result.
The cancellation in the fourth line is the key: the two terms involving the mean combine to leave one subtraction of \(\mu^2\). The resulting formula does not change what variance means. It is an algebraically equivalent way to calculate the same expected squared deviation.
For a discrete random variable with possible values \(x_j\) and probabilities \(p_j=P(X=x_j)\), the expectations in the formula are sums. For a continuous random variable with density \(f_X\), they are integrals over the support of the distribution.
In the continuous case, each integral is over the support where the density is positive. In either case, the procedure is the same: find \(E[X]\), find \(E[X^2]\), and subtract the square of the first quantity from the second. Keep the order of the subtraction; reversing it would produce a nonpositive result, even though variance cannot be negative.
Applying the Formula to Discrete Models
Worked Example: A Discrete Calibration Score
A hypothetical calibration procedure assigns a score \(X\) of 0, 2, or 5 points. Its model is \(P(X=0)=0.20\), \(P(X=2)=0.50\), and \(P(X=5)=0.30\). Find the variance of the score. This is a discrete distribution specified by its three support values and probabilities; there is no interest rate or mortality assumption because no financial accumulation or survival model is involved.
Method. Use the computational formula, calculating the first and second raw moments separately.
First verify the probabilities sum to one: \(0.20+0.50+0.30=1.00\). The mean is
For the second raw moment, square each possible score before multiplying by its probability:
Now subtract the square of the mean:
Check. The direct squared-deviation calculation gives \(0.20(0-2.50)^2+0.50(2-2.50)^2+0.30(5-2.50)^2=1.25+0.125+1.875=3.25\). The two methods agree. A common mistake this avoids is squaring the mean before calculating \(E[X^2]\), rather than squaring each outcome in the second-moment calculation.
Worked Example: A Discrete Net-Change Model
A hypothetical process records a net change \(X\), in units, that can be \(-1\), 1, or 3. The model is \(P(X=-1)=0.25\), \(P(X=1)=0.50\), and \(P(X=3)=0.25\). Calculate the variance. The distribution is discrete with the stated support and probabilities; there is no interest or mortality assumption.
Method. Apply the raw-moment formula, retaining the negative outcome when calculating the mean and squaring it when calculating the second raw moment.
The probabilities sum to \(0.25+0.50+0.25=1\). The mean is
The second raw moment is
Therefore,
Check. The mean is 1, so the deviations at \(-1\), 1, and 3 are \(-2\), 0, and 2. Their probability-weighted squared deviations are \(0.25(4)+0.50(0)+0.25(4)=2\). The result agrees. A common mistake is to retain the negative sign after squaring \(-1\); its contribution to \(E[X^2]\) is \(({-1})^2(0.25)=0.25\), not \(-0.25\).
Applying the Formula to a Continuous Model
Worked Example: A Continuous Measurement With a Triangular Density
A hypothetical instrument reports a measurement \(X\) between 0 and 3. Its density is \(f_X(x)=2x/9\) for \(0\leq x\leq3\), and zero otherwise. Find its variance. This is a continuous distribution with support \([0,3]\) and density parameter \(2/9\); no interest rate or mortality assumption applies.
Method. Integrate \(x f_X(x)\) to find \(E[X]\), then \(x^2 f_X(x)\) to find \(E[X^2]\), and use the computational formula. First check the density: \(\int_0^3 (2x/9)\,dx=(1/9)[x^2]_0^3=1\).
The first raw moment is
The second raw moment is
Thus,
Check. Directly integrating the squared deviation gives
The direct calculation confirms the result. A common mistake is to integrate \(x^2\) alone and call the result \(E[X^2]\); the density must remain in the integrand, so the quantity being integrated is \(x^2f_X(x)\).
Checks and Common Exam Traps
The computational formula is often shorter than calculating every squared deviation, but it has two separate quantities that are easy to confuse. Calculate \(E[X^2]\) by applying the expectation operation to the squared variable. Calculate \((E[X])^2\) by first finding the mean and then squaring that number. These operations are generally not equal.
A useful final check is that the computed variance is nonnegative. This follows from its definition as an expectation of a square, and it provides a quick warning if the order of subtraction or an intermediate calculation is wrong. Variance is measured in squared units: if \(X\) is measured in points, the variance is in points squared. The square root of variance is a different measure, so do not label the variance itself in the original units.
The raw-moment method is especially efficient when the support or density makes the first two moments straightforward to calculate. The direct definition remains valuable as a check and as the interpretation of the result: variance is the probability-weighted or density-weighted average of squared distances from the mean. The formula derived here is aligned with the SOA VEE Mathematical Statistics syllabus.
Check Your Understanding
For each model, use the computational variance formula and check that the stated distribution is valid.
- A discrete variable \(X\) takes values \(-2,0,4\) with probabilities \(0.25,0.50,0.25\), respectively. Find \(E[X]\), \(E[X^2]\), and \(\operatorname{Var}(X)\). (Answer: \(E[X]=0.5\), \(E[X^2]=5\), and \(\operatorname{Var}(X)=4.75\).)
- A discrete measurement \(X\) is 1 with probability \(0.40\) and 3 with probability \(0.60\). Calculate its variance. (Answer: \(0.96\).)
- A continuous variable has density \(f_X(x)=1/4\) for \(0\leq x\leq4\), and zero elsewhere. Find its variance using integrals. (Answer: \(4/3\).)
- A continuous model has density \(f_X(x)=3x^2/8\) for \(0\leq x\leq2\), and zero elsewhere. Verify the density integrates to one, then calculate the variance. (Answer: the density integrates to \(1\), \(E[X]=1.5\), \(E[X^2]=2.4\), and \(\operatorname{Var}(X)=0.15\).)
- A discrete variable takes values 0, 1, and 4 with probabilities \(0.50,0.25,0.25\), respectively. Calculate the mean, second raw moment, and variance; do not confuse the second raw moment with the variance. (Answer: \(E[X]=1.25\), \(E[X^2]=4.25\), and \(\operatorname{Var}(X)=2.6875\).)