Skip to content

Discrete random variables

A random variable assigns a numerical value to each outcome of a random experiment. It is discrete when its possible values can be listed, even if the list is infinite.

For example, if XX is the number of sixes in four rolls of a die, then

X{0,1,2,3,4}.X\in\{0,1,2,3,4\}.

The value of XX is not known until the experiment happens, but each possible value has a probability. Those values and probabilities form the probability distribution of XX.

This lesson explains how to construct and use discrete distributions, including their mean, variance and standard deviation.

You should be able to:

  • calculate probabilities using probability rules;
  • recognise mutually exclusive outcomes;
  • use sigma notation such as x\sum x;
  • calculate a mean and variance from a frequency table.

An outcome describes what happens. A random variable records a numerical feature of what happens.

Suppose two fair coins are tossed. The equally likely outcomes are

HH, HT, TH, TT.HH,\ HT,\ TH,\ TT.

Define XX to be the number of heads. Then

X(HH)=2,X(HT)=X(TH)=1,X(TT)=0.X(HH)=2,\qquad X(HT)=X(TH)=1,\qquad X(TT)=0.

The outcomes HTHT and THTH are different, but they give the same value of XX. Combining outcomes with equal XX values gives

xx001122
P(X=x)\operatorname{P}(X=x)14\frac1412\frac1214\frac14

This is a probability distribution.

A discrete variable takes separate, countable values. A continuous variable can take any value in an interval.

VariableTypeReason
Number of emails receivedDiscreteTakes values 0,1,2,0,1,2,\ldots
Mass of an appleContinuousCan take any value in a measurement interval
Score on a ten question testDiscreteTakes integer values from 00 to 1010
Time until a bus arrivesContinuousCan take any non-negative real value

A rounded measurement is still modelled as continuous if the underlying quantity is continuous.

A spinner is spun three times. Let RR be the number of red results. Is RR discrete or continuous, and what values can it take?

Answer

RR is discrete because it is a count. Its possible values are

R{0,1,2,3}.\boxed{R\in\{0,1,2,3\}}.

For a discrete random variable XX, write

p(x)=P(X=x).p(x)=\operatorname{P}(X=x).

Every probability distribution must satisfy two conditions:

0p(x)1for every x\boxed{0\leq p(x)\leq1\quad\text{for every }x}

and

p(x)=1.\boxed{\sum p(x)=1}.

The second condition holds because the possible values of XX are mutually exclusive and exhaustive: exactly one of them must occur.

Worked example 1: finding an unknown probability

Section titled “Worked example 1: finding an unknown probability”

The distribution of XX is shown below.

xx00112233
P(X=x)\operatorname{P}(X=x)0.150.15kk2k2k0.250.25

Find kk.

The probabilities sum to 11:

0.15+k+2k+0.25=1.0.15+k+2k+0.25=1.

Therefore

3k=0.603k=0.60

and

k=0.20.\boxed{k=0.20}.

Check that every resulting probability lies between 00 and 11.

Worked example 2: a distribution given by a formula

Section titled “Worked example 2: a distribution given by a formula”

A random variable YY has probability function

P(Y=y)=ky,y=1,2,3,4.\operatorname{P}(Y=y)=ky, \qquad y=1,2,3,4.

Find kk and P(Y3)\operatorname{P}(Y\geq3).

First use the total probability:

y=14ky=k(1+2+3+4)=10k=1.\begin{aligned} \sum_{y=1}^{4}ky &=k(1+2+3+4)\\ &=10k=1. \end{aligned}

Hence k=1/10k=1/10. Now

P(Y3)=P(Y=3)+P(Y=4)=310+410=710.\begin{aligned} \operatorname{P}(Y\geq3) &=\operatorname{P}(Y=3)+\operatorname{P}(Y=4)\\ &=\frac3{10}+\frac4{10}\\ &=\boxed{\frac7{10}}. \end{aligned}

For x=0,1,2,3x=0,1,2,3, suppose

P(X=x)=a(x+1).\operatorname{P}(X=x)=a(x+1).

Find aa and P(X<2)\operatorname{P}(X<2).

Answer

Since the probabilities sum to 11,

