§ 01What Is Expected Value?
Expected value is the long-run average. It answers: if you repeated this experiment infinitely many times and averaged all the outcomes, what number would you converge to?
Suppose you roll a fair six-sided die. The possible outcomes are 1, 2, 3, 4, 5, 6, each equally likely. If you roll 600 times, you expect roughly 100 of each. The average score you expect is (1+2+3+4+5+6)/6 = 3.5. This is the expected value E[X], the probability-weighted average of all possible outcomes.
Expected value is also called the mean, the population mean, or the first moment of the distribution. It is denoted E[X], μ (mu), or ⟨X⟩ depending on the textbook. Throughout this page we use E[X] and μ interchangeably.
One important subtlety: the expected value need not be a value that X can actually take. The die example gives E[X] = 3.5, which is not a possible roll. Expected value describes the distribution as a whole, not any single outcome.
Expected value is defined for both discrete and continuous random variables. The formulas look different, a sum versus an integral, but the underlying idea is identical: a probability-weighted average.
§ 02Expected Value — Definition & Properties
Discrete random variable
For a discrete random variable X taking values in a countable set:
The sum runs over every value x in the range of X. Each value x is weighted by its probability P(X = x).
Continuous random variable
For a continuous random variable X with probability density function (PDF) f(x):
The integral plays the role of the sum: it weights each value x by its density f(x). You will need this form when studying the normal distribution, exponential distribution, and others.
Expected value of a function — LOTUS
A theorem called the Law of the Unconscious Statistician (LOTUS) lets us compute E[g(X)] without first finding the distribution of g(X):
This is essential for computing variance (where g(x) = (x − μ)² or g(x) = x²) and for moments in general.
Linearity of Expectation
The single most important property of expected value is its linearity. It holds regardless of whether X and Y are independent:
Non-linearity for products
Expectation is not linear for products unless X and Y are independent:
In general, E[XY] = E[X]E[Y] + Cov(X, Y), where Cov is the covariance (covered in §06).
§ 03Variance & Standard Deviation
Variance measures how spread out a distribution is, how far values of X tend to stray from the mean. Standard deviation is its square root, expressed in the same units as X.
Definition
Expanded using LOTUS for a discrete X:
The Computational Shortcut
Expanding (x − μ)² = x² − 2μx + μ² and applying linearity of expectation yields the most practical formula:
In words: mean of the squares minus the square of the mean. This avoids computing each (x − μ)² separately and is the standard approach in virtually all exam calculations.
Standard Deviation
Standard deviation is always non-negative. It equals zero if and only if X is a constant (a degenerate random variable with no randomness). The standard deviation is in the same units as X, making it the preferred measure of spread when communicating results.
Properties of Variance
The most important point above: adding a constant does not change variance. Only multiplying by a constant changes spread: and the effect is squared (multiply by a, variance multiplies by a²).
Variance for Continuous Random Variables
The computational shortcut E[X²] − (E[X])² applies equally for continuous random variables: only the method of computing E[X²] changes (integral instead of sum).
§ 04Interactive Visualiser
The chart below shows a custom discrete distribution over the values 1 through 8. Adjust the sliders to reshape the distribution and watch how E[X], Var[X], and σ respond in real time. Notice how spreading probability into the tails increases variance while keeping E[X] fixed when the distribution remains symmetric.
Reshape the distribution — observe E[X] and Var[X] live
Experiment: set all weights equal to see a uniform distribution. Then set all weight on a single value to see a degenerate distribution with Var[X] = 0. Try concentrating probability at the extremes (values 1 and 8) to maximise variance.
§ 05Quick Reference — Formulas for Named Distributions
Here are the E[X] and Var[X] formulas for the most common discrete distributions you will encounter. Each is derived by applying the definitions above to the specific PMF.
| Distribution | Parameters | E[X] | Var[X] |
|---|---|---|---|
| Discrete Uniform | {a, a+1, …, b} | (a + b) / 2 | ((b−a+1)² − 1) / 12 |
| Binomial | n, p | np | np(1−p) |
| Poisson | λ | λ | λ |
| Geometric | p | 1/p | (1−p) / p² |
| Negative Binomial | r, p | r/p | r(1−p) / p² |
| Hypergeometric | N, K, n | nK/N | nK(N−K)(N−n) / N²(N−1) |
| Uniform (cts) | [a, b] | (a + b) / 2 | (b − a)² / 12 |
| Exponential (cts) | λ | 1/λ | 1/λ² |
| Normal (cts) | μ, σ² | μ | σ² |
Var[aX+b] = a²σ²
Var[X+Y] = Var[X]+Var[Y]
§ 06Covariance — How Two Variables Move Together
Covariance measures the degree to which two random variables X and Y move in the same direction. Positive covariance means they tend to be above their means together; negative covariance means one tends to be above when the other is below.
Computational formula for covariance
Expanding the definition using LOTUS yields the computationally convenient form:
Notice that if X and Y are independent, then E[XY] = E[X]·E[Y] and so Cov(X, Y) = 0. The converse is not always true: zero covariance does not imply independence (it only implies uncorrelatedness).
Properties of Covariance
The first property is elegant: the covariance of a variable with itself is its variance. The last two generalize the variance addition rule for sums and differences of any two random variables, dependent or not.
General sum formula
For a linear combination of n random variables X₁, X₂, …, Xₙ:
When all variables are mutually independent, all covariance terms vanish and the formula reduces to Var[Σ aᵢXᵢ] = Σ aᵢ² Var[Xᵢ].
§ 07Correlation — Standardised Association
The Pearson correlation coefficient ρ (rho) standardises covariance so it lies between −1 and 1, making it directly interpretable as a measure of linear association:
Interpreting ρ
| Value of ρ | Interpretation |
|---|---|
| ρ = +1 | Perfect positive linear relationship: Y = aX + b with a > 0 |
| 0 < ρ < 1 | Positive association: X above its mean tends to go with Y above its mean |
| ρ = 0 | No linear association (but could still be a nonlinear relationship) |
| −1 < ρ < 0 | Negative association: X above its mean tends to go with Y below its mean |
| ρ = −1 | Perfect negative linear relationship: Y = aX + b with a < 0 |
Properties of Correlation
- −1 ≤ ρ(X, Y) ≤ 1 always (follows from the Cauchy-Schwarz inequality)
- ρ(X, Y) = ρ(Y, X), it is symmetric
- ρ(aX + b, cY + d) = sign(ac) · ρ(X, Y): correlation is unaffected by linear transformations except for sign changes
- If X and Y are independent, then ρ = 0. The converse is false in general.
§ 08Worked Examples
Twelve fully worked examples covering every formula and technique on this page.
- E[X] = Σ x · P(X=x)
- E[X] = 0(0.1) + 1(0.4) + 2(0.3) + 3(0.2)
- = 0 + 0.4 + 0.6 + 0.6 = 1.6
- First compute E[X²] via LOTUS (g(x) = x²):
E[X²] = 0²(0.1) + 1²(0.4) + 2²(0.3) + 3²(0.2) = 0 + 0.4 + 1.2 + 1.8 = 3.4 - Apply the shortcut:
Var[X] = E[X²] − (E[X])² = 3.4 − (1.6)² = 3.4 − 2.56 = 0.84 - Standard deviation: σ = √0.84 ≈ 0.917
- Apply linearity of expectation (no independence required):
- E[4X − 2Y + 5] = 4·E[X] − 2·E[Y] + 5
- = 4(3) − 2(7) + 5 = 12 − 14 + 5 = 3
- Var[aX + bY + c] = a²Var[X] + b²Var[Y] when X, Y independent (constants vanish):
- Var[3X − 2Y + 1] = 3²·Var[X] + (−2)²·Var[Y]
- = 9(4) + 4(9) = 36 + 36 = 72
- Note: the +1 contributes nothing to variance.
- Var[X + Y] = Var[X] + Var[Y] + 2Cov(X,Y):
= 5 + 3 + 2(−2) = 8 − 4 = 4 - Var[X − Y] = Var[X] + Var[Y] − 2Cov(X,Y):
= 5 + 3 − 2(−2) = 8 + 4 = 12
- E[X] = 0(0.1+0.2) + 1(0.3+0.4) = 0 + 0.7 = 0.7
- E[Y] = 0(0.1+0.3) + 1(0.2+0.4) = 0 + 0.6 = 0.6
- E[XY] = Σ xy·P(X=x,Y=y) = 0(0.1)+0(0.2)+0(0.3)+1·1(0.4) = 0.4
- Cov(X,Y) = E[XY] − E[X]E[Y] = 0.4 − (0.7)(0.6) = 0.4 − 0.42 = −0.02
- σX = √9 = 3, σY = √16 = 4
- ρ(X,Y) = Cov(X,Y) / (σX·σY) = 6 / (3·4) = 6/12 = 0.5
- E[X] = (1+2+3+4)/4 = 10/4 = 2.5
- E[X²] = (1²+2²+3²+4²)/4 = (1+4+9+16)/4 = 30/4 = 7.5
- Var[X] = E[X²] − (E[X])² = 7.5 − 6.25 = 1.25
- σ = √1.25 = √(5/4) = √5/2 ≈ 1.118
- E[Z] = E[(X−10)/5] = (E[X] − 10)/5 = (10−10)/5 = 0
- Var[Z] = Var[(X−10)/5] = (1/5)²·Var[X] = (1/25)·25 = 1
- Z is the standardised version of X: mean 0, variance 1. This is the foundation of z-scores used in the normal distribution.
- E[X] = np = 10(0.3) = 3; E[Y] = 15(0.3) = 4.5
- E[X+Y] = E[X]+E[Y] = 3 + 4.5 = 7.5
- Var[X] = np(1−p) = 10(0.3)(0.7) = 2.1
- Var[Y] = 15(0.3)(0.7) = 3.15
- Since X and Y are independent: Var[X+Y] = 2.1 + 3.15 = 5.25
- Note: X+Y ~ B(25, 0.3), the sum of independent Binomials with the same p is also Binomial.
- Apply LOTUS with g(x) = 2x:
- E[2X] = 2¹·(1/3) + 2²·(1/3) + 2³·(1/3)
- = (2 + 4 + 8)/3 = 14/3 ≈ 4.667
- Note: E[2X] ≠ 2E[X] = 2² = 4. Jensen's inequality says E[g(X)] ≥ g(E[X]) for convex g.
- E[X] = 2(0.6) + (−1)(0.4) = 1.2 − 0.4 = 0.8
- E[X²] = 4(0.6) + 1(0.4) = 2.4 + 0.4 = 2.8
- Var[X] = 2.8 − 0.64 = 2.16; σX = √2.16 ≈ 1.470
- E[Y] = E[3X+5] = 3(0.8)+5 = 7.4
- Var[Y] = Var[3X+5] = 9·Var[X] = 9(2.16) = 19.44; σY = 3σX ≈ 4.409
- Cov(X,Y) = Cov(X, 3X+5) = 3·Cov(X,X) = 3·Var[X] = 3(2.16) = 6.48
- ρ(X,Y) = Cov(X,Y)/(σX·σY) = 6.48/(1.470·4.409) ≈ 6.48/6.48 = 1
- ρ = 1 because Y = 3X+5 is a perfect positive linear function of X: no surprise!
§ 09Common Mistakes
§ 1010-Question Quiz
Select one answer per question, then click Check All Answers to see your score and full explanations.
§ 11Continue in Probability & Beyond
Expected value and variance are the foundation of almost every topic that follows: from named distributions to statistical inference and regression. Here are the most important next steps.