Variance of a Discrete Random Variable

Compute Var(X) for a probability distribution with E[X²] - (E[X])², then use the rules for Var(aX + b) and sums of independent variables. Worked examples.

Variance of a Random Variable: Formula and Examples

The variance of a random variable is the average squared distance of its possible values from their mean. For a discrete random variable, the formula is Var(X) = E[(X, μ)²] = Σ (x, μ)² P(x). This gives you variance in squared units, which is one of the two most common mistakes students make: the square root (standard deviation) is in the original units, not the variance itself. The other common mistake is using the wrong denominator when working with samples instead of populations. To compute the variance of a probability distribution step by step, use the shortcut formula E[X²], μ², and apply the variance formulas for the binomial, Poisson, and uniform distributions.

Definition: Var(X) = E[(X, μ)²]

The variance of a random variable X is defined as Var(X) = E[(X, μ)²], where μ = E[X] is the expected value (mean). For a discrete random variable, this expands to σ² = Σ (x, μ)² P(x). Each possible value x is subtracted from the mean, squared, then multiplied by its probability P(x), and all those products are summed. The result is a non-negative number in squared units. A variance of zero means every outcome is identical: there is no spread at all.

OpenStax Introductory Statistics section 4.2 gives this exact formula as the definition of variance for a discrete random variable. The notation σ² (sigma squared) is used for population variance. If you are working with a probability distribution from a textbook or exam problem, this is the formula to apply when you have the full probability distribution.

Shortcut Formula: Var(X) = E[X²], μ²

The shortcut formula Var(X) = E[X²], μ² is algebraically equivalent to the definition but often easier to compute. You calculate the expected value of X², then subtract the square of the expected value of X. For a discrete random variable, E[X²] = Σ x² P(x). The mean μ is Σ x P(x).

Why Use the Shortcut

When you have a table of x and P(x), squaring each x and multiplying by P(x) is straightforward. The alternative, computing (x, μ)² for every x, requires you to subtract the mean first, which adds a step and introduces rounding error if you keep only a few decimal places for μ. The shortcut gives the same result and is less prone to arithmetic mistakes.

Worked Example: Dice Game

Consider a dice game where the payout X in dollars is: $1 for rolling 1, 2, or 3; $5 for rolling 4 or 5; $10 for rolling 6. The probability distribution is:

  • x = 1, P(x) = 3/6 = 0.5
  • x = 5, P(x) = 2/6 ≈ 0.3333
  • x = 10, P(x) = 1/6 ≈ 0.1667

First, find the mean: μ = (1 × 0.5) + (5 × 0.3333) + (10 × 0.1667) = 0.5 + 1.6667 + 1.6667 = 3.8334.5) + (25 × 0.3333) + (100 × 0.1667) = 0.5 + 8.3333 + 16.6667 = 25.5. Now use the shortcut: Var(X) = E[X²] - μ² = 25.5 - (3.8334)² = 25.5 - 14.694 = 10.806 dollars squared. The standard deviation is √10.806 ≈ 3.29 dollars.

1667 = (8.027) × 0.5 + (1.361) × 0.3333 + (38.028) × 0.1667 = 4.0135 + 0.4537 + 6.3380 = 10.8052. The small difference is from rounding.

Worked Example: Two-Asset Portfolio Variance

Finance students computing portfolio risk need the two-asset portfolio variance formula. Markowitz's 1952 paper "Portfolio Selection" gives it as σ²_p = w₁²σ₁² + w₂²σ₂² + 2w₁w₂σ₁σ₂ρ₁₂, where w are portfolio weights, σ² are variances, and ρ is the correlation coefficient.

Example: Stock A has a variance of return of 0.04 (20% standard deviation) and Stock B has a variance of 0.09 (30% standard deviation). You invest 60% in A and 40% in B. The correlation between them is 0.3. Portfolio variance = (0.6)² × 0.04 + (0.4)² × 0.09 + 2 × 0.6 × 0.4 × √0.04 × √0.09 × 0.3 = 0.0144 + 0.0144 + 2 × 0.6 × 0.4 × 0.2 × 0.3 × 0.3 = 0.0288 + 0.00864 = 0.03744. The portfolio standard deviation is √0.03744 ≈ 0.1935 or 19.35%.