a(1+2+3+4)=10a=1,a(1+2+3+4)=10a=1,

so a=1/10a=1/10. Therefore

P(X<2)=P(X=0)+P(X=1)=110+210=310.\operatorname{P}(X<2) =\operatorname{P}(X=0)+\operatorname{P}(X=1) =\frac1{10}+\frac2{10} =\boxed{\frac3{10}}.

Calculating probabilities from a distribution

Section titled “Calculating probabilities from a distribution”

Translate the wording into an inequality before adding probabilities.

WordsProbability statement
exactly aaP(X=a)\operatorname{P}(X=a)
at most aaP(Xa)\operatorname{P}(X\leq a)
fewer than aaP(X<a)\operatorname{P}(X<a)
at least aaP(Xa)\operatorname{P}(X\geq a)
more than aaP(X>a)\operatorname{P}(X>a)
from aa to bb inclusiveP(aXb)\operatorname{P}(a\leq X\leq b)

For integer-valued XX,

P(X<4)=P(X3),\operatorname{P}(X<4)=\operatorname{P}(X\leq3),

but P(X<4)\operatorname{P}(X<4) and P(X4)\operatorname{P}(X\leq4) are not the same.

Worked example 3: interval and complement probabilities

Section titled “Worked example 3: interval and complement probabilities”

The probability distribution of XX is

xx1122334455
P(X=x)\operatorname{P}(X=x)0.100.100.250.250.300.300.200.200.150.15

Find:

  1. P(2<X5)\operatorname{P}(2<X\leq5);
  2. P(X3)\operatorname{P}(X\neq3).

For the first probability, include 3,4,53,4,5 but not 22:

P(2<X5)=0.30+0.20+0.15=0.65.\operatorname{P}(2<X\leq5)=0.30+0.20+0.15=\boxed{0.65}.

For the second, a complement is shorter:

P(X3)=1P(X=3)=10.30=0.70.\operatorname{P}(X\neq3)=1-\operatorname{P}(X=3)=1-0.30=\boxed{0.70}.

The cumulative distribution function of XX is

F(x)=P(Xx).\boxed{F(x)=\operatorname{P}(X\leq x)}.

It accumulates probability from the smallest possible value up to xx. For a discrete random variable, FF is a step function.

Using the previous distribution,

xx1122334455
P(X=x)\operatorname{P}(X=x)0.100.100.250.250.300.300.200.200.150.15
F(x)F(x)0.100.100.350.350.650.650.850.8511

Differences of cumulative probabilities give interval probabilities. For integer-valued XX,

P(aXb)=F(b)F(a1).\boxed{\operatorname{P}(a\leq X\leq b)=F(b)-F(a-1)}.

For example,

P(3X4)=F(4)F(2)=0.850.35=0.50.\operatorname{P}(3\leq X\leq4)=F(4)-F(2)=0.85-0.35=0.50.

The expected value or mean of a discrete random variable is

E(X)=xP(X=x).\boxed{\operatorname{E}(X)=\sum x\operatorname{P}(X=x)}.

Each value is weighted by its probability. If the experiment is repeated many times, the mean of the observed XX values tends towards E(X)\operatorname{E}(X).

The expected value need not be a possible outcome. A fair die has expected score 3.53.5, although no single roll can produce 3.53.5.

Worked example 4: expected value from a table

Section titled “Worked example 4: expected value from a table”

A game pays XX pounds, with distribution

xx0022551010
P(X=x)\operatorname{P}(X=x)0.500.500.300.300.150.150.050.05

Then

E(X)=0(0.50)+2(0.30)+5(0.15)+10(0.05)=0+0.60+0.75+0.50=1.85.\begin{aligned} \operatorname{E}(X) &=0(0.50)+2(0.30)+5(0.15)+10(0.05)\\ &=0+0.60+0.75+0.50\\ &=\boxed{1.85}. \end{aligned}

Over many plays, the average payout approaches £1.85 per play.

If the game costs £2 to play, the player’s net gain is G=X2G=X-2, so

E(G)=1.852=0.15.\operatorname{E}(G)=1.85-2=-0.15.

