Random Variables and Their Probability
Distributions, chapter 4.1
Grethe Hystad
February 16, 2011
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
Numerical outcomes such as
the number of students who received A in a course
the number of people who live past the age of 100
number of accidents at a particular street
whose values can change from experiment to experiment are called
random variables.
Definition
A random variable is a real valued function whose domain is the
sample space:
X : S R.
We use capital letters near the end of the alphabet, e.g. X,Y,Z for
random variables.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
Example
Suppose a fair coin is tossed 3 times.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
Example
Suppose a fair coin is tossed 3 times.
There are 23 = 8 possible outcomes.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
Example
Suppose a fair coin is tossed 3 times.
There are 23 = 8 possible outcomes.
Let X be the number of heads observed. X is a random
variable and can take the values 0,1,2 or 3.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
Example
Suppose a fair coin is tossed 3 times.
There are 23 = 8 possible outcomes.
Let X be the number of heads observed. X is a random
variable and can take the values 0,1,2 or 3.
Since each outcomes is equally likely, the probability that 0
(3)
head is observed is P(X = 0) = 80 = 18 .
The probability that exactly 1 head is observed is
(3)
P(X = 1) = 81 = 83 .
The probability that exactly 2 heads are observed is
(3)
P(X = 2) = 82 = 83 .
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
Example
The probability that exactly 3 heads are observed is
(3)
P(X = 3) = 83 = 81 .
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
Example
The probability that exactly 3 heads are observed is
(3)
P(X = 3) = 83 = 81 .
The probability that at least 2 heads are observed is
P(X 2) = P(X = 2 or X = 3) =
P(X = 2) + P(X = 3) = 83 + 18 = 21 .
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
Example
The probability that exactly 3 heads are observed is
(3)
P(X = 3) = 83 = 81 .
The probability that at least 2 heads are observed is
P(X 2) = P(X = 2 or X = 3) =
P(X = 2) + P(X = 3) = 83 + 18 = 21 .
The probability that at most 1 head is observed is
P(X 1) = P(X = 0) + P(X = 1) = 18 + 83 = 12 .
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
Example
The probability that exactly 3 heads are observed is
(3)
P(X = 3) = 83 = 81 .
The probability that at least 2 heads are observed is
P(X 2) = P(X = 2 or X = 3) =
P(X = 2) + P(X = 3) = 83 + 18 = 21 .
The probability that at most 1 head is observed is
P(X 1) = P(X = 0) + P(X = 1) = 18 + 83 = 12 .
The probability that more than 1 head is observed is
P(X > 1) = P(X = 2) + P(X = 3) = 38 + 81 = 12 .
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
Example
The probability that exactly 3 heads are observed is
(3)
P(X = 3) = 83 = 81 .
The probability that at least 2 heads are observed is
P(X 2) = P(X = 2 or X = 3) =
P(X = 2) + P(X = 3) = 83 + 18 = 21 .
The probability that at most 1 head is observed is
P(X 1) = P(X = 0) + P(X = 1) = 18 + 83 = 12 .
The probability that more than 1 head is observed is
P(X > 1) = P(X = 2) + P(X = 3) = 38 + 81 = 12 .
The probability that more than 1 head is observed can also be
found as P(X > 1) = 1 P(X 1) = 1 12 = 12 .
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Random Variables
The values that random variables can assume are denoted by
lower case letters, such as x,y,z.
We write P(X = x) = p(x) for the probability that X takes on
the value x.
In our previous coin tossing example, we have
x
p(x)
1
0
8
3
1
8
3
2
8
1
3
8
Total
1
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
What does this notation mean?
Let A be some subset of the range of a discrete random variable.
For example A = {is greater than 2}, A = {between 0 and 2}. We
write
{e S|X (e) A}
(1)
for the set of outcomes e in S such that, X (e), the value of the
random variable is in the subset A. We typically write (1) as
(X A). For example,
{X is greater than 2} = (X > 2) = {e S|X (e) > 2}
{X is between 0 and 2} = (0 < X < 2) = {e S|0 < X (e) < 2}.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Discrete Random Variables
Definition
A random variable X : S R is said to be discrete if its range,
{X (e)|e S},
is either finite or infinite countable, i.e., X can take on only a finite
number- or a countable infinite number- of possible values x.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Probability Function
Definition
Let X (S) R be a random variable. The Probability function of
X, p : X (S) [0, 1] is defined as
p(x) = P({e S|X (e) = x})
for any x X (S). Thus, p(x) is the probability that X equals x,
and we write
p(x) = P(X = x).
The probability function, p(x), assigns probability to each value x
of X so that the following conditions are satisfied:
Grethe Hystad
P(X = x) = p(x) 0 for all x X (S)
P
xX (S) P(X = x) = 1, where the sum is over all possible
values of x.
Random Variables and Their Probability Distributions, chapter 4.1
Cumulative Probability Distribution (CDF)
Definition
The (cumulative) distribution function, F (b), for a random
variable X evaluated at b is defined by
F (b) = P(X b).
If X is discrete,
F (b) =
b
X
p(x),
x=
where p(x) is the probability function.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Cumulative Probability Distribution (CDF)
Let A be some subset of the range of a discrete random variable.
We have
(X A) = (X A).
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Cumulative Probability Distribution (CDF)
Let A be some subset of the range of a discrete random variable.
We have
(X A) = (X A).
For sets A1 , A2 ,...,
i (X Ai ) = (X i Ai )
.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Cumulative Probability Distribution (CDF)
Let A be some subset of the range of a discrete random variable.
We have
(X A) = (X A).
For sets A1 , A2 ,...,
i (X Ai ) = (X i Ai )
.
P(X > x) = 1 P(X x)
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Cumulative Probability Distribution (CDF)
Let A be some subset of the range of a discrete random variable.
We have
(X A) = (X A).
For sets A1 , A2 ,...,
i (X Ai ) = (X i Ai )
.
P(X > x) = 1 P(X x)
If a < b, then (X b) \ (X a) = (a < X b)
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Cumulative Probability Distribution (CDF)
Let A be some subset of the range of a discrete random variable.
We have
(X A) = (X A).
For sets A1 , A2 ,...,
i (X Ai ) = (X i Ai )
.
P(X > x) = 1 P(X x)
If a < b, then (X b) \ (X a) = (a < X b)
P(a < X b) = P((X b) \ (X a))
= P(X b) P(X a) = F (b) F (a).
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Properties of the Distribution Function
A function, F, is a Cumulative Distribution Function iff
limx F (x) = 0
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Properties of the Distribution Function
A function, F, is a Cumulative Distribution Function iff
limx F (x) = 0
limx F (x) = 1
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Properties of the Distribution Function
A function, F, is a Cumulative Distribution Function iff
limx F (x) = 0
limx F (x) = 1
F is nondecreasing; that is if a < b, F (a) F (b).
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Properties of the Distribution Function
A function, F, is a Cumulative Distribution Function iff
limx F (x) = 0
limx F (x) = 1
F is nondecreasing; that is if a < b, F (a) F (b).
F is right-hand continuous; that is
lim F (x) = F (x0 ).
xx0+
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example
Suppose a section of an electrical circuit has two relays, I and II,
operating in parallel. The current will flow when a switch is thrown
if either one or both of the relays close. The probability that a
relay will close properly is 0.9. We assume that the relays operate
independently. Let Ei denote the event that relay i closes properly
when the switch is thrown. Then P(Ei ) = 0.9. Let X be the
number of relays that close properly. X can take the values 0, 1, 2.
The probability that 0 relays close is
p(0) = P(X = 0)
= P(E1 E2 )
= P(E1 )P(E2 )
= (0.1)(0.1)
= 0.01.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example continue
The probability that 1 relays close is
p(1) = P(X = 1)
= P(E1 E2 E1 E2 )
= P(E1 E2 ) + P(E1 E2 )
= P(E1 )P(E2 ) + P(E1 )P(E2 )
= (0.9)(0.1) + (0.1)(0.9) = 0.18
The probability that 2 relays close is
p(2) = P(X = 2)
= P(E1 E2 )
= P(E1 )P(E2 )
= (0.9)(0.9) = 0.81.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example continue
The current will flow if X is equal to at least 1; that is X 1. This
event has probability,
P(X 1) = P((X = 1) (X = 2))
= P(X = 1) + P(X = 2)
= 0.18 + 0.81
= 0.99.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example continue
We have
F (1) = P(X 1) = P(X = 0) + P(X = 1) = 0.01 + 0.18 =
0.19
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example continue
We have
F (1) = P(X 1) = P(X = 0) + P(X = 1) = 0.01 + 0.18 =
0.19
Notice that P(X < 2) = P(X 1.5) = P(X 1)
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example continue
We have
F (1) = P(X 1) = P(X = 0) + P(X = 1) = 0.01 + 0.18 =
0.19
Notice that P(X < 2) = P(X 1.5) = P(X 1)
F (2) = P(X 2) = P(X = 0) + P(X = 1) + P(X = 2) =
0.01 + 0.18 + 0.81 = 1
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example continue
We have
F (1) = P(X 1) = P(X = 0) + P(X = 1) = 0.01 + 0.18 =
0.19
Notice that P(X < 2) = P(X 1.5) = P(X 1)
F (2) = P(X 2) = P(X = 0) + P(X = 1) + P(X = 2) =
0.01 + 0.18 + 0.81 = 1
Notice that F (k) = P(X k) = P(X 2) = F (2) for k 2.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example continue
We have
F (1) = P(X 1) = P(X = 0) + P(X = 1) = 0.01 + 0.18 =
0.19
Notice that P(X < 2) = P(X 1.5) = P(X 1)
F (2) = P(X 2) = P(X = 0) + P(X = 1) + P(X = 2) =
0.01 + 0.18 + 0.81 = 1
Notice that F (k) = P(X k) = P(X 2) = F (2) for k 2.
Distribution Function:
0,
x <0
0.01,
0x <1
F (x) =
0.19,
1x <2
1,
x 2
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example continue
The height of the step is the probability associated with the value
of x. Notice that we have
p(1) = P(0 < X 1) = F (1) F (0) = 0.19 0.01 = 0.18
p(2) = P(1 < X 2) = F (2) F (1) = 1 0.19 = 0.81
Notice that limx1+ F (x) = 0.19 = F (1). So F is right-hand
continuous.
limx1 F (x) = 0.01 6= 0.19 = F (1). So F is not left-hand
continuous.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example
The distribution function of X, which is the number of times per
week a student at a large university exercises, is given as follows,
x <0
0,
0.30,
0x <1
0.50,
1x <2
F (x) =
0.80,
2x <3
0.90,
3x <4
1,
x 4
Verify that F is a distribution function and find the probability
function associated with F.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Solution
Solution
x
p(x)
0
0.30 0 = 0.30
1 0.50 0.30 = 0.20
2 0.80 0.50 = 0.30
3 0.90 0.80 = 0.10
4
1 0.90 = 0.10
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example
Suppose that you are playing a game against the computer
and the probability of winning a play is p. Let X be the
number of unsuccessful trials before the first win. Assume
that the events of play are independent.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example
Suppose that you are playing a game against the computer
and the probability of winning a play is p. Let X be the
number of unsuccessful trials before the first win. Assume
that the events of play are independent.
The probability of x unsuccessful plays before the first win is
p(x) = P(X = x) = (1 p)x p
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
for
x = 0, 1, 2, ...
Example
Suppose that you are playing a game against the computer
and the probability of winning a play is p. Let X be the
number of unsuccessful trials before the first win. Assume
that the events of play are independent.
The probability of x unsuccessful plays before the first win is
p(x) = P(X = x) = (1 p)x p
for
x = 0, 1, 2, ...
The cumulative distribution function is:
F (x) = p(0) + p(1) + ... + p(x)
= p + (1 p)p + (1 p)2 p + ... + (1 p)x p
1 (1 p)x+1
=p
= 1 (1 p)x+1 .
p
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example
Suppose that the probability of winning is p = 0.10 in the previous
example.
(A) What is the probability that one has to play at most 3
unsuccessful games before the first win?
(B) What is the probability that one has to play at least 4
unsuccessful games before the first win?
(C) How many games do you need to play in order for the
probability of winning at least once is 0.95 or greater?
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example
Suppose that the probability of winning is p = 0.10 in the previous
example.
(A) What is the probability that one has to play at most 3
unsuccessful games before the first win?
(B) What is the probability that one has to play at least 4
unsuccessful games before the first win?
(C) How many games do you need to play in order for the
probability of winning at least once is 0.95 or greater?
Solution
(A) F (3) = P(X 3) = 1 (0.90)3+1 = 0.3439.
(B) P(X > 3) = 1 F (3) = 0.904 = 0.6561.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Solutions continue
In part (B), we can see that we have a 65.61% probability of
losing at least 4 times before the first win. In other words, if
you play four games in a row, the probability of losing all 4
times is 0.6561 and the probability of winning at least once in
the 4 plays is F (3) = 0.3439.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Solutions continue
In part (B), we can see that we have a 65.61% probability of
losing at least 4 times before the first win. In other words, if
you play four games in a row, the probability of losing all 4
times is 0.6561 and the probability of winning at least once in
the 4 plays is F (3) = 0.3439.
Thus, in general, F (x) is the probability that you win at least
once in x + 1 successive plays.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Solutions continue
Solution
(C) F (x 1) = 1 (0.90)x is the probability that you win at least
once in x successive plays. Now let
1 (0.9)x = 0.95.
Then
ln(0.90)x = ln(0.05)
and hence
x=
ln(0.05)
28.43.
ln(0.90)
Thus, you need to play 29 times for the probability to be at least
95% that you win at least once.
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
R-code
In the previous example, the terms for the probability mass
function, p(x) = p(X = x) = (1 p)x p, formed a geometric
sequence. X is therefore called a geometric random variable.
In R, we can calculate the probability mass function and the
cumulative distributon function for the geometric random
variable with p = 0.1 as follows:
> x < c(0 : 5)
> f < dgeom(x, 1/10) # d indicates density
> F < pgeom(x, 1/10) # p indicates probability
> data.frame(x, f , F )
> y < rgeom(100, 1/10) # simulate 100 geometric
random variables
> hist(y )
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example
Five lightbulb, 2 of which are defect are being mixed. Two of the
lightbulb are randomly selected. Let X denote the number of
defective lightbulb picked.
(A) Determine the probability mass function for X.
(B) Determine the Cumulative Distribution function for X.
Solution
The probability of selecting 0 defect lightbulbs is
(2)(3)
3
p(0) = 0 5 2 = 10
(2)
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example
Five lightbulb, 2 of which are defect are being mixed. Two of the
lightbulb are randomly selected. Let X denote the number of
defective lightbulb picked.
(A) Determine the probability mass function for X.
(B) Determine the Cumulative Distribution function for X.
Solution
The probability of selecting 0 defect lightbulbs is
(2)(3)
3
p(0) = 0 5 2 = 10
(2)
The probability of selecting 1 defect lightbulb is
(2)(3)
p(1) = 1 5 1 = 35
(2)
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1
Example
Five lightbulb, 2 of which are defect are being mixed. Two of the
lightbulb are randomly selected. Let X denote the number of
defective lightbulb picked.
(A) Determine the probability mass function for X.
(B) Determine the Cumulative Distribution function for X.
Solution
Grethe Hystad
The probability of selecting 0 defect lightbulbs is
(2)(3)
3
p(0) = 0 5 2 = 10
(2)
The probability of selecting 1 defect lightbulb is
(2)(3)
p(1) = 1 5 1 = 35
(2)
The probability of selecting 2 defect lightbulb is
(2)(3)
1
p(2) = 2 5 0 = 10
.
(2)
Random Variables and Their Probability Distributions, chapter 4.1
Example
Five lightbulb, 2 of which are defect are being mixed. Two of the
lightbulb are randomly selected. Let X denote the number of
defective lightbulb picked.
(A) Determine the probability mass function for X.
(B) Determine the Cumulative Distribution function for X.
Solution
Grethe Hystad
The probability of selecting 0 defect lightbulbs is
(2)(3)
3
p(0) = 0 5 2 = 10
(2)
The probability of selecting 1 defect lightbulb is
(2)(3)
p(1) = 1 5 1 = 35
(2)
The probability of selecting 2 defect lightbulb is
(2)(3)
1
p(2) = 2 5 0 = 10
.
(2)
Random Variables and Their Probability Distributions, chapter 4.1
Solution continue
The probability mass function is given by,
x p(x)
3
0
10
3
1
5
1
2
10
(B) The cumulative distribution function is
0,
x <0
0.30,
0x <1
F (x) =
0.90,
1x <2
1,
x 2
Grethe Hystad
Random Variables and Their Probability Distributions, chapter 4.1