9 Discrete Random Variables
Random Variables
A random variable must take a numerical value:
Examples: the number on a single throw of a die
the height of a person
the number of cars travelling past a fixed point in a certain time
But not the colour of hair as this is not a number
Continuous and discrete random variables
Continuous random variables
A continuous random variable is one which can take any value in a certain interval;
Examples: height, time, weight.
Discrete random variables
A discrete random variable can only take certain values in an interval
Examples: Score on die (1, 2, 3, 4, 5, 6)
Number of coins in pocket (0, 1, 2, ...)
Probability distributions
A probability distribution (or table) is the set of possible outcomes together with their
probabilities, similar to a frequency distribution (or table).
Example:
score on two dice, X 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 5 4 3 2 1
probability, f (x)
36 36 36 36 36 36 36 36 36 36 36
is the probability distribution (table) for the random variable, X, the total score on two dice.
12
Note that the sum of the probabilities must be 1, i.e. ∑ P( X = x) = 1 .
x=2
39
Cumulative probability distribution
Just like cumulative frequencies, the cumulative probability, F, that the total score on two dice
1 2 3 6 1
is less than or equal to 4 is F(4) = P(X ≤ 4) = P(X = 2, 3, 4) = + + = = .
36 36 36 36 6
Note that F(4.3) means P(X ≤ 4.3) and seeing as there are no scores between 4 and 4.3 this is
the same as P(X ≤ 4) = F(4).
You are expected to recognise that capital F (X) means the cumulative probability.
Expectation or expected values
Expected mean or expected value of X.
For a discrete probability distribution the expected mean of X , or the expected value of X is
µ = E[X] = � 𝑥𝑖 𝑝𝑖
Expected value of a function
The expected value of any function, h(X), is defined as
E[X] = � ℎ(𝑥𝑖 )𝑝𝑖
Note that for any constant, k, E[k] = k, since ∑ 𝑘𝑝𝑖 = k ∑ 𝑝𝑖 = k × 1 = k
Expected variance
The expected variance of X is
𝜎 2 = Var[𝑋] = �(𝑥𝑖 − 𝜇)2 𝑝𝑖 = � 𝑥𝑖 2 𝑝𝑖 − 𝜇 2 , or
σ 2 = Var[X] = E[(X – µ)2] = E[X 2] – µ 2 = E[X 2] – (E[X])2
Expectation algebra
E[aX + b] = �(𝑎𝑥𝑖 + 𝑏)𝑝𝑖 = � 𝑎𝑥𝑖 𝑝𝑖 + 𝑏𝑝𝑖 = 𝑎 � 𝑥𝑖 𝑝𝑖 + 𝑏
= aE[X] + b since ∑ 𝑥𝑖 𝑝𝑖 = µ, and ∑ 𝑝𝑖 = 1
Var[aX + b] = E[(aX + b)2] – (E[(aX + b)])2
= E[(a2X 2 + 2abX + b2)]) – (aE[X] + b)2
= {a2 E[X 2] + 2ab E[X] + E[b2]} – {a2 (E[X])2 + 2ab E[X] + b2}
= a2 E[X 2] – a2 (E[X])2 = a2{E[X 2] – (E[X])2} = a2 Var[X]
Thus we have two important results:
E[aX + b] = aE[X] + b
Var[aX + b] = a2 Var[X] which are equivalent to the results for coding done earlier.
40
Example: A fair die is rolled and the score recorded.
(a) Find the expected mean and variance for the score, X.
(b) A ‘prize’ is awarded which depends on the score on the die. The value of the prize
is $Z = 3X – 6. Find the expected mean and variance of Z.
Solution: (a) score probability xi pi xi2pi
1 1 1
1 6 6 6
1 2 4
2 6 6 6
1 3 9
3 6 6 6
1 4 16
4 6 6 6
1 5 25
5 6 6 6
1 6 36
6 6 6 6
21 91
6 6
21 1
⇒ µ = E[X] = ∑ 𝑥𝑖 𝑝𝑖 = 6
=32
91 21 2 35 11
and σ 2 = E[X 2] – (E[X])2 = 6
– �6� = 12
= 2 12
1 11
⇒ The expected mean and variance for the score, X, are µ = 32 and σ 2 = 2 12
(b) Z = 3X – 6
1 1
⇒ E[Z] = E[3X – 6] = 3E[X] – 6 = 10 2 – 6 = 4 2
35 1
and Var[Z] = Var[3X – 6] = 32 Var[X] = 9 × 12 = 26 4
1 1
⇒ The expected mean and variance for the prize, $Z, are µ = 42 and σ 2 = 26 4
Interpretation of expected value
In the example above, assume that the die was rolled N times, where N is large, and the score
recorded each time.
1
If the frequencies were exactly 6 N, then the mean of the recorded scores would equal E[X] =
11
3⋅5, and the variance of the recorded scores would equal Var[X] = 2 12.
Also, if the value of the prize, Z, was calculated each time, then the mean of the values would
1
equal E[Z] = 4⋅5, and the variance of the values would equal Var[X] = 26 4.
41
Example: A die is rolled until a 6 is thrown, or until the die has been rolled 4 times.
Find the expected mean and standard deviation of the number of times the die is
rolled.
Solution: Expected mean = µ = E[X] = ∑ 𝑥𝑖 𝑝𝑖
and expected variance = σ 2 = E[X 2] − (E[𝑋])2 = ∑ 𝑥𝑖 2 𝑝𝑖 − µ2
number probability
of rolls, xi
outcome pi
xipi xi2 pi
1 1 1
1 (six)
6 6 6
5 1 10 20
2 (not six)(six) ×
6 6 36 36
5 2 1 75 225
3 (not six)(not six)(six) � � ×
6 6 216 216
(not six)(not six)(not six) 3 500 2000
4 4th roll could be anything �56� 216 216
671 2381
216 216
671
⇒ µ = ∑ 𝑥𝑖 𝑝𝑖 = 216 = 3⋅11 to 3 S.F.
2381 671 2
and σ 2 = ∑ 𝑥𝑖 2 𝑝𝑖 − µ2 = 216
− �216� = 1⋅372920953
⇒ σ = √1 ∙ 372920953 = 1⋅17 to 3 S.F.
Answer : Expected mean number of rolls is 3⋅11, with standard deviation 1⋅17
The discrete uniform distribution
Conditions for a discrete uniform distribution
• The discrete random variable X is defined over a set of n distinct values
• Each value is equally likely, with probability 1/n .
Example: The random variable X is defined as the score on a single die. X is a discrete
uniform distribution on the set {1, 2, 3, 4, 5, 6}
The probability distribution is
Score 1 2 3 4 5 6
1 1 1 1 1 1
Probability 6 6 6 6 6 6
42
Expected mean and variance
For a discrete uniform random variable, X defined on the set {1, 2, 3, 4, ..., n},
X 1 2 3 4 ... ... n
1 1 1 1 1
Probability 𝑛 𝑛 𝑛 𝑛 𝑛
1
By symmetry we can see that the Expected mean = µ = E[X] = 2 (n + 1),
1 1 1 1
or µ = E[X] = ∑ 𝑥𝑖 𝑝𝑖 = 1 × 𝑛 + 2 × 𝑛 + 3 × 𝑛 + … + n × 𝑛
1 1 1 1
= (1 + 2 + 3 + … + n) × 𝑛 = 2
n(n + 1) × 𝑛 = 2 (n + 1) long winded method
Var[X] = σ 2 = E[X 2] – (E[X])2 = ∑ 𝑥𝑖 2 𝑝𝑖 − 𝜇 2
2
1 1 1 1 1
= (12 × 𝑛 + 22 × 𝑛 + 32 × 𝑛 + … + n2 × 𝑛) − �2 (𝑛 + 1)�
2
1 1
= (12 + 22 + 32 + … + n2) × 𝑛 − �2 (𝑛 + 1)�
1 1 1
= 6
n(n + 1)(2n + 1) × 𝑛 − 4
(n + 1) 2 since Σ i2 = n(n + 1)(2n + 1)
1
6
1
= 24
(n + 1)[4(2n + 1) − 6(n + 1)]
1 1
= 24
(n + 1) (2n − 2) = 12
(n + 1) (n − 1)
1
⇒ Var[X] = σ 2 = 12
(n2 − 1)
These formulae can be quoted in an exam (if you learn them!).
Non-standard uniform distribution
The formulae can sometimes be used for non-standard uniform distributions.
Example: X is the score on a fair 10 sided spinner. Define Y = 5X + 3.
Find the mean and variance of Y.
1
Y is the distribution {8, 13, 18, … 53}, all with the same probability 10
.
Solution: X is a (standard) discrete uniform distribution on the set {1, 2, 3, …, 10}
1 1
⇒ E[X] = 2 (n + 1) = 5 2
1 99 1
and Var[X] = 12
(n2 − 1) = 12
=84
1
⇒ E[Y] = E[5X + 3] = 5E[X] + 3 = 30 2
99 1
and Var[Y] = Var[5X + 3] = 52 Var[X] = 25 × 12 = 206 4
1 1
⇒ mean and variance of Y are 27 2 and 206 4 .
43