Variance of a Random Variable

Variance measures how spread out a random variable's values are around its mean, using the formula Var(X) = E(X²) - [E(X)]².

Var(X)=E(X2)[E(X)]2\operatorname{Var}(X) = E(X^2) - \big[E(X)\big]^2

Solve a problem with Variance of a Random Variable

Type the problem. The solver will use Variance of a Random Variable where Variance of a Random Variable is the right tool, and tell you when it is not.

Drag one in or paste from the clipboard. JPEG, PNG or WebP. You get the transcription to check before anything is solved.

How to get a better answer
  • Paste the whole problem, including the instruction word — "simplify", "solve for x" and "factor" lead to three different answers.
  • Say what you have already tried. "I got x = 4 and the book says 2" turns a solution into a diagnosis.
  • Set the level in the settings button. A calculus shortcut is not a better answer if you have not met derivatives yet.
  • For a photo, get the whole problem in frame and hold the page flat — you get the transcription to fix before anything is solved.

What each symbol means

What Variance of a Random Variable takes
XX
Variance of a Random Variable
SymbolMeaning
XXA random variable representing the outcomes of a random experiment; it can be discrete (like a die roll) or continuous (like a weight), and the variance tells you how far its values typically scatter from the mean.

When to use it

Use variance when you need to quantify how much a random variable typically deviates from its expected value.

Level

Usually taught in: Statistics

Worked examples

1. Heads in two fair coin flips

Problem

A fair coin is flipped twice. Let XX be the number of heads. Find Var(X)\operatorname{Var}(X).
  1. X{0,1,2},P(X=0)=14,P(X=1)=12,P(X=2)=14X \in \{0, 1, 2\}, \quad P(X=0) = \tfrac{1}{4}, \quad P(X=1) = \tfrac{1}{2}, \quad P(X=2) = \tfrac{1}{4}

    The sample space has four equally likely outcomes: HH (2 heads), HT and TH (1 head each), and TT (0 heads).

  2. E(X)=014+112+214=12+12=1E(X) = 0 \cdot \tfrac{1}{4} + 1 \cdot \tfrac{1}{2} + 2 \cdot \tfrac{1}{4} = \tfrac{1}{2} + \tfrac{1}{2} = 1

    Calculate the expected value by multiplying each outcome by its probability and summing.

  3. E(X2)=0214+1212+2214=12+1=32E(X^2) = 0^2 \cdot \tfrac{1}{4} + 1^2 \cdot \tfrac{1}{2} + 2^2 \cdot \tfrac{1}{4} = \tfrac{1}{2} + 1 = \tfrac{3}{2}

    Calculate the expected value of X2X^2 by squaring each outcome first, then applying the same weighting.

  4. Var(X)=E(X2)[E(X)]2=3212=12\operatorname{Var}(X) = E(X^2) - [E(X)]^2 = \tfrac{3}{2} - 1^2 = \tfrac{1}{2}

    Apply the variance formula: subtract the square of the mean from the expected value of the square.

Answer: Var(X)=12\operatorname{Var}(X) = \tfrac{1}{2}

This formula directly applies the definition of variance using the shortcut formula. The positive result confirms that the number of heads does vary from its expected value of 1.

2. Variance with negative values and fractions

Problem

A discrete random variable XX takes values 2-2, 00, and 33 with probabilities 14\tfrac{1}{4}, 12\tfrac{1}{2}, and 14\tfrac{1}{4} respectively. Find Var(X)\operatorname{Var}(X).
  1. E(X)=(2)14+012+314=12+0+34=14E(X) = (-2) \cdot \tfrac{1}{4} + 0 \cdot \tfrac{1}{2} + 3 \cdot \tfrac{1}{4} = -\tfrac{1}{2} + 0 + \tfrac{3}{4} = \tfrac{1}{4}

    Multiply each value by its probability; negative values keep their sign.

  2. E(X2)=(2)214+0212+3214=1+0+94=134E(X^2) = (-2)^2 \cdot \tfrac{1}{4} + 0^2 \cdot \tfrac{1}{2} + 3^2 \cdot \tfrac{1}{4} = 1 + 0 + \tfrac{9}{4} = \tfrac{13}{4}

    When squaring negative values, they become positive: (2)2=4(-2)^2 = 4, so negative outcomes still contribute positively to E(X2)E(X^2).

  3. [E(X)]2=(14)2=116[E(X)]^2 = \left(\tfrac{1}{4}\right)^2 = \tfrac{1}{16}

    Square the mean—not the individual terms, but the result E(X)=14E(X) = \tfrac{1}{4}.

  4. Var(X)=134116=5216116=5116\operatorname{Var}(X) = \tfrac{13}{4} - \tfrac{1}{16} = \tfrac{52}{16} - \tfrac{1}{16} = \tfrac{51}{16}

    Convert to a common denominator: 134=5216\tfrac{13}{4} = \tfrac{52}{16}, then subtract.

Answer: Var(X)=5116=3.1875\operatorname{Var}(X) = \tfrac{51}{16} = 3.1875

This example shows that variance is always non-negative, even when the random variable takes negative values, because we square all deviations in the formula.

3. Point spread in a basketball season

Problem

