Skip to main content
Examonaut

Topic 1 · Lesson 1 of 3

Expectation and variance

Probability distributions

A probability distribution lists every value xx that XX can take with its probability P(X=x)\text{P}(X = x). It may be given as a table or as a probability function, a formula such as P(X=x)=kx\text{P}(X = x) = kx for x=1,2,3,4x = 1, 2, 3, 4. Either way, two facts always hold:

  • every probability is between 0 and 1;
  • the probabilities add up to 1: ∑P(X=x)=1\sum \text{P}(X = x) = 1.

The second fact is how you find an unknown constant. For P(X=x)=kx\text{P}(X = x) = kx, x=1,2,3,4x = 1, 2, 3, 4: k(1+2+3+4)=1k(1 + 2 + 3 + 4) = 1, so k=110k = \frac{1}{10}.

The cumulative distribution function is F(x)=P(X⩽x)\text{F}(x) = \text{P}(X \leqslant x). To get back to the probabilities, subtract consecutive values: P(X=3)=F(3)−F(2)\text{P}(X = 3) = \text{F}(3) - \text{F}(2).

Expected value

The expected value (or mean) of XX is

E(X)=μ=∑x P(X=x)\text{E}(X) = \mu = \sum x\,\text{P}(X = x)

Multiply each value by its probability and add. For example, if XX takes the values 1, 2, 3, 4 with probabilities 0.2, 0.3, 0.4, 0.1, then

E(X)=1(0.2)+2(0.3)+3(0.4)+4(0.1)=2.4\text{E}(X) = 1(0.2) + 2(0.3) + 3(0.4) + 4(0.1) = 2.4

E(X)\text{E}(X) need not be a value XX can take: no single experiment gives 2.4, but the average of many results will be close to it.

If the distribution is symmetrical, the mean is at the centre of symmetry. A table with P(X=−2)=P(X=2)\text{P}(X = -2) = \text{P}(X = 2) and P(X=−1)=P(X=1)\text{P}(X = -1) = \text{P}(X = 1) has E(X)=0\text{E}(X) = 0 without any calculation.

Expected value of a function of X

For any function gg,

E(g(X))=∑g(x) P(X=x)\text{E}(g(X)) = \sum g(x)\,\text{P}(X = x)

Apply the function to each value, keep the same probabilities, and add. With the distribution above,

E(X2)=1(0.2)+4(0.3)+9(0.4)+16(0.1)=6.6\text{E}(X^2) = 1(0.2) + 4(0.3) + 9(0.4) + 16(0.1) = 6.6

In general E(X2)≠[E(X)]2\text{E}(X^2) \neq [\text{E}(X)]^2 (here 6.6≠5.766.6 \neq 5.76), and E(1X)≠1E(X)\text{E}\left(\frac{1}{X}\right) \neq \frac{1}{\text{E}(X)}. Never "apply the function to the mean".

Variance

The variance measures spread about the mean:

Var(X)=E[(X−μ)2]=E(X2)−[E(X)]2\text{Var}(X) = \text{E}\left[(X - \mu)^2\right] = \text{E}(X^2) - [\text{E}(X)]^2

The second form is the one to use: "the mean of the squares minus the square of the mean". Above, Var(X)=6.6−2.42=0.84\text{Var}(X) = 6.6 - 2.4^2 = 0.84, and the standard deviation is 0.84=0.917\sqrt{0.84} = 0.917.

A variance can never be negative. If you get a negative answer, you have probably subtracted the wrong way round or used E(X)\text{E}(X) instead of E(X2)\text{E}(X^2).

The formula also works backwards: E(X2)=Var(X)+[E(X)]2\text{E}(X^2) = \text{Var}(X) + [\text{E}(X)]^2. If E(X)=4\text{E}(X) = 4 and Var(X)=3\text{Var}(X) = 3, then E(X2)=19\text{E}(X^2) = 19.

Worked example

A probability function

The random variable XX has P(X=x)=k(x+1)\text{P}(X = x) = k(x + 1) for x=0,1,2,3x = 0, 1, 2, 3. Find kk, E(X)\text{E}(X) and Var(X)\text{Var}(X).

Show solution
  1. Probabilities add to 1: k(1+2+3+4)=10k=1k(1 + 2 + 3 + 4) = 10k = 1, so k=0.1k = 0.1.
  2. The distribution is 0.1,0.2,0.3,0.40.1, 0.2, 0.3, 0.4 for x=0,1,2,3x = 0, 1, 2, 3.
  3. E(X)=0+0.2+0.6+1.2=2\text{E}(X) = 0 + 0.2 + 0.6 + 1.2 = 2.
  4. E(X2)=0+0.2+1.2+3.6=5\text{E}(X^2) = 0 + 0.2 + 1.2 + 3.6 = 5, so Var(X)=5−22=1\text{Var}(X) = 5 - 2^2 = 1.

Worked example

Unknown probabilities

The random variable XX takes the values 1, 2, 3, 4 with probabilities pp, 0.30.3, qq, 0.20.2, and E(X)=2.5\text{E}(X) = 2.5. Find pp and qq.

Show solution

Two unknowns need two equations.

  • Sum of probabilities: p+0.3+q+0.2=1p + 0.3 + q + 0.2 = 1, so p+q=0.5p + q = 0.5.
  • Mean: p+0.6+3q+0.8=2.5p + 0.6 + 3q + 0.8 = 2.5, so p+3q=1.1p + 3q = 1.1.

Subtracting, 2q=0.62q = 0.6: q=0.3q = 0.3 and p=0.2p = 0.2. With three unknowns you need a third equation, usually from a given variance, through E(X2)=Var(X)+[E(X)]2\text{E}(X^2) = \text{Var}(X) + [\text{E}(X)]^2.

Practise this topic

Both are part of Premium.