The player loses an average of 15 pence per play in the long run. This does not mean every play loses 15 pence.

Worked example 5: finding a parameter from the mean

Section titled “Worked example 5: finding a parameter from the mean”

The distribution of YY is

yy001144
P(Y=y)\operatorname{P}(Y=y)pp2p2p13p1-3p

Given that E(Y)=2\operatorname{E}(Y)=2, find pp.

Use the values as weights:

E(Y)=0(p)+1(2p)+4(13p)=410p.\begin{aligned} \operatorname{E}(Y) &=0(p)+1(2p)+4(1-3p)\\ &=4-10p. \end{aligned}

Therefore

410p=2,4-10p=2,

so

p=0.2.\boxed{p=0.2}.

The probabilities are then 0.2,0.4,0.40.2,0.4,0.4, which are valid and sum to 11.

A fair spinner has labels 1,1,2,61,1,2,6 on four equal sectors. Let XX be the label obtained. Find E(X)\operatorname{E}(X).

Answer

The distribution is

P(X=1)=12,P(X=2)=14,P(X=6)=14.\operatorname{P}(X=1)=\frac12,\qquad \operatorname{P}(X=2)=\frac14,\qquad \operatorname{P}(X=6)=\frac14.

Hence

E(X)=1(12)+2(14)+6(14)=52.\operatorname{E}(X) =1\left(\frac12\right)+2\left(\frac14\right)+6\left(\frac14\right) =\boxed{\frac52}.

Expectation gives the centre of a distribution. Variance measures its spread about that centre.

If μ=E(X)\mu=\operatorname{E}(X), then

Var(X)=E((Xμ)2)=(xμ)2P(X=x).\operatorname{Var}(X)=\operatorname{E}\bigl((X-\mu)^2\bigr) =\sum (x-\mu)^2\operatorname{P}(X=x).

The efficient formula is

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

where

E(X2)=x2P(X=x).\boxed{\operatorname{E}(X^2)=\sum x^2\operatorname{P}(X=x)}.

The standard deviation is

SD(X)=Var(X).\boxed{\operatorname{SD}(X)=\sqrt{\operatorname{Var}(X)}}.

Variance has squared units, while standard deviation has the same units as XX.

Worked example 6: mean, variance and standard deviation

Section titled “Worked example 6: mean, variance and standard deviation”

Let XX have distribution

xx00112233
P(X=x)\operatorname{P}(X=x)0.100.100.200.200.400.400.300.30

First calculate the mean:

E(X)=0(0.10)+1(0.20)+2(0.40)+3(0.30)=1.9.\begin{aligned} \operatorname{E}(X) &=0(0.10)+1(0.20)+2(0.40)+3(0.30)\\ &=1.9. \end{aligned}

Next calculate the second moment:

E(X2)=02(0.10)+12(0.20)+22(0.40)+32(0.30)=0+0.20+1.60+2.70=4.5.\begin{aligned} \operatorname{E}(X^2) &=0^2(0.10)+1^2(0.20)+2^2(0.40)+3^2(0.30)\\ &=0+0.20+1.60+2.70\\ &=4.5. \end{aligned}

Therefore

Var(X)=4.5(1.9)2=0.89,\begin{aligned} \operatorname{Var}(X) &=4.5-(1.9)^2\\ &=\boxed{0.89}, \end{aligned}

and

SD(X)=0.89=0.9430.943.\operatorname{SD}(X)=\sqrt{0.89}=0.943\ldots\approx\boxed{0.943}.

For longer distributions, organise the work in columns:

xxppxpxpx2px^2p
possible valueprobabilitycontribution to E(X)\operatorname{E}(X)contribution to E(X2)\operatorname{E}(X^2)

Then add the third and fourth columns. This reduces omitted terms and calculator input errors.

For the random variable XX below, find Var(X)\operatorname{Var}(X).

xx113355
P(X=x)\operatorname{P}(X=x)0.250.250.500.500.250.25
Answer E(X)=1(0.25)+3(0.50)+5(0.25)=3,\operatorname{E}(X)=1(0.25)+3(0.50)+5(0.25)=3,

and