If you forgot the covariance term, you would compute 0.0144 + 0.0144 = 0.0288, which underestimates risk by about 23%. The covariance term is not optional.

Rules: Var(aX + b) = a²Var(X) and Var(X + Y) for Independent X and Y

These properties of variance let you compute variance after transforming random variables without redoing the full calculation.

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

Adding a constant b shifts all values but does not change spread. Multiplying by a constant a multiplies spread by |a|, and variance by a². This is why scaling a data set changes variance by the square of the scaling factor.

Var(X + Y) for Independent X and Y

For independent random variables, Var(X + Y) = Var(X) + Var(Y). Blitzstein & Hwang, Introduction to Probability (2nd ed., 2019), states this as a consequence of the general formula Var(X + Y) = Var(X) + Var(Y) + 2 Cov(X, Y). When X and Y are independent, the covariance term is zero. This rule is critical for portfolio risk, combining measurement errors, and adding independent sources of variation.

Failure case: If you apply Var(X + Y) = Var(X) + Var(Y) to variables that are not independent, you omit the covariance term and get the wrong variance. This is a common error in statistics courses.

Variance of Common Distributions: Binomial, Poisson, Uniform

Each common probability distribution has a closed-form variance formula derived from its parameters. You use these instead of recalculating from the definition every time.

Binomial Distribution

OpenStax Introductory Statistics section 4.3 gives binomial variance as σ² = np(1-p), where n is the number of trials and p is the probability of success. The mean is np. For example, if you flip a fair coin (p=0.5) 100 times, the variance of the number of heads is 100 × 0.5 × 0.5 = 25. The standard deviation is 5.

Poisson Distribution

The Poisson distribution has variance equal to its mean λ. If the average number of events per hour is 10, the variance is also 10, and the standard deviation is √10.

Uniform Distribution (Discrete)

For a discrete uniform distribution on integers from a to b, the variance is ((b, a + 1)², 1) / 12. For rolling a fair six-sided die (a=1, b=6), variance = (36-1) / 12 = 35/12.

Sample Variance vs. Distribution Variance

The variance of a random variable is a population parameter: it uses the true probabilities from the distribution. Sample variance, written s², estimates the population variance from a data set. The formula for sample variance is s² = (1/(n-1)) Σ (x_i, x̄)². Casella & Berger, Statistical Inference (2nd ed., 2002), shows that this is an unbiased estimator of σ².

The n-1 Denominator

The denominator n-1 is Bessel's correction. Using n would make the sample variance on average too low, because the sample mean is closer to the data than the population mean is. The degrees of freedom lost is one because the mean is estimated from the data. You do not need to prove unbiasedness to compute s², but you must use n-1. On a TI-84, the 1-Var Stats command outputs both Sx (sample standard deviation, n-1) and σx (population standard deviation, n). Students frequently report σx when the problem asks for the sample statistic.

In Excel, VAR.S computes sample variance (n-1), and VAR.P computes population variance (n). Using VAR.P on a sample underestimates the true spread. Google Docs Editors Help and Microsoft Support both document these functions identically: VAR.S for samples, VAR.P for populations.

Common Questions

What is the variance of a random variable?

Variance is the average of the squared deviations from the mean. For a discrete random variable, it is Σ (x, μ)² P(x).

What is the shortcut formula for variance?

The shortcut formula is Var(X) = E[X²], μ². It avoids subtracting the mean from each value before squaring.

What is the variance of a binomial distribution?

For a binomial distribution with n trials and success probability p, the variance is np(1-p). OpenStax section 4.3 gives this formula.

What is the difference between VAR.S and VAR.P in Excel?

VAR.S computes sample variance using n-1. VAR.P computes population variance using n. Using VAR.P on a sample gives a biased underestimate of the population variance.

What are the properties of variance?

Var(aX + b) = a²Var(X). For independent X and Y, Var(X + Y) = Var(X) + Var(Y). Adding a constant does not change variance.

Why does sample variance use n-1?

The n-1 denominator, called Bessel's correction, makes s² an unbiased estimator of σ². Using n would make the sample variance too low on average.

How do I interpret variance in real units?

Variance is in squared units. You cannot interpret it in the original units; take the square root to get standard deviation, which is in the original units.