EFA 2213 Engineering Mathematics IV (Statistics) : Random Variables
EFA 2213 Engineering Mathematics IV (Statistics) : Random Variables
Engineering Mathematics IV
(Statistics)
LECTURE 4:
Random Variables
C.P. NG
Random Variable
• A random variable is a variable that
assumes numerical values
associated with the random
outcomes of an experiment, where
one (and only one) numerical value
is assigned to each sample point.
2
Types of Random Variable
• A discrete random variable can assume
a countable number of values.
– Number of steps to the top of Batu Caves
• A continuous random variable can
assume any value along a given interval
of a number line.
– The time a tourist stays at the top once he/
she gets there
3
Types of Random Variables
Discrete Random Variables Continuous Random Variables
• Number of sales • Length
• Number of calls • Depth
• Shares of stock • Volume
• People in line • Time
• Mistakes per page • Weight
4
Example 4.1
• A coin is tossed three times and the
sequence of heads and tails are
noted.
• The sample space for this experiment
is S = {HHH, HHT, HTH, HTT, THH, THT, TTH,
TTT}.
• Let x be the number of heads (H) in
the three tosses.
• X assigns each outcome ω in S a
number from the Sx = {0, 1, 2, 3}.
5
Example 4.1
• The table below lists the eight
outcomes of S and the corresponding
values of X.
Ω HHH HHT HTH THH HTT THT TTH TTT
X(ω) 3 2 2 2 1 1 1 0
6
Example 4.2
• Two passengers are Sample y
chosen in succession space
without replacement MM
MF
2
1
from a train containing 4 FM 1
male passengers and 3 FF 0
female passengers.
• The possible outcomes
and the value y of the
random variable Y,
where Y is the number of
male passengers, are
7
Example 4.3
• A player pays RM1.50 to play the
following game: A coin is tossed
three times and the number of
heads X is counted.
• The player receives RM1 if X = 2 and
RM 8 if X = 3, but nothing otherwise.
8
Example 4.3
• Let Y be the reward to the player.
• Y is a function of the random variable X
and its outcomes can be related back to
the sample space of the underlying
random experiment as follows:
Ω HHH HHT HTH THH HTT THT TTH TTT
X(ω) 3 2 2 2 1 1 1 0
Y(ω) 8 1 1 1 0 0 0 0
9
Discrete and Continuous
Sample Space
• If a sample space contains a finite
number of possibilities or an un-ending
sequence with as many elements as
there are whole numbers, it called a
discrete sample space.
• If a sample space contains an infinite
number of possibilities equal to the
number of points on a line segment, it
is called a continuous sample space.
10
Discrete Probability
Distribution
• The set of ordered pairs (x, f(x)) is a
probability mass function,
probability function, or probability
distribution of the discrete random
variable X if, for each possible
outcome x,
f ( x) 0
f ( x) 1
x
P( X x) f ( x)
11
Example 4.5
• A shipment of 8 similar motorcar to
a retail outlet contains 3 that are
defective.
• If a car dealer makes a random
purchase of 2 of these motorcars,
find the probability distribution for
the number of defectives.
12
Example 4.5
• Let X be a random variable whose
values x are the possible numbers of
defective motorcars purchased by
the dealer.
• Then x can be any of the number 0,
1, and 2.
13
Example 4.5
3 5
• The probability
f ( 0 ) P( X 0 )
0 2 10
8
28 distribution for X is
2
x 0 1 2
3 5
f(x) 10/28 15/28 3/28
f ( 1 ) P( X 1 )
1 1 15
8 28
2
3 5
f ( 2 ) P( X 2 )
2 0 3
8 28
2
14
Example 4.6
• A player receives RM1 if the number
of heads in three coin tosses is 2,
RM8 if the number is 3, but nothing
otherwise.
• Find the probability distribution of
the reward Y.
15
Example 4.6
• S = {HHH, HHT, HTH, THH, TTH, THT, HTT, TTT}
16
Example 4.7
• If a car agency sells 50% of its
inventory of a certain foreign car
equipped with airbags, find a
formula for the probability
distribution of the number of cars
with airbags among the next 4 cars
sold by the agency.
17
Example 4.7
• Since the probability of selling an automobile with airbags
is 0.5, the 24 =16 points in the sample space are equally
likely to occur.
4 3 2 1 0
FFFF FFFL FFLL FLLL LLLL
FFLF FLLF LLLF
FLFF LLFF LFLL
LFFF LFFL LLFL
LFLF
FLFL
18
Example 4.7
• The event of selling x models with air
bags and 4-x models without air bags
can occur in 4
x
F ( x) P( X x) f (t ), for x
tx
20
Discrete Probability
Distribution
• The axioms of probability and their
corollaries imply that the cumulative
distribution function has the
following properties:
0 Fx ( x) 1
lim F ( x) 1
x
x
lim F ( x) 0
x
x
P( X b) 1 Fx (b)
21
Example 4.8
• Find the cumulative distribution
function of the random variable X in
Example 4.7.
• Using F(x), verify that f(2) = 3/8.
22
Example 4.8
• f(0) = 1/16, f(1) = 1/4, f(2) =3/8, f(3) =
1/4, f(4) = 1/16
• F(0) = f(0) = 1/16
• F(1) = f(0) + f(1) = 5/16
• F(2) = f(0) + f(1) +f(2) = 11/16
• F(3) = f(0) + f(1) + f(2) + f(3) = 15/16
• F(4) = f(0) + f(1) + f(2) + f(3) + f(4) = 1
• f(2) =F(2) – F(1) = 11/16 – 5/16 = 3/8
23
Example 4.9
• Let X be the number of heads in
three tosses of a fair coin.
• Use the cumulative distribution
function to find the probability of
the events A= {1 < x ≤ 2}, B= {0.5 ≤ x
< 2.5}, and C= {1≤ x < 2}.
24
Example 4.9
Ω HHH HHT HTH THH HTT THT TTH TTT
X 3 2 2 2 1 1 1 0
25
Example 4.9
• P[{1 < x ≤ 2}] = Fx(2) – Fx(1)
=7/8 – 4/8
= 3/8
26
Exercise 4.1 (Q1)
• Two fair dice tossed, and let X
denote the sum of the spots that
appears on the top face.
• Obtain the probability distribution
for X.
• Construct a graph for this
probability distribution.
27
Exercise 4.1 (Q2)
• A car parks has 5 white and 3 black
cars.
• If 2 cars are selected at random
without replacement and Z denotes
the number of white cars selected.
• Find the probability distribution for Z.
• Draw the graph for the distribution.
28
Exercise 4.2 (Q3)
• Two dice are rolled.
• Let X be the difference of the face
numbers showing the higher minus
the lower, and 0 for ties.
• Find the probability mass function of
X.
29
Exercise 4.1 (Q4)
• A fair coin is tossed until a head or
five tails occurs.
• Find the probability mass function
and the cumulative distribution
function.
30
Exercise 4.1 (Q5)
• Suppose that a random variable X
has a discrete distribution with the
following probability mass function
c
2x x 1,2 ,...
f(x)
0 otherwise
x!
• Find the probability that in a specific 20-s time
period, more that 8 cars arrive at the
intersection. (Answer = 0.1528)
• Find the probability that only 2 cars arrive.
(Answer = 0.0446)
33
Continuous Probability
Distribution
a b
b
P(a X b) f ( x)dx
a
34
Continuous Probability
Distribution
• The function f(x) is a probability
density function for continuous
random variable X, defined over
the set of real numbers R, if
f ( x ) 0 , for all x ϵ R
f ( x)dx 1
b
P(a X b) f ( x)dx
a
35
Example 4.10
• Suppose that the error in the reaction
temperature in C, for a control lab experiment
is continuous random variable X having the
probability density function
x2
f ( x) 3 1 x 2
0 elsewhere
• Verify that f ( x)dx 1
36
Example 4.10
2
2 2
x x
3
8 1
f ( x )dx 1 3 dx 9 9 9 1
1
1
x 1
x 1
2 3
P( 0 X 1 ) dx
0 3 9 0 9
37
Example 4.11
• Based on extensive testing, it is determined
by the manufacturer of a washing
machine that the time Y (in years) before
a major repair is required is characterized
by the probability density function
1 y4
e y0
f ( x) 4
0 elsewhere
– Critics would certainly consider the product a bargain
if it is unlikely to require a major repair before the sixth
year. Comment on this by determining P(Y>6)
– What is the probability that a major repair occurs in the
first year?
38
Example 4.11
1
1 y 4
P( y 6) 1 P(0 y 6) P(0 y 1) e dy
6 40
1 y4
1 e dy 1
e
y
40 4
6
0
1 e 4
y
0 e 1
4
e0
1 e 2 e0
3
0.2212
0.2231
39
Continuous Probability
Distribution
• The cumulative distribution function
F(x) of a continuous random
variable X with density function f(x)
is
F ( x ) P( X x ) f ( t )dt
, for -∞ < x < ∞
40
Example 4.12
• For the density function below, find
F(x), and use it to evaluate P(0 < X ≤
1).
x2
f ( x) 3 1 x 2
0 elsewhere
41
Example 4.12
• For -1 < x < 2
x3 1
x
x x
x 2
x 3
F ( x ) f ( x )dx dx
1 3 9 1 9
0, x 1
x 3 1
F ( x) , 1 x 2
9
1, x2
42
Example 4.13
• The Department of Energy (DOE) puts projects out
on bid and generally estimates what a reasonable
bid should be, let the estimate be b.
• The DOE has determined that the density function of
the winning (low) bid is
5 2
b y 2b
f ( y ) 8b 5
0 elsewhere
• Find F(y) and use it to determine the probability that
the winning bid is less than the DOE’s preliminary
estimate b.
43
Example 4.13
y
y
5 5y 5y 1
F ( y ) dy
2 b 8b
5
8b 2 b 5 8b 4
2
0, y b
5
5 y 1 2
F( y ) , b y 2b
8b 4 5
1, y 2b
– Find F(x)
– Determine the probability that the component (and thus
the DVD player) lasts more than 1000 hours before the
component needs to be replaced.
– Determine the probability that the component fails before
2000 hours.
45
Exercise 4.2 (Q2)
• An important factor in solid missile fuel is the
particle size distribution. Significant problems
occur if the particle sizes are too large. From
production data in the past, it has been
determined that the particle size (in
micrometers) distribution is characterized by
3x 4 x 1
f ( x)
0 elsewhere
– Verify that this is a valid density function.
– Evaluate F(x).
– What is the probability that a random particle from the
manufactured fuel exceeds 4 micrometers?
46
Exercise 4.2 (Q3)
• Suppose a special type of small data
processing firm is so specialized that some
have difficulty making a profit in their fist year
of operation. The probability distribution
function that characterizes the proportion Y
that make a profit is given by
3x 4 x 1
f ( x)
0 elsewhere
– What is the value of k that renders the above a valid
density function? (Answer = 280)
– Find the probability that at most 50% of the firms make a
profit in the first year. (Answer = 0.3633)
– Find the probability that at least 80% of the firms make a
profit in the first year. (Answer = 0.0563)
47
Joint Probability Distribution
• The function f(x, y) is a joint probability
distribution or probability mass function of
the discrete random variables X and Y if
f ( x, y) 0 for all ( x, y)
f ( x, y) 1
x y
P( X x, Y y) f ( x, y)
• For any region A in the xy plane,
P [( X ,Y ) A ] f ( x , y )
A
48
Example 4.14
• Two refills for a ballpoint pen are
selected at random from a box that
contains 3 blue refills, 2 red refills,
and 3 green refills. If X is the number
of blue refills and Y is the number of
red refills selected, find
– the joint probability function f(x,y)
– P[(X,Y)ϵ A], where A is the region {(x,y)|x+y ≤1}
49
Example 4.14
3 2 3
x y 2 x y
f ( x, y ) , x = 0, 1, 2; y = 0, 1, 2; 0≤ x+y ≤ 2
8
2
P(x+y ≤1) = f(0,0) +f(0,1) + f(1,0) = 3/28 + 3/14 + 9/28 = 9/14
f(x,y) x Total
0 1 2
y 0 3/28 9/28 3/28 15/28
1 3/14 3/14 0 3/7
2 1/28 0 0 1/28
Total 5/14 15/28 3/28 1
50
Exercise 4.3 (Q1)
• Determine the values of c so that
the following functions represent
joint probability distributions of the
random variables X and Y:
– f(x,y) = cxy, for x = 1, 2, 3; y = 1, 2, 3
– f(x,y) = c|x-y|, for x = -2, 0, 2; y = -2, 3
51
Joint Probability Distribution
• The function f(x,y) is a joint density
function of the continuous random
variables X and Y if
f ( x, y) 0 for all ( x, y)
f ( x, y)dxdy 1
52
Example 4.15
• A candy company distributes boxes of chocolates
with a mixture of creams, toffees, and nuts coated in
both light and dark chocolate.
• For a randomly selected box, let X and Y,
respectively, be the proportions of the light and dark
chocolates that are creams and suppose that the
joint density function is
2
(2 x 3 y ) 0 x 1,0 y 1
f ( x, y ) 5
0 elsewhere
– Verify that f ( x, y)dxdy 1
53
Example 4.15
1 1
2
f ( x , y ) dxdy 0 0 5 (2 x 3 y)dxdy
1
1
2 x 2 6 xy
dy
0 0
5 5
1
1
2 6y 2 y 3y2 2 3
dy 1
0
5 5 5 5 0 5 5
1 1
2 2
1 1 1 2
P[(0 X , Y ) (2 x 3 y )dxdy
2 4 2 1 0 5
4
1 1 1
2
2x2
6 xy 2 2
1 3y
dy dy
1 5 5 0 1 10 5
4 4
1
y 3y2 1 1 3 1 3 13
2
10 5 1 10 2 4 4 16 160
4
54
Exercise 4.4 (Q1)
• A candy company distributes boxes of chocolates with a
mixture of creams, toffees, and cordials. Suppose that the
weight of each box is 1 kilogram, but the individual
weights of the creams, toffees, and cordials vary from box
to box. For a randomly selected box, let X and Y represent
the weights of the creams and the toffees, respectively,
and suppose that the joint density function of these
variables is
24 xy 0 x 1,0 y 1, x y 1
f ( x, y )
0 elsewhere
– Find the probability that in a given box the cordials account for more
than ½ of the weight.
– Find the marginal density for the weight of the creams
– Find the probability that the weight of the toffees in a box is less than 1/8
of a kilogram if it is known that creams constitute ¾ of the weight.
55
Joint Probability Distribution
• The marginal distribution of X alone and
of Y alone are
g ( x) f ( x, y) and h ( y ) f ( x, y )
y x
56
Example 4.16
• Show that the column and row
totals of table below give the
marginal distribution of X alone and
Y alone
f(x,y) x Total
0 1 2
y 0 3/28 9/28 3/28 15/28
1 3/14 3/14 0 3/7
2 1/28 0 0 1/28
Total 5/14 15/28 3/28 1
57
Example 4.16
3 3 1 5
g (0) f (0,0) f (0,1) f (0,2)
28 14 28 14
9 3 15
g (1) f (1,0) f (1,1) f (1,2) 0
28 14 28
3 3
g (2) f (2,0) f (2,1) f (2,2) 00
28 28
3 9 3 15
h(0) f (0,0) f (1,0) f (2,0)
28 28 28 28
3 3 3
h(1) f (0,1) f (1,1) f (2,1) 0
14 14 7
1 1
h(2) f (0,2) f (1,2) f (2,2) 00
28 28
58
Joint Probability Distribution
• Let X and Y be two random variables,
discrete or continuous. The conditional
distribution of the random variable Y
given that X = x is
f ( x, y)
f ( y | x) , g ( x) 0
g ( x)
60
Example 4.17
2
h( 1 ) f ( x ,1 ) 143 143 0 73
x 0
f ( x,1) 7
f ( x | 1) f ( x,1), x 0,1,2
h(1) 3
7 3 1
P( X 0 | Y 1) f (0 | 1) *
3 14 2
61
Example 4.18
• The joint density for the random
variables (X,Y), where X is the unit
temperature change and Y is the
proportion of spectrum shift that a
certain atomic particle produces, is
10 xy 2 0 x y 1
f ( x, y )
0 elsewhere
– Find the marginal densities g(x), h(y), and the
conditional density f(y|x)
– Find the probability that the spectrum shifts more
than half of the total observations, given that the
temperature is increased to 0.25 unit
62
Example 4.18
1
g ( x) f ( x, y)dy 10 xy
2
dy
x
1
10 3 10
xy x(1 x 3 ), 0 x 1
3 x 3
y
h( y ) f ( x, y)dx 10 xy
2
dx
0
y
5x 2 y 2 5 y 4 ,0 y 1
0
f ( x, y ) 10 xy 2 3y2
f ( y | x) ,0 x y 1
g ( x) 10
x(1 x )
3 1 x 3
3
1 1
1 3y2 8
P(Y | X 0.25) f ( y | x 0.25)dy dy
1 1 0.25
3
2 1 9
2 2
63
Example 4.19
• Given the joint density function
x(1 3 y 2 )
, 0 x 2,0 y 1
f ( x, y ) 4
0 elsewhere
64
Example 4.19
x(1 3 y 2 )
1
g ( x) f ( x, y )dy dy
0
4
1
xy xy 3 x
,0 x 2
4 4 0 2
x(1 3 y 2 )
2
h( y ) f ( x, y )dx dx
0
4
2
x 2 3x 2 y 2 1 3y 2
,0 y 1
8 8 0 2
f ( x, y ) x(1 3 y 2 ) / 4 x
f ( x | y) ,0 x 2
h( y ) (1 3 y 2 ) / 2 2
1
2
1 1 1 x 3
P( X | Y ) dx
4 2 3 12 64
4
65
Joint Probability Distribution
• Let X and Y be two random variables,
discrete or continuous, with joint
probability distribution f(x,y) and
marginal distributions g(x) and h(y),
respectively.
• The random variables X and Y are said
to be statistically independent if and
only if
f(x,y) = g(x)h(y)
• for all (x,y) within their range.
66
Example 4.20
• Show that the following random
variables are not statistically
independent.
f(x,y) x Total
0 1 2
y 0 3/28 9/28 3/28 15/28
1 3/14 3/14 0 3/7
2 1/28 0 0 1/28
Total 5/14 15/28 3/28 1
67
Example 4.20
• Let us consider the point (0,1)
• f(0,1) = 3/14
2
3 3 1 5
g (0) f (0, y)
y 0 28 14 28 14
2
3 3 3
h(1) f ( x,1) 0
x 0 14 14 7
2 1 0
( 1 e 2 )( e 1 e 3 )e 2 0.0372
70
Exercise 4.5 (Q1)
• Let X, Y, and Z have the joint
probability density function
kxy 2 z , 0 x, y 1,0 z 2
f ( x, y , z )
0 elsewhere
– Find k
– Find P(X <¼, Y > ½, 1 <z < 2)
71
Exercise 4.5 (Q2)
• The amount of kerosene, in thousands of
liters, in a tank at the beginning of any day
is a random amount Y from which a
random amount X is sold during that day.
Suppose that the tank is not resupplied
during the day so that x ≤ y, and assume
that the joint density function of these
variables is
2, 0 x y 1
f ( x, y )
0 elsewhere
– Determine if X and Y are independent
– Find P(¼ < X < ½ |Y =¾)
72
Exercise 4.5 (Q3)
• Consider an experiment that
consists of 2 rolls of a balanced die.
If X is the number of 4s and Y is the
number of 5s obtained in the 2 rolls
of the die, find
– the joint probability distribution of X and Y;
– P[(X,Y) ϵ A], where A is the region
{(x,y)|2x+y<3}
73
Exercise 4.5 (Q4)
• Let X denotes the number of times a certain number
control machine will malfunction: 1, 2, or 3 times on
any given day. Let Y denote the number of times a
technician is called on an emergency call. Their joint
probability distribution is given as
f(x,y) x
1 2 3
y 1 0.05 0.05 0.1
2 0.05 0.1 0.35
3 0 0.2 0.1
74