Probability and Random
Variables
Dr. Sadiq Ali
Lecture Outline
• Expected Value
• Practice Example - Random Variable
• Variance of a Random Variable
Expected Value
Graph of pmf (Previous Week)
Example: Draw the pmf of the random variable X,
where X is defined as the number of heads in 3 tosses.
Probabilities pX x versus X
PX x
pmf of X
𝟑
𝟖
𝟏
𝟖
0 1 2 3 𝑥
Center of Probability Mass
• The pmf is centered at 𝐗 = 𝟏. 𝟓 , with equal
probability mass on both sides.
𝑃𝑋 𝑥
pmf of X
𝟑
𝟖
𝟏
𝟖
0 1 2 3 𝑥
Expected Value of X
• The center of probability mass in a PMF graph is the
expected value of X,
EX = x k pX x k
all k
• OR, the mean of the random variable
mX = E X = x k pX x k
all k
• You can think of the expected value (or the mean) as the
average value that the random variable can take.
Expected Value of X
• Using the expression for E[X], we can find the
expected value for the 3 coin tosses example.
• The answer should come out to be 1.5, since that is
what the pmf graph suggests.
mX = E X = x k pX x k
all k
Expected Value of X
EX = x k pX x k
all k
= 0 × pX 0 + 1 × pX 1 + 2 × pX 2 + 3 × pX 3
E X = 0 × 18 + 1 × 38 + 2 × 38 + 3 × 18
E X = 38 + 68 + 38 = 1.5
Properties of E[X]
• If α and β are constants,
– E[αX] = αE[X]
– E[α] = α and E[β] = β
– E[αX + β] = E[αX] + E[β] = αE[X] + β
Function of a random variable
• Function of a random variable is also a random variable.
• Example: if the random variable X denotes the number
of heads in 3 tosses and the random variable Y is
defined as follows,
2
Y=ቊ X if X = 2 or X = 3
0 otherwise
• Then Y is also a random variable.
Expected Value of the Function of a
random variable
Method 1:
We fine E[Y] by using standard method. This method
requires using the probabilities of the random variable
Y.
E Y = ypy Y
Expected Value of the Function of a
random variable
X 2 if X = 2 or X = 3
Y=ቊ
𝑆 0 otherwise
3
9
HHH HHT HTH THH 2
4
1 0
THT TTH HTT TTT
0 𝑌 𝑆𝑌
𝑋
𝑆𝑋
E[Y] = (0 × 4 / 8) + (4 × 3 / 8) + (9 × 1 / 8)
= 21 / 8
Expected Value of the Function of a
random variable
Method 2:
We find E[Y] using the probabilities of the random
variable X.
E Y = Y x j pX x j
all j
E[Y] = (0 × 1/8) + (02 × 3/8) + (22 × 3/8) +
(32 × 1/8) = 21 / 8.
Expected Value of Y
S
3
9
HHH HHT HTH THH 2
4
1 0
THT TTH HTT TTT
0 Y SY
X
SX
E[Y] = (0 × 1/8) + (0 × 3/8) + (22 × 3/8) + (32 ×
1/8) = 21 / 8.
Practice Example – Random
Variable
Example 1
• Let X be the maximum of the number of heads
obtained when Ibrahim and Ismail both flip a fair
coin twice.
a) Describe the underlying sample space of this
random experiment and specify the probabilities
of its elementary events.
Example 1(a) Solution
The sample space is,
HH, HH , HH, HT , HH, TH , HH, TT ,
S =
HT, HH , … , TT, TT
Since both Ibrahim and Ismail use a fair coin for their
respective 2 tosses, all 16 outcomes are equally likely with
probability 1/16.
1
P HH, HH = P HH, HT =, … , P TT, TT = 16
Example 1(a) Solution
Ibrahim
Ismail
• Depiction of Tossing 2 fair coins by Ibrahim and Ismail.
• Number of elements in 𝐒 = 𝟒 × 𝟒 = 𝟏𝟔.
Example 1(b)
• Let X be the maximum of the number of heads
obtained when Ibrahim and Ismail both flip a fair
coin twice. The number of heads is determined by the
individual obtaining more heads in his coin tosses.
b) Show the mapping from 𝑆 to SX. Show the range
of X.
Example 1(b) Solution
SX = {0, 1, 2} = Range of X
Example 1(c)
• Let X be the maximum of the number of heads
obtained when Ibrahim and Ismail both flip a fair
coin twice.
c) Find the probabilities for the various values of X.
Example 1 (c) Solution
Example 1(c) Solution
P[X = 0] = 1/4 × 1/4 = 1/16.
Example 1(c) Solution
1 1 1 1 1 1 1
P[X = 1] = × + × + × =
4 2 2 4 2 2 2
Example 1(c) Solution
1 1 1 1 1 7
P[X = 2] = × + × + ×1 = .
4 4 2 4 4 16
Example 1(d)
• Let X be the maximum of the number of heads
obtained when Ibrahim and Ismail both flip a fair
coin twice.
d) Plot the pmf of X.
Example 1(d) Solution
The pmf of X is plotted using values from part (c).
Example 1(e)
• Let X be the maximum of the number of heads
obtained when Ibrahim and Ismail both flip a fair
coin twice.
e) Find E[X].
Example 1(e) Solution
pmf of X, when two
people flip a fair coin
twice.
1 1 7 22
E X = xpX x = 0 × + 1× + 2× =
16 2 16 16
Variance of a Random
Variable
Deviation of a Random Variable
• The deviation of a random variable, X, about its mean
value, E[X], is given by,
D= X−E X 2
– where the square is used since we are often
interested in the magnitude (non-negative values)
of the deviation.
Variance of a Random Variable
• The variance of a random variable, X, is defined as
the expected value of its deviation, D.
VAR X = E D = E X 2 − E X 2
VAR X = E X 2 − m2X
• The variance tells us how much does the random
variable (on average) deviate from its mean value.
Example 1 (f)
• Let X be the maximum of the number of heads
obtained when Ibrahim and Ismail toss a fair coin
twice.
f) Find VAR[X].
Example 1(f) Solution
VAR X = E X 2 − E X 2
• Let Z = X2 be a random variable.
E X 2 = E[Z(X)]
• Finding E[Z(X)] means that we have to find the
expected value of a function of a random variable.
Example 1(f) Solution
Example 1(f) Solution
• We use the second method to find E[Z(X)].
E X2 = E Z X = Z x j pX x j
all j
• We will need the pmf of X to solve this. The pmf of
X was found in part (d)
Example 1(f) Solution
E X2 = E Z X
= Z x j pX x j
all j
Example 1(f) Solution
1 1 7 9
E X2 = 02 × + 12 × 2
+ 2 × =
16 2 16 4
VAR X = E X 2 − E X 2
• We had already found E[X] in part (e)
2
9 22 82
VAR X = − =
4 16 256
Properties of VAR[X]
• If c is a constant,
a) VAR[X + c] = VAR[X]
b) VAR[cX] = c2VAR[X]
Standard Deviation
• The standard deviation, 𝜎𝑋 , is given by
VAR X = σ2X
σX = STD X = VAR X