9/26/2018
Discrete Random Variables
Presentation by Dr Bassant Youssef
Random Variables
• A random variable (R.V.) is a function that
associates a real number with each element in
the sample space. In other words, it is a function
X whose domain is the sample space S and range
is a subset of the real numbers.
• If the range of a random variable is a countable
set (finite or infinite), the random variable is said
to be a discrete random variable. In case the
range is an uncountable set, the random variable
is said to be a continuous one
Presentation by Dr Bassant Youssef
Presentation by Dr Bassant Youssef 1
9/26/2018
R x = {0,1,2}
Example 1
• A coin is tossed twice. Define the random
variable X to be the number of appearing heads
in the 2 tosses. Determine the range of X.
• The range is R = {0,1,2} and therefore X is a
x
discrete random variable.
Presentation by Dr Bassant Youssef
Example 2
• Consider the random experiment of waiting for calls at a
certain switchboard. Define the random variable X to be
the interarrival time between calls and the random
variable Y to be the number of arriving calls in a certain
day. Determine the range of X and that of Y.
• Time is dealt with as a continuous variable,
unless otherwise stated (in slotted time systems).
The range of X is .R x = [0, ∞[
• The number of calls received on a certain day is a
discrete random variable and its range is .R y = {0,1,2,⋯}
Presentation by Dr Bassant Youssef
Presentation by Dr Bassant Youssef 2
9/26/2018
Discrete Probability Distributions
1) Probability Mass Functions
• A discrete random variable assumes each of its values
with a certain probability.
• It is convenient to represent all the probabilities
associated with a random variable X by a formula. Such
a formula is necessarily a function of the numerical
values x ∈ R x and shall be denoted by f(x)
• Therefore, we will use f(x) to denote P(X=x) , which is
the probability that the random variable X takes on the
value x.
• The set of ordered pairs(x,f(x)) is called the probability
mass function (pmf) or probability distribution of the
discrete random variable X .
Presentation by Dr Bassant Youssef
Probability mass function (pmf)
• A valid probability mass function of a discrete
random variable X X must satisfy the following
requirements for each x ∈ R x
1. f ( x) ≥ 0
2. f (x) =1
x
3. f (x) =P(X =x)
Presentation by Dr Bassant Youssef
Presentation by Dr Bassant Youssef 3
9/26/2018
: Example 3
• A shipment of 8 microcomputers to an outlet contains 3
that are defective. If a school makes a random purchase of
2 computers, find the probability distribution for the
number of defectives.
• Let the R.V. X denote the number of defective items in the
selection. The sample space of the experiment is shown in
Figure 2 (selection is without replacement)
• The range of X is R x = {0,1,2}
G
• The pmf is given by the set of values G
4G
3D
D
P ( X = 0 ), P ( X = 1 ), P ( X = 2 )
5G D
5 4 5 3D
P ( X = 0 ) = P ( GG ) = × = G
8 7 14
5G
3 5 5 3 15
P(X = 1) = P(DG ) + P(GD) = × + × = 2D
8 7 8 7 28 D
3 2 3
P ( X = 2 ) = P ( DD ) = × =
8 7 28 Presentation by Dr Bassant Youssef
2) Cumulative Distribution Functions
• If we wish to compute the probability that the
observed value of a random variable X is less
than or equal to some real number x.
• For any discrete R.V. with possible values x1 , x2 ,
… , xn, the events {X= x1} ,{X= x2} ,… ,{X= xn} are
mutually exclusive events and therefore the
cumulative distribution function (cdf) for a
discrete R.V. with pmf f(x) is defined to be
F( x ) = P(X ≤ x ) = f ( x i ) for
• xi ≤x
−∞ < x < ∞
• The cdf of a random variable is a non-decreasing
function taking values in the unit interval [0,1].
Presentation by Dr Bassant Youssef
Presentation by Dr Bassant Youssef 4
9/26/2018
Example 4
• A coin is tossed until a tail appears or after three
attempts have been made. Find the pmf and cdf of the
number of trials made in this experiment and sketch
their graphs.
• Let X denote the number of trials made. The range of X
is R x = {.1,2,3} The pmf of X is given by
T
1
P( X = 1) = P (T ) =
2 T
1
P( X = 2) = P( HT) = H T
4
1 1 1 H
P (X = 3) = P (HHT ) + P( HHH ) = + =
8 8 4 H
Presentation by Dr Bassant Youssef
Example 4
• This can be summarized in the following table
x 1 2 3
f(x) 0.5 0.25 0.25
• The cdf is given by 0,
0.5,
x <1
1≤ x < 2
F( x ) =
0.75, 2≤x<3
1, x≥3
1 1
0.75 0.75
0.5 0.5
0.25
0.25
1 2 3
1 2 3
pmf Presentation by Dr Bassant
cdf Youssef
Presentation by Dr Bassant Youssef 5
9/26/2018
Example 5
• The number of errors found in an eight bit byte is a
discrete random variable X with the given
cumulative distribution function. Determine the
corresponding pmf for X 0 , x <1
0.7, 1 ≤ x < 4
F( x ) =
0.9 , 4 ≤ x < 7
1 , x ≥ 7
• First of all, we need to determine the range of the
R.V. X. From the above cdf, it is clear that
• R x = {1,4,7}
• The probability distribution for the R.V. X is given by
P(X=1) =0.7, P(X=4) =0.9−0.7=0.2, P(X=7) =1−0.9=0.1
Presentation by Dr Bassant Youssef
Mean and Variance of a Discrete
Random Variable
• Two numbers are often used to summarize a
probability distribution of a R.V. X:
• The mean, which is a measure of the centre or
middle of the probability distribution.
• The variance, which is a measure of dispersion
or variability in the distribution.
• Notice that these two measures do not
uniquely identify a probability distribution
Presentation by Dr Bassant Youssef
Presentation by Dr Bassant Youssef 6
9/26/2018
The Mean or Expected Value (1)
• The mean (or expected value) of a random variable X is
a measure of the average value that we might expect
on the long run for this random variable.
• For example, consider the experiment of tossing two
coins and define the random variable X to be the
number of heads appearing. It is clear that . Suppose
that this experiment is carried out actually for 16
times, and suppose we observed that no heads
occurred 4 times, one head 7 times and two heads 5
times. The average number of heads per toss (of the 2
coins) is then given by
0 × 4 + 1× 7 + 2 × 5 4 7 5
= 0 × + 1 × + 2 × ≈ 1.06
16
Presentation by Dr Bassant Youssef 16 16 16
The Mean or Expected Value (2)
• The average value approaches a limit on the long
run (if the experiment is repeated for a large
number of times), which is the mean or
mathematical expectation of the random variable
X.
• Let X be a random variable with a probability
mass function f(x). The mean of a discrete R.V. X
is a weighted average of its possible values with
weights equal to probabilities and is calculated as
µ = E (X ) = x f (x )
Presentation by
x Dr Bassant Youssef
Presentation by Dr Bassant Youssef 7
9/26/2018
Example 6
• Find the expected number of chemists on a
committee of size two selected at random from 4
chemists and 3 biologists.
• First, define the R.V. X denoting the number of
chemists in the selected committee and therefore
R x .= {0,1,2} Using techniques of counting, we can
construct the pmf of X as follows
x 0 1 2
4
C x ×3 C 2 − x
f ( x ) = P( X = x ) = , x = 0,1, 2 f(x) 3/21 12/21 6/21
7
C2
• The expected number of chemists is given by
3 12 6 8
µ = E(X) = 0 × + 1× + 2 × = ≈ 1.14
21 21 21 7
Presentation by Dr Bassant Youssef
Remarks
• Let X be a random variable with probability
distribution f(x) . The mean of the random
variable g(x) is given by
µ g = E(g (X)) = g (x ) f ( x )
x
• Special case: E(aX+ b) = a E(X) + b
• where a,b are constants.
• The proof is direct.
E(aX + b) = (ax + b) f ( x ) = a x f ( x ) + b f ( x ) = a E (X) + b
x x x
Presentation by Dr Bassant Youssef
Presentation by Dr Bassant Youssef 8
9/26/2018
Variance and Standard Deviation
• By itself, however, the mean does not give
adequate description of the shape of the
distribution. We need to characterize the
variability or the dispersion of the distribution
about the mean.
• The most important measure of variability of a
random variable X is its variance, which is
defined to be
σ 2 = V( X) = E[(X − µ) 2 ] = ( x − µ) 2 f ( x )
x
• where µ = E(X)
Presentation by Dr Bassant Youssef
Variance and Standard Deviation
• The positive square root of the variance, , σis called
the standard deviation of X and is measured in
same units as X.
• An alternative and more preferred formula for
finding the variance is given by σ 2 = E ( X 2 ) − µ 2
• Remark: V(aX + b) = a 2 V(X)
• where a,b are constants. The variance is only
affected by scaling the values of the random variable
X and is invariant under translation of its values.
Presentation by Dr Bassant Youssef
Presentation by Dr Bassant Youssef 9
9/26/2018
Example 7
• Two new product designs are to be compared on the basis of
revenue potential on the long run. Marketing estimates that the
revenue from design A can be predicted accurately to be $ 3
million. The revenue potential of design B is more difficult to
assess. Marketing concludes that there is a probability of 0.3 that
the revenue from design B will be $ 7 million, but there is a
probability of 0.7 that the revenue will only be $ 2 million.
Calculate the mean and standard deviation of the revenue from
each design.
• Let X be a R.V. denoting the revenue from design A and let Y
denote the revenue from B in million dollars.
µ X = E(X ) = 3 σ X = V (X ) = 0 (X is constant; i.e. deterministic)
µ Y = E (Y) = 0.3 × 7 + 0.7 × 2 = 3.5 E(Y 2 ) = 0.3 × 7 2 + 0.7 × 2 2
Presentation by Dr Bassant Youssef
σ Y = V(Y) = E (Y 2 ) − µ 2Y = 2.29
Moments of a Random Variable
• The mean of a random variable is sometimes
referred to as the first moment of the probability
distribution. In general, the rth moment is E(Xr).
It is noteworthy that there is a function that can
be used to derive various moments of a random
variable; which is known as the moment
generating function.
• This function is given by M X (t) = E(e tX )
Presentation by Dr Bassant Youssef
Presentation by Dr Bassant Youssef 10
9/26/2018
Moment generating function
• It characterizes the distribution of a random variable
just like its probability mass (density) function does.
• The rth moment can be derived from it according to
r
the following formula E(X r ) = dtd r M X (t)
t =0
• To see this, let's consider deriving the second
moment; that is, E(X 2 ) . Recall that M (t) = 1 + t E(X) + t2 ! E(X ) + t3 ! E(X ) + ...
X
2
2
3
3
2 3
• M (t) = E(e ) = E(1 + tX + t2 !X + t3 !X +...) (we used Maclaurin's expansion)
X
tX 2 3
• Differentiating the above expression twice with
2
respect to t dtd M ( t ) = E ( X ) + t E ( X ) + ...
2 X
2 3
• Putting t=0 in the above expression yields E(X 2 ) as all
higher order terms involve t. Presentation by Dr Bassant Youssef
Presentation by Dr Bassant Youssef 11