During a basketball season, a player scored the following points over 5 games: 12, 18, 15, 20, and 10. Treating these as equally likely outcomes, find the variance of the player's scoring.
  1. E(X)=12+18+15+20+105=755=15E(X) = \frac{12 + 18 + 15 + 20 + 10}{5} = \frac{75}{5} = 15

    The expected value is the mean of the five scores.

  2. E(X2)=122+182+152+202+1025=144+324+225+400+1005=11935E(X^2) = \frac{12^2 + 18^2 + 15^2 + 20^2 + 10^2}{5} = \frac{144 + 324 + 225 + 400 + 100}{5} = \frac{1193}{5}

    Square each score, sum them, then divide by the number of games to find the average of the squares.

  3. [E(X)]2=152=225[E(X)]^2 = 15^2 = 225

    Square the mean score.

  4. Var(X)=11935225=1193511255=685=13.6\operatorname{Var}(X) = \frac{1193}{5} - 225 = \frac{1193}{5} - \frac{1125}{5} = \frac{68}{5} = 13.6

    Subtract: convert 225 to fifths (225=11255225 = \frac{1125}{5}) so the subtraction is valid.

Answer: Var(X)=685=13.6 points2\operatorname{Var}(X) = \frac{68}{5} = 13.6 \text{ points}^2

The variance of 13.6 points² tells us that the player's scoring varies considerably from the average of 15 points per game. To describe the spread in the same units (points), we would take the square root to get the standard deviation: 13.63.69\sqrt{13.6} \approx 3.69 points.

Common mistakes

Where Variance of a Random Variable usually goes wrong
Answer came out wrong
Writing Var(X)=E(X2)+[E(X)]2\operatorname{Var}(X) = E(X^2) + [E(X)]^2 (adding instead of subtracting).
Always subtract: Var(X)=E(X2)[E(X)]2\operatorname{Var}(X) = E(X^2) - [E(X)]^2.
Computing E(X2)E(X)E(X^2) - E(X) instead of E(X2)[E(X)]2E(X^2) - [E(X)]^2, forgetting to square the mean.
Calculate E(X)E(X) first, then square that single number to get [E(X)]2[E(X)]^2, not the expectation of XX without squaring.
Computing the formula backwards as [E(X)]2E(X2)[E(X)]^2 - E(X^2), which gives a negative result when the variable is spread out.
Remember the order: E(X2)E(X^2) comes first, then subtract [E(X)]2[E(X)]^2.
The mistakeWhy it is wrongThe fix
Writing Var(X)=E(X2)+[E(X)]2\operatorname{Var}(X) = E(X^2) + [E(X)]^2 (adding instead of subtracting).Addition would artificially inflate the variance and violate the mathematical definition; variance measures deviations from the mean, not a sum of them.Always subtract: Var(X)=E(X2)[E(X)]2\operatorname{Var}(X) = E(X^2) - [E(X)]^2.
Computing E(X2)E(X)E(X^2) - E(X) instead of E(X2)[E(X)]2E(X^2) - [E(X)]^2, forgetting to square the mean.The second term must be the expected value squared, not just the expected value; omitting the square gives a numerically wrong and dimensionally incorrect answer.Calculate E(X)E(X) first, then square that single number to get [E(X)]2[E(X)]^2, not the expectation of XX without squaring.
Computing the formula backwards as [E(X)]2E(X2)[E(X)]^2 - E(X^2), which gives a negative result when the variable is spread out.Variance is always non-negative because it measures spread; a negative result signals that the formula order was reversed.Remember the order: E(X2)E(X^2) comes first, then subtract [E(X)]2[E(X)]^2.

Tips and when to use something else

  • Variance is always non-negative: Var(X)0\operatorname{Var}(X) \geq 0, with equality only when XX is constant.
  • Variance has squared units: if XX is measured in dollars, Var(X)\operatorname{Var}(X) is in dollars²; use the standard deviation σ=Var(X)\sigma = \sqrt{\operatorname{Var}(X)} to describe spread in the original units.
  • When you need to compare spread across random variables with different units or scales, variance is often less intuitive than the standard deviation or coefficient of variation.
  • For a linear transformation, Var(aX+b)=a2Var(X)\operatorname{Var}(aX + b) = a^2 \operatorname{Var}(X) (constant bb disappears, and the coefficient aa is squared)—use this shortcut instead of recomputing from scratch.

Frequently asked questions

What's the difference between variance and standard deviation?
Variance is Var(X)=E(X2)[E(X)]2\operatorname{Var}(X) = E(X^2) - [E(X)]^2, while standard deviation is σ=Var(X)\sigma = \sqrt{\operatorname{Var}(X)}. Standard deviation is in the same units as XX, making it more interpretable; variance is squared, which is why it appears in the shortcut formula.
Why use the formula E(X2)[E(X)]2E(X^2) - [E(X)]^2 instead of computing deviations directly?
The shortcut formula E(X2)[E(X)]2E(X^2) - [E(X)]^2 is algebraically equivalent to the definition E[(XE(X))2]E[(X - E(X))^2] but often faster to compute by hand because you only need E(X)E(X) and E(X2)E(X^2), not the squared deviations from the mean.
Can variance ever be negative?
No, variance is always non-negative because it sums squared deviations. If you calculate a negative variance, you have made an error—most likely reversing the subtraction order or forgetting to square the mean.
How do I know which formula to use, E(X2)[E(X)]2E(X^2) - [E(X)]^2 or the definition with deviations?
Both are correct and equivalent. Use the E(X2)[E(X)]2E(X^2) - [E(X)]^2 formula when you already know the probability distribution, as it requires fewer steps; use the deviation formula E[(Xμ)2]E[(X - \mu)^2] if you want to emphasize how variance measures spread around the mean.

Need a different method?

The full solver is not scoped to one formula — type any problem and it will pick the method.

Open the math solver

Reviewed 2026-09-18