E(X2)=1(0.25)+9(0.50)+25(0.25)=11.\operatorname{E}(X^2)=1(0.25)+9(0.50)+25(0.25)=11.

Therefore

Var(X)=1132=2.\boxed{\operatorname{Var}(X)=11-3^2=2}.

Suppose a new variable is defined by

Y=aX+b,Y=aX+b,

where aa and bb are constants. Then

E(Y)=aE(X)+b\boxed{\operatorname{E}(Y)=a\operatorname{E}(X)+b}

and

Var(Y)=a2Var(X).\boxed{\operatorname{Var}(Y)=a^2\operatorname{Var}(X)}.

Adding bb shifts every value equally, so it changes the mean but not the spread. Multiplying by aa multiplies distances from the mean by a|a|, so it multiplies variance by a2a^2.

Consequently,

SD(aX+b)=aSD(X).\operatorname{SD}(aX+b)=|a|\operatorname{SD}(X).

Worked example 7: transforming a random variable

Section titled “Worked example 7: transforming a random variable”

A delivery charge in pounds is modelled by

C=1.2X+3,C=1.2X+3,

where E(X)=8\operatorname{E}(X)=8 and Var(X)=2.5\operatorname{Var}(X)=2.5. Find the mean and standard deviation of CC.

For the mean,

E(C)=1.2(8)+3=12.6.\operatorname{E}(C)=1.2(8)+3=\boxed{12.6}.

For the variance,

Var(C)=1.22(2.5)=3.6.\operatorname{Var}(C)=1.2^2(2.5)=3.6.

Therefore

SD(C)=3.6=1.8971.90.\operatorname{SD}(C)=\sqrt{3.6}=1.897\ldots\approx\boxed{1.90}.

The added £3 affects the mean charge but not its standard deviation.

  • The possible values must have equal probabilities. They do not. Probabilities come from the underlying random experiment.
  • Expectation is the most likely value. Not necessarily. It is a probability-weighted mean and may not be possible at all.
  • E(X2)=[E(X)]2\operatorname{E}(X^2)=[\operatorname{E}(X)]^2. Usually these differ. Their difference is the variance.
  • Adding a constant increases variance. It shifts the distribution without changing its spread.
  • Var(aX)=aVar(X)\operatorname{Var}(aX)=a\operatorname{Var}(X). Variance scales by a2a^2.
  • At most and fewer than mean the same thing. At most includes the boundary; fewer than excludes it.

A random variable XX has probability function

P(X=x)=k(5x),x=1,2,3,4.\operatorname{P}(X=x)=k(5-x), \qquad x=1,2,3,4.
  1. Find kk.
  2. Find P(X3)\operatorname{P}(X\geq3).
  3. Find E(X)\operatorname{E}(X).
  4. Find Var(X)\operatorname{Var}(X).
Answers

The probability weights are 4k,3k,2k,k4k,3k,2k,k. Hence

10k=1k=0.1.10k=1\quad\Longrightarrow\quad \boxed{k=0.1}.

Then

P(X3)=0.2+0.1=0.3.\operatorname{P}(X\geq3)=0.2+0.1=\boxed{0.3}.

The mean is

E(X)=1(0.4)+2(0.3)+3(0.2)+4(0.1)=2.\begin{aligned} \operatorname{E}(X) &=1(0.4)+2(0.3)+3(0.2)+4(0.1)\\ &=\boxed{2}. \end{aligned}

Also,

E(X2)=12(0.4)+22(0.3)+32(0.2)+42(0.1)=5.\operatorname{E}(X^2) =1^2(0.4)+2^2(0.3)+3^2(0.2)+4^2(0.1) =5.

Therefore

Var(X)=522=1.\boxed{\operatorname{Var}(X)=5-2^2=1}.

For a discrete random variable XX:

P(X=x)=1,\sum\operatorname{P}(X=x)=1, E(X)=xP(X=x),\operatorname{E}(X)=\sum x\operatorname{P}(X=x), Var(X)=x2P(X=x)[E(X)]2.\operatorname{Var}(X)=\sum x^2\operatorname{P}(X=x)-[\operatorname{E}(X)]^2.

Always define the random variable, check that probabilities are valid, and translate boundary language before calculating.