Download Chapter 4

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

History of statistics wikipedia , lookup

Statistics wikipedia , lookup

Randomness wikipedia , lookup

Probability interpretations wikipedia , lookup

Probability wikipedia , lookup

Transcript
This work is licensed under the Creative commons Attribution-Non-commercial-Share Alike 2.5 South
Africa License. You are free to copy, communicate and adapt the work on condition that you attribute the
authors (Dr Les Underhill & Prof Dave Bradfield) and make your adapted work available under the same
licensing agreement.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/za/ or send a letter to
Creative Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA
Chapter
4
RANDOM VARIABLES
KEYWORDS: Random variables, discrete and continuous random
variables, probability mass functions and probability density functions.
Words or numbers. . .
In Chapter 3, we defined a sample space as the set consisting of all the elementary
events that are possible outcomes of a random experiment. Sometimes, we expressed
these elementary events quantitatively (the length of time for which a light bulb lasts,
the number of items purchased by a customer, the proportion of voters who support
a particular proposal), and sometimes we used verbal, qualitative descriptions of the
elementary events (for random experiments such as the state of the economy, the sex of
an applicant for a job, the colour of a vehicle ordered by a purchaser).
In order to manipulate the events defined on a sample space mathematically, it
is necessary to attach a numerical value to each elementary event. Frequently, the
elementary events are quantitative, and there is a natural and obvious way to assign
numbers to them — the “survival time” (in hours) of the light bulb, the count of items
purchased, the number of girls in families of four children.
However, if the elementary events are expressed qualitatively, we have to assign a
number to each elementary event. For example, the economy might be classified as being
“in recession”, “stable” or “booming”; we could asign a “1” to the event “recession”,
“2” to the event “stable” and “3” to the event “booming”. An applicant for a advertised
post could be male or female, and we could assign “0” to the event “male applicant” and
“1” to the event “female applicant”. To repeat the motivation for assigning numbers to
elementary events — it clears the way for us to develop a general mathematical theory
for handling the probabilities of events in a sample space.
Once all the elementary events in a sample space have numerical values assigned
to them, we follow the classic algebraic tradition and let X “stand for” the numerical
values of the elementary events. We then call X a random variable. X is a variable
because it can “take on” (or assume) different values. X is a random variable because
the particular value it takes on depends on the outcome of a random experiment.
By convention, statisticians use the capital letters near the end of the alphabet to
denote random variables. Their favourite choice is the letter X.
91
92
INTROSTAT
Definition of a random variable. . .
A random variable X is a numerical variable whose value is determined by the
outcome of a random experiment. Expressed somewhat differently, a random variable is
a function whose domain is the sample space, and whose range is the real line.
Once we are dealing with a random variable, events (which we defined in Chapter 3
as subsets of the sample space) become subsets of the real line, usually a set of points or
an interval. Thus “X = 1”, “X < 4” and “5 ≤ X ≤ 10” are events. And because they are
events, they have probabilities — we write Pr[X = 1], Pr[X < 4] and Pr[5 ≤ X ≤ 10],
and read them as “the probability that the random variable X takes on the value 1”,
“the probability that X is less than 4”, and “the probability that X lies in the interval
from 5 to 10, inclusive of the end points.”
Statisticians have also adopted the convention that small letters (e.g. x, a, b) are
used to denote particular values that a random variable may assume. Thus Pr[X = x]
means the probability that the random variable X takes on some particular value x.
If there is only one random variable under consideration, and hence no ambiguity, we
abbreviate Pr[X = x] to Pr(x).
Example 1A: Consider tossing a die. We attach numerical values to the elementary
events in the sample space in the obvious way:
1
2
3
4
5
6
If the die is unbiased, then Pr[X = 1] = 1/6, i.e. Pr(1) = 1/6. We can write
Pr[X = x] = 1/6, or Pr(x) = 1/6, for x = 1, 2, 3, 4, 5 and 6.
It is important to realize that the definition of a random variable does not imply that
a different numerical value needs to be assigned to each elementary event. In fact, we
often want random variables in which the same value is assigned to different elementary
events. The following four examples illustrate this.
Example 2A: Consider the random experiment that consists of tossing an unbiased
coin 3 times (see also Example 3C of Chapter 3). If the random variable of interest is the
number of heads that occur, then we attach numerical values to the elementary events
as follows:
S=
{ HHH HHT HTH THH HTT THT TTH TTT }
X=
3
2
2
2
1
1
1
0
The event “X = 1” corresponds to the subset {HTT, THT, TTH} of S, and thus
Pr[X = 1] = 3/8. Also, clearly, Pr(0) = 1/8, Pr(2) = 3/8 and Pr(3) = 1/8.
Example 3B: Suppose you have 5 coins in your pocket — two 5c coins, two 10c coins
and a 50c coin — and you pull out two coins at random for a tip. Let the random variable
X be the amount of the tip. What are the possible values for X, and the probabilities
that X takes on these values?
We denote the coins 51 52 101 102 and 50. The sample space S, and the numerical
values assigned to each elementary event, can be represented as:
S = { 51 52 51 101 51 102 52 101 52 102 101 102 51 50 52 50 101 50 102 50 }
X=
10
15
15
15
15
20
55
55
60
60
If we assume that each of the ten pairs of coins is equally likely, then Pr[X = 10] = 0.1,
Pr[X = 15] = 0.4, Pr[X = 20] = 0.1, Pr[X = 55] = 0.2, and Pr[X = 60] = 0.2.
CHAPTER 4. RANDOM VARIABLES
93
Example 4B: A shocking snooker player hits the balls around at random until he gets
one into a pocket. There are 15 red balls (valued at 1 point) and one each of the colours
yellow, green, brown, blue, pink and black (valued from 2 to 7 respectively). What is the
sample space for this “random experiment”? Let the random variable X be the “score”.
What values can X take on and with what probabilities?
Denoting the red balls red 1, red 2,. . ., red 15, the elementary events in the sample
space, and the X values assigned to them, are
S = { red 1, . . . , red 15, yellow, green, brown, blue, pink, black }
X=
1
...
1
2
3
4
5
6
7
and, assuming that each ball is equally likely to be pocketed, Pr[X = 1] = 15/21 and
Pr[X = 2] = Pr[X = 3] = . . . = Pr[X = 7] = 1/21.
Example 5C: A car salesperson is scheduled to see two clients today. She sells only
two models of cars, an “executive” (E) and a “basic” (B) model. Each executive model
sold earns the salesperson a commission of R2000, while each basic model sold earns
her only R1000. If the sale is lost (L), no commission is earned. Suppose Pr(E) = 0.2,
Pr(B) = 0.3, and Pr(L) = 0.5, and that sales are independent of each other. Let the
random variable X be the total commission earned by the salesperson today. What
values can X take on, and with what probabilities?
Discrete and continuous random variables. . .
Random variables fall into two categories — discrete and continuous. The mathematical treatment of these two types of random variables is very different — as you will
learn from the remainder of this chapter.
Discrete random variables take on isolated values along the real line, usually
(but by no means always) integer values. Examples of integer-valued discrete random
variables are:
• the number of customers entering a store between 09h00 and 10h00
• the number of occupied tables at a restaurant
• the number of clients visited by a salesperson during a day
• the number of applicants who respond to an job advertisement
Discrete random variables with values that are not integers do also exist! This
happens when the random variable consists of the ratio of two counts: for example, we
might measure the effectiveness of a television advertisement for a luxury car as the
number of cars sold divided by the number of times the advertisement was shown on
TV. Both the numerator and the denominator are then integers, so the random variable
must be a rational number. Detailed consideration of this type of random variable is
beyond the scope of this book, but there are a couple of simple examples!
In contrast to discrete random variables, a continuous random variable can
(conceptually, at least) be measured to any degree of accuracy; i.e. between every two
possible values x1 and x2 that the random variable can assume, there is another possible
value x3 , between x1 and x2 . The set of all possible values of a continuous random
variable is usually an interval of the real line. Examples of continuous random variables
are:
• the distance a car travels on one litre of petrol
94
INTROSTAT
• the proportion of gold in a sample of ore
• the volume of milk that actually goes into a nominally one litre carton
• the time that a customer waits in the queue at a fast food outlet
• the direction of the wind at midday.
Example 6C: Which of the following are random variables? Which of the random
variables are continuous and which are discrete? Write down the set of values that each
random variable can take on.
(a)
(b)
(c)
(d)
The number of customers arriving at a supermarket during the morning.
The number of letters in the Greek alphabet.
The opening price of gold in New York on Monday next week.
The number of seats that will be sold for a performance of a play in a theatre with
a capacity of 328.
(e) The length of time you have to wait at an autobank.
(f) The ratio between the circumference and the diameter of a circle.
(g) The last digit of a randomly selected telephone number.
The distinction between discrete and continuous random variables is critical because
we develop different mathematical approaches for the two types of random variable.
(Interestingly, though, in advanced treatments of random variables, the mathematical approach for both types is again unified!) We describe discrete random variables
mathematically using probability mass functions. Continuous random variables are
described by probability density functions. We adopt the convention of using p(x)
to denote a probability mass function and f (x) for a probability density function.
Probability mass functions. . .
A function p(x) is called a probability mass function (frequently abbreviated to
p.m.f.) if it satisfies the conditions PMF1, PMF2 and PMF3.
PMF1: p(x) is defined for all values of x, but p(x) 6= 0 only at a finite or “countably
infinite” set of points.
PMF2: all values of p(x) lie in the unit interval [0, 1], that is 0 ≤ p(x) ≤ 1.
PMF3: Σp(x) = 1, where the sum is taken over all values of x for which p(x) 6= 0.
We now consider several examples of probability mass functions.
Example 7A: An unbiased die is rolled and the random variable X consists of the
number of dots appearing on the upturned face. Find the probability mass function for
this random variable.
Simply letting Pr[X = x] = p(x) gives us the required probability mass function.
Because the die is unbiased Pr[X = 1] = p(1) = 1/6, and similarly p(2) = p(3) = p(4) =
p(5) = p(6) = 1/6. All other values of X represent impossible events; for example,
Pr[X = −1] = p(−1) = 0 (you cannot get −1 when you toss a die!), p(0) = 0, p(113) =
0, p(187) = 0, and so on. Defined in this way p(x) is non-zero at only six isolated points,
and zero for all other values of x, thus satisfying condition PMF1. PMF2 is satisfied
95
CHAPTER 4. RANDOM VARIABLES
because p(x) is either 0 or 1/6 (which both lie in the closed interval [0, 1], and for PMF3
we note that
6
X
p(x) = 1/6 + 1/6 + 1/6 + 1/6 + 1/6 + 1/6 = 1.
x=1
The probability mass function that describes tossing a single die can therefore be written
as
p(x) = 1/6 x = 1, 2, 3, 4, 5, 6
=0
all other values of x.
1/6
p(x)
0
−2
−1
0
1
2
3
4
5
6
7
8
x
Example 8B: “Heavily-backed favourite Enforce came through along the inside, but was
overwhelmed by Susan’s Dream, quoted at 9–1.” Express the anticipated performance of
the filly Susan’s Dream in this horse race as a probability mass function.
Let X = 0 describe the event that Susan’s Dream loses the race and X = 1 the event
that she wins. The quoted odds of 9–1 means that the probability of losing is estimated
by the bookmaker as 9 times the probability of winning. Thus Pr[X = 0] = 9/10 and
Pr[X = 1] = 1/10, so that
p(x) = 9/10 x = 0
= 1/10 x = 1
=0
all other values of x.
PMF1 is satisfied, because p(x) is non-zero at only two points. Both values of p(x) lie
in the unit interval, so PMF2 is satisfied. The two values of p(x) add to one, so PMF3
is satisfied.
Example 9C: The Minister of Environment Affairs has to decide on a fishing quota for
the forthcoming season. Currently, the biomass of fish is estimated to be 20 m tonnes.
The fish may have a good breeding season (with probability 0.3) and produce 10 m tonnes
of young, or have a bad breeding season and produce only 1 m tonnes. A so-called “warmwater event” may occur with probability 0.1, and kill 15 m tonnes of fish, otherwise
1 m tonnes of fish will die. Find the probability mass function for X, the biomass of
fish before setting the quota (assuming all events are independent). If the minister bases
his decision using a policy that the biomass must remain 10 m tonnes or more with
probability 0.8, what should his decision be?
Example 10C: The hostile merger bid by Minorco on Consgold in 1989 was, at one
point, considered highly likely to fail by the financial media. They quoted a 12–1 chance
of failure. Express the anticipated outcome of the merger as a probability mass function.
96
INTROSTAT
For a discrete random variable X, the probability of the event a ≤ X ≤ b is found
by summing the relevant values of the probability mass function:
Pr[a ≤ X ≤ b] =
b
X
p(x).
x=a
Be careful in your handling of “≤” and “<”, and “≥” and “>”: if X assumes only
integer values, then
b−1
X
p(x).
Pr[a < X < b] =
x=a+1
Also, if you have to find Pr[X ≥ b], the lower limit of the summation is b, but the upper
limit is the largest value of x for which p(x) is defined. You need this information for
the following examples.
Example 11A:
(a) Check that the function
p(x) = x/15 x = 1, 2, 3, 4, 5
=0
otherwise
satisfies the conditions for being the probability mass function of some random
variable X. Sketch p(x).
(b) Find Pr[2 ≤ X ≤ 4].
(c) Find Pr[X ≥ 3].
0.3
p(x)
0.2
0.1
0.0
0
1
2
3
4
5
x
(a)
PMF1: p(x) 6= 0 for only five values of x and p(x) is defined for all values of
x.
PMF2: all values of p(x) lie in the interval [0, 1].
P5
P5
x
1+2+3+4+5
=
= 1.
PMF3:
x=1 p(x) =
x=1
15
15
P4
P4
x
2+3+4
3
(b) Pr[2 ≤ X ≤ 4] = x=2 p(x) = x=2
=
= .
15
15
5
P5
P5
x
3+4+5
4
=
=
(c) Pr[X ≥ 3] = x=3 p(x) = x=3
15
15
5
97
CHAPTER 4. RANDOM VARIABLES
Example 12B: Show that the function
1 x
p(x) = ( ) x = 1, 2, 3, . . .
2
=0
otherwise
is a probability mass function.
PMF1: p(x) is defined for all x, and is non-zero on the set of positive integers
{1, 2, 3, . . .}, a “countably infinite” set1 .
PMF2: p(x) takes on the values 0, 21 , 41 , 18 , . . . all of which lie in the unit interval.
PMF3:
∞
X
p(x) =
x=1
∞
X
1x 1 1 1
= + + + ···
2
2 4 8
x=1
1
1.
(1 − ) = 1.
=
2
2
(Recall that sum of infinity of a geometric progression is given by a/(1 − r). Here
a = 12 and r = 12 .)
Example 13C: Find the sample space for the random experiment which consists of
rolling a pair of dice. Find the probability mass function for the random variables X
defined to be sum of the values on the dice and Y defined to be the product of the values.
Find Pr[X ≥ 10] and Pr[Y ≥ 13].
Example 14C:
(a) Show that the function
p(x) = x3 0.53
=0
x = 0, 1, 2, 3
otherwise
satisfied the conditions for being a probability mass function.
(b) Show that it is the probability mass function for the random variable X, the
number of heads obtained when three coins are flipped.
(c) Find P [X ≤ 2].
Example 15C: Which of the following functions satisfy the conditions for being a
probability mass function?
(a)
p(x) = 0.25 (0.75)x x = 0, 1, 2, . . .
=0
elsewhere
(b)
p(x) = 15 (2x − 3) x = 1, 2, 3, 4, 5
=0
elsewhere
1
A set is said to be countably infinite if there is an orderly way of setting about counting its members.
The set of integers is a countably infinite set. However, the set {x|0 ≤ x ≤ 1}, the unit interval, is noncountable — no matter how what system you use to count the numbers, you always leave out infinitely
many!
98
INTROSTAT
(c)
p(x) = 0.3
= 0.4
= 0.2
= 0.1
= 0.0
x=1
x=2
x=3
x=4
otherwise
(d)
p(x) = x4
=0
3 7
2−x
2
x = 0, 1, 2
otherwise
Example 16C:
(a) For what value of k will
p(x) = k
x!
=0
x = 0, 1, 2, 3, 4
otherwise
be a probability mass function?
(b) Find Pr[X < 2].
Example 17C: 10% of the customers entering a supermarket purchase a particular
brand of margarine. A market researcher wishes to interview a sample of these customers.
As people exit the supermarket she asks them if they have purchased this margarine.
Let the random variable X be the number of people she approaches before she finds
her first customer who has purchased the margarine. Find the probability mass function
for X.
Bar graphs. . .
A probability mass function is conveniently plotted by means of a bar graph. This
gives an easily interpretable visual impression of the shape of the distribution of probabilities associated with the random variable. The example demonstrates the method.
Example 18A: Plot a bar graph for the probability mass function
4
p(x) =
0.6x 0.44−x x = 0, 1, 2, 3, 4
x
=0
otherwise
of the random variable X.
We compute the following probabilities:
x
0
1
2
3
4
p(x)
0.026
0.154
0.346
0.346
0.130
and plot them as a bar graph. The heights of the lines are equal to the probabilities of
the events X = 0, X = 1, X = 2, X = 3 and X = 4. Naturally, the sum of the heights
of the bars must be equal to one.
99
CHAPTER 4. RANDOM VARIABLES
0.4
0.3
p(x) 0.2
0.1
0.0
0
1
2
x
3
4
Example 19C: A random variable X has probability mass function
12
25x
=0
p(x) =
x = 1, 2, 3, 4
otherwise
Plot the bar graph.
Probability density functions. . .
Continuous random variables are represented by probability density functions.
The mathematical treatment of probability density functions is very different to that of
probability mass functions: having separate notations for them reminds us to keep the
mathematical differences in view. We use p(x) for probability mass functions and f (x)
for probability density functions.
A function f (x) is called a probability density function (sometimes abbreviated
to p.d.f.) if it satisfies the conditions PDF1, PDF2 and PDF3.
PDF1: f (x) is defined for all values of x.
PDF2: all values of f (x) lie in the interval [0, ∞); that is 0 ≤ f (x) < ∞.
R∞
PDF3: −∞ f (x) dx = 1, i.e. the “area under the curve” of a probability density
function is one.
Frequently, the function f (x) is non-zero only on some interval, say (a, b) (this
interval may also be closed, or one of the limits may be infinity). It is then only necRb
essary to check PDF3 on this interval: a f (x) dx = 1. This is obvious, because then
R∞
Ra
Rb
R∞
Rb
0 dx = a f (x) dx because f (x) = 0 outside
−∞ f (x) dx = −∞ 0 dx+ a f (x) dx+ b
the interval (a, b).
We have seen that probabilities for discrete random variables are found by calculating the values of the probability mass function p(x) at the points of interest and summing
them. However, for continuous random variables, the probability density function f (x)
is constructed in such a way that probabilities of events are found by integration: the
area under the graph between the numbers c and d represents the probability
of the
Rd
event “the random variable X lies between c and d” i.e. Pr(c ≤ X ≤ d) = c f (x) dx.
This is illustrated below:
100
INTROSTAT
0.4
.....
..............
............
............
..............
...............
................
.................
..................
....................
....................
....................
....................
....................
....................
c
d
x
.....................
.....
....
....
...
...
...
.
.
.
...
...
...
...
...
.
...
..
.
.
...
.
.
...
...
.
...
..
...
.
..
...
.
...
..
.
.
...
.
.
...
...
.
...
.
.
...
.
..
...
.
.
...
..
.
.
...
..
.
...
.
..
....
.
.
.
...
..
.
.
.....
.
....
......
.
.
.
.
.......
...
.
.
.
.
.
.
.........
.....
.
.
.
............
.
.
.
.
.
.
.
......................
..........................
0.3
f (x) 0.2
0.1
0.0
a
b
This, in fact, motivates condition PDF3 of our definition of a probability density
function. The random variable X must lie between −∞ and ∞. Thus the event
“−∞ < X < ∞” is a certain event, and therefore its probability must be equal to
1:
Z ∞
f (x) dx = 1.
i.e.
Pr(−∞ < X < ∞) =
−∞
We now consider several examples of probability density functions.
Example 20A: Show that
f (x) = 4 0 ≤ x ≤ 0.25
= 0 otherwise
is a probability density function. Sketch the probability density function.
PDF1: f (x) is defined for all x.
PDF2: f (x) takes on only the values 0 and 4, both of which are positive.
R 0.25
= 1.
PDF3: 0
4 dx = [4x]0.25
0
4
3
f (x)
2
1
−0.25
0.00
0.25
0.50
0.75
1.00
x
Example 21B: In a certain risky sector of the share market, the proportion of companies that survive (i.e. are not delisted) a year is a continuous random variable lying in
the interval from zero to one. A statistician examines the data collected over past years
and suggests that the function
f (x) = 20x3 (1 − x) 0 ≤ x ≤ 1
=0
otherwise
might be useful in modelling X, the annual proportion of companies that survive.
CHAPTER 4. RANDOM VARIABLES
101
(a) Check that f (x) is a probability density function.
(b) What is the probability that between 30% and 50% of the companies survive a
year?
(c) What is the probability that less than 10% of the companies survive a year?
(a) PDF1 (f (x) is defined for all x), and PDF2 (f (x) > 0) are satisfied. To check
PDF3,
Z 1
Z 1
3
20x3 − 20x4 dx = [5x4 − 4x5 ]10 = 1,
20x (1 − x) dx =
0
0
as required.
(b) The probability that between 30% and 50% survive is
Z 0.5
20x3 (1 − x) dx = [5x4 − 4x5 ]0.5
Pr[0.3 < X < 0.5] =
0.3 = 0.157
0.3
(c) The probability that less than 10% survive is
Z 0.1
Pr[X < 0.1] =
20x3 (1 − x) dx = [5x4 − 4x5 ]0.1
0 = 0.00046
0
Example 22B: A remote country service station is supplied with petrol once a week.
The weekly demand for petrol (measured in 1000’s of litres) is a random variable with
probability density function
1
(10 − x)3 0 ≤ x ≤ 10
f (x) = 2500
=0
otherwise
(a) Show that f (x) is a probability density function
(b) What is the probability that between 3 and 5 thousand litres of petrol are sold in
a week?
(c) If less than 2 thousand litres are sold in a week, the petrol company does not
bother to deliver a supply. What is the probability of this event?
(d) If the service station has a 7 thousand litre tank, what is the probability that it
runs out of petrol in a week, assuming that it started the week full?
(e) What size tank is required in order to be 98% certain that weekly demand can be
met?
(f) What is the probability of selling exactly 5 thousand litres in a week?
(a) Checking the three conditions:
PDF1: f (x) is defined for all x.
PDF2: 10 − x is positive for x in the interval [0, 10], hence f (x) ≥ 0.
PDF3:
1
2500
Z
10
0
10
1
1
1
1
4
4
=
× 10
(10 − x) dx =
− (10 − x)
2500
4
2500 4
0
3
=1
(b) The probability that sales lie between 3000 and 5000 litres is
5
Z 5
1
1
1
4
3
(10 − x) dx =
− (10 − x)
Pr[3 ≤ X ≤ 5] =
2500 3
2500
4
3
1
1
=
−
(54 − 74 ) = 0.1776
2500
4
102
INTROSTAT
(c) The probability that sales are less than 2000 litres is
2
1
1
4
− (10 − x)
Pr[0 ≤ X ≤ 2] =
2500
4
0
1
1
=
−
(84 − 104 ) = 0.5904
2500
4
(d) The probability that sales exceed 7000 litres is
1
Pr[x ≥ 7] =
2500
Z
10
7
1
(10 − x) dx =
2500
3
1
× 34
4
= 0.0081
Demand exceeds capacity with probability 0.0081; on average, the tank is emptied
once in every 123 weeks.
(e) We want Pr[0 ≤ X ≤ c] = 0.98, or equivalently Pr[c ≤ X ≤ 10] = 0.02 : that is
Z 10
1
1
1
(10 − c)4 = 0.02
(10 − x)3 dx =
2500 c
2500 4
1
Thus c = 10 − (0.02 × 10 000) 4 = 10 − 3.76 = 6.24. We need a 6240 litre tank.
(f) Probability of selling exactly 5000 litres, may be expressed as
Pr[5 ≤ X ≤ 5] =
Z
5
f (x) dx = 0.
5
This is a general principle for continuous variables — the probability of the
random variable taking on a particular value exactly is zero. This seems counterintuitive, but is due to the fact that our ability to measure is always discrete (for
example, digital petrol pumps measure to the “nearest” tenth of a litre). Continuous
random variables are essentially unobservable, an abstract mathematical concept that is
useful only because it is convenient.
As a corollary of the above, note that for continuous random variables
Z d
f (x) dx.
Pr[c ≤ X ≤ d] = Pr[c < X ≤ d] = Pr[c ≤ X < d] = Pr[c < X < d] =
c
(This is not true of discrete random variables, where one has to be alert to the type of
inequality.)
Examples 21B and 22B showed how a random variable and a “probability density
function” could be used to “model” a practical problem. The particular probability
density functions that we used were chosen to make the integration trivial, and would
certainly be poor representations of reality in both situations. In the next chapter we
will be considering various probability mass functions and probability density functions
which have proved themselves useful in practice as models of real-world phenomena.
Example 23B:
(a) Could the following function serve as a probability density function for some random variable X?
f (x) = 6x(1 − x) 0 ≤ x ≤ 1
=0
otherwise
103
CHAPTER 4. RANDOM VARIABLES
1.5
1.0
f (x)
0.5
......................
......
.....
...
.....
...
...
.
.
...
.
...
...
..
...
.
...
..
.
...
..
.
...
..
.
...
..
...
.
...
..
.
...
..
.
...
..
.
...
..
.
...
..
...
.
..
...
.
...
....
...
.
.
...
....
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
....
...
.
f (x) = 6x(1 − x)
0
1
x
(b) What is the probability that
(i) 0 ≤ X ≤ 0.2?
(ii) 0.4 ≤ X ≤ 0.6?
(a) We must check that the three conditions of our definition are satisfied
PDF1: f (x) is defined for all x.
PDF2: All values f (x) lie in the set {y|0 ≤ y ≤ 1.5} which contains no
negative numbers.
PDF3: We need to check that the area under the curve between 0 and 1 is
equal to 1:
Z 1
Z 1
Z 1
(x − x2 ) dx
6x(1 − x) dx = 6
f (x) dx =
0
0
0
1 2 1 3 1
=6 x − x
2
3
0
1 1
=6
−
= 1.
2 3
The conditions are satisfied.
R 0.2
(i) Pr[0 ≤ X ≤ 0.2] = 6 0 (x − x2 ) dx = 0.104
R 0.6
(ii) Pr[0.4 ≤ X ≤ 0.6] = 6 0.4 (x − x2 ) dx = 0.296
Note that there is no requirement for the graph of a probability density function f (x)
to be a “smooth” curve such as this one:
2
f (x)
1
0
.....
............ ................
......
.......
.....
......
....
......
.
.
.
......
......
...
......
...
.
......
..
.
......
.
.
......
.
......
...
.
......
..
.
......
..
......
.
......
..
.
......
..
.......
.
.......
..
.
.......
..
........
.
........
..
.
.........
..
..........
.
...........
..
.
............
..
................
.
....................
..
.
.............................
.
..........................
.
.
..
0.0
0.5
x
1.0
In fact, a great variety of shapes are possible. The only restrictions are that f (x)
must be non-negative, and that the area under the curve must be equal to one. It is
104
INTROSTAT
important to grasp that the actual values of f (x) (the “height of the curve at value x”)
cannot be interpreted as being the probability that the random variable X is equal to
x. This interpretation was possible with graphs of the probability mass functions of
discrete random variables. For continuous random variables, probabilities are computed
by integrating the probability density function.
4
4
3
3
f (x) 2
1
...
..
...
...
...
...
...
...
...
...
....
.
.
....
...
....
....
....
...
.....
....
.....
.....
.
.
.
.
.
.....
.....
......
......
......
......
.......
.......
........
...........
........
.........................................
0
0.5
x
1.0
3
f (x)
1
0
1
0
0.0
2
2
...
.......
... ...
... ....
... ...
... ....
... ...
... ....
...
...
...
...
...
...
...
...
...
...
...
..
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
....
....
...
....
...
.....
...
......
......
...
......
...
.......
.......
...
........
...
..........
............
...
.............
...
...
............................................
0.0
0.5
x
3
....
..... ...
..... .....
.....
...
.
.
.
.
..
...
.....
...
.....
...
.....
.
.
...
.
.
...
.
...
.
.
.
...
...
.
.
.
.
...
...
.
.
.
.
...
...
.
.
.
...
.
...
.
...
.
.
.
...
...
.
.
.
.
...
...
.
.
.
.
...
...
.
.
.
...
.
...
.
.
...
.
.
...
.
...
.
.
.
...
....
.
.
.
...
...
.
.
.
.
...
...
.
.
.
...
.
...
.
...
.
.
.
...
....
.
.
.
.
.
0.0
0.5
x
2
1
0
1.0
........
... ......
.........
...
...
.. ..
..
...
.. .....
..
..
...
....
.
...
..
..
...
...
.
.
..
.
..
.
..
..
..
..
..
..
.
..
.
..
.
...
..
.
..
..
..
..
.
....
..
.
..
.
..
.
...
..
...
..
....
...
.
..
...
....
.
..
..
...
.
...
..
.
..
.
...
.
.
..
..
..
...
....
...
..
...
...
....
..
..
..
.
...
... ...
..
...
..
... ..
..
.
...
.......
..
...
...
.
...
.
...
..
.
.
...
.
.
.....
..
.
......
.
...
.
.
........... ..
.
.
.
.
.
..............
..
0.0
0.5
x
Example 24B: Let X be a random variable with probability density function
1
f (x) = ke− 2 x 0 ≤ x ≤ ∞
=0
otherwise
What value must k assume?
To make f (x) a density function, k must be chosen so that
Z ∞
f (x) dx = 1
−∞
i.e.
Z
∞
−∞
Z
∞
1
ke− 2 x dx
0
i∞
h
1
= 2k = 1
= −2ke− 2 x
f (x) dx =
0
Thus k = 12 .
1.0
1.0
105
CHAPTER 4. RANDOM VARIABLES
A selection of examples. . .
Example 25C:
(a) Find the value of k, so that the function
f (x) = k(x2 − 1) 1 ≤ x ≤ 3
=0
otherwise
may serve as a probability density function.
(b) Find the probability that X lies between 2 and 3.
Example 26C: Verify that each of the following functions satisfies the conditions for
being either a probability mass function or probability density function.
(a)
p(x) = x/6 x = 1, 2, 3
=0
otherwise
(b)
p(x) = x4
=0
14
2
x = 0, 1, 2, 3, 4
otherwise
(c)
f (x) = 1 0 ≤ x ≤ 1
= 0 otherwise
(d)
f (x) = |x| −1 ≤ x ≤ 1
=0
otherwise
(e)
f (x) = − log x 0 < x ≤ 1
=0
otherwise
(f)
p(x) = e−1 /x! x = 0, 1, 2, . . .
=0
otherwise
(g)
p(x) = 1/n x = 1, 2, 3, . . . , n
=0
otherwise
(h)
f (x) = 12 sin x 0 ≤ x ≤ π
=0
otherwise
Example 27C: The probability density function of a random variable X is given by
f (x) = kx(1 − x2 ) 0 ≤ x ≤ 1
=0
elsewhere
(a) Show that the value of k must be 4
(b) Calculate Pr[0 < X < 12 ]
(c) Find the value of A so that Pr[0 < X < A] = 21 .
106
INTROSTAT
Example 28C: For what values of A can p(x) be a probability mass function?
p(x) = (1 − A)/4
= (1 + A)/2
= (1 − A)/4
=0
x=0
x=1
x=2
otherwise
Example 29C: A small pool building company is equally likely to be able to complete
2 or 3 pool contracts each month. The company receives between 1 and 4 contracts
to build pools each month, with probabilities Pr(1) = 0.1, Pr(2) = 0.2, Pr(3) = 0.5,
Pr(4) = 0.2. At the beginning of this month the company has two contracts carried
forward from the previous month. The random variable X of interest is the number of
contracts to be carried forward to next month. Find the probability mass function of X.
In particular, what is the probability that no contracts will be carried forward to next
month? Assume that the number of contracts is independent of the number of pools
completed. Also, to simplify the problem, assume that the contracts for a month are
made at the beginning of the month.
Solutions to examples. . .
5C The sample space, numerical values for the elementary events and their associated
probabilities are:
S
= {
EE
EB
EL
BB
BE
BL
LL
LE
LB
}
X =
4000 3000 2000 2000 3000 1000
0
2000 1000
Pr =
0.04 0.06 0.10 0.09 0.06 0.15 0.25 0.10 0.15
The probability mass function is therefore given by
p(x) = 0.25
= 0.30
= 0.29
= 0.12
= 0.04
=0
x=0
x = 1000
x = 2000
x = 3000
x = 4000
otherwise
6C (b) & (f) are not random variables, (a), (d) & (g) are discrete, (c) & (e) are
continuous.
9C
p(x) = 0.07
= 0.03
= 0.63
= 0.27
=0
x=6
x = 15
x = 20
x = 29
otherwise
Set the quota at 10 m tonnes.
10C Let X = 0 be fail, X = 1 be succeed.
p(x) = 12/13 x = 0
= 1/13 x = 1
=0
otherwise
107
CHAPTER 4. RANDOM VARIABLES
13C The sample space, numerical values for the elementary events and their associated
probabilities are:
X
=
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
5
4
3
2
1
1
Probability
=
36
36
36
36
36
36
36
36
36
36
36
Y=
Pr(Y ) =
1
2
3
4
5
6
8
9
10
12
15
16
18
20
24
25
30
36
1
36
2
36
2
36
3
36
2
36
4
36
13
36 .
2
36
1
36
2
36
4
36
2
36
1
36
2
36
2
36
2
36
1
36
2
36
1
36
Pr[x ≥ 10] = 0.1667, Pr[Y ≥ 13] =
14C (c) 0.875
15C (a), (c) and (d) are probability mass functions, but (b) is not, because
p(1) = −0.2 < 0.
16C (a) k = 24/65
(b) 48/65
17C The probability mass function is
p(x) = 0.1 × 0.9x x = 0, 1, 2, . . .
=0
otherwise
25C (a) k = 3/20
(b) Pr[2 < X < 3] = 4/5
26C (a), (b), (f) and (g) are probability mass functions, (c), (d), (e) and (h) are probability density functions.
27C (b) 7/16
(c) A = 0.5412
28C −1 ≤ A ≤ 1 (otherwise probabilities are either negative or greater than one).
29C
p(x) = 0.1 × 0.5 = 0.05
= 0.2 × 0.5 + 0.1 × 0.5 = 0.15
= 0.2 × 0.5 + 0.5 × 0.5 = 0.35
= 0.5 × 0.5 + 0.2 × 0.5 = 0.35
= 0.2 × 0.5 = 0.1
=0
x=0
x=1
x=2
x=3
x=4
otherwise
Exercises. . .
∗ 4.1
Which of the following random variables are discrete, and which are continuous?
(a)
(b)
(c)
(d)
(e)
(f)
(g)
(h)
(i)
the time required to answer this question
the number of words in a book chosen at random from the library
the number of “heads” in 6 flips of a coin
the number of goals scored in a soccer match
the maximum temperature recorded at Cape Town International Airport today
the volume of air breathed in by an individual when asked to “take a deep
breath”
the annual income to the nearest cent of a randomly chosen wage-earner
the population of a randomly chosen town in the Free State
the length of time you have to wait for a bus
108
INTROSTAT
(j) the amount of rain that falls in a day.
∗ 4.2
Check which of the following functions can serve as probability mass functions or
probability density functions.
(a)
p(x) = x/6 x = 1, 2, 3
=0
otherwise
(b)
3
(2 − x2 ) −1 ≤ x ≤ 1
f (x) = 10
=0
otherwise
(c)
p(x) = x
x=
1 3 1 1
, , ,
16 16 4 2
(d)
f (x) = 2x/3 −1 < x < 2
=0
otherwise
(e)
f (x) = 14
=0
3<x<7
otherwise
(f)
p(x) =
x
x = 1, 2, . . . , n
1
n(n+1)
2
=0
otherwise
4.3 Show that the following functions are probability mass functions.
(a)
p(x) = e−2 2x x! x = 0, 1, 2, . . .
=0
otherwise
(b)
p(x) = x5
=0
1 x 3 5−x
4 4
x = 0, 1, 2, 3, 4, 5
otherwise
4.4 Show that the following functions are probability density functions.
(a)
√
f (x) = (2 x)−1 0 < x < 1
=0
otherwise
(b)
1
f (x) = 14 xe− 2 x 0 ≤ x < ∞
=0
otherwise
∗ 4.5
What must the value of k be so that the following functions are probability density
functions?
(a)
f (x) = kx2 (1 − x) 0 < x < 1
=0
otherwise
(b)
f (x) = ke−4x 0 ≤ x < ∞
=0
otherwise
CHAPTER 4. RANDOM VARIABLES
109
4.6 A random variable X has probability density function given by
f (x) = Ax3 0 ≤ x ≤ 10
=0
otherwise
Find A. What is the probability that X lies between 2 and 5, and what is the
probability that X is less than 3? Sketch the density function.
∗ 4.7
A random variable X has probability density function
f (x) = e−x 0 ≤ x < ∞
=0
otherwise
Find the number t such that Pr[X < t] = 12 .
4.8 For the probability density function
f (x) = 2x 0 ≤ x ≤ 1
= 0 otherwise
find the number a such that the probability that X < a is three times the probability that X ≥ a.
4.9 If f (x) = 3x2 for 0 < x < 1, and zero elsewhere, find the number b, such that X
is equally likely to be greater than, or less than b.
∗ 4.10
The probability density function of the life in hours X of a certain kind of radio
tube is found to be
f (x) = 100/x2 x > 100
=0
otherwise
Three such tubes are bought for a radio set. What is the probability that none
will have to be replaced during the first 150 hours of operation?
4.11 A batch of small-calibre ammunition is accepted as satisfactory if none of a sample
of five shots fall more than 8 cm from the target at a given range. If X, the distance
from the centre of the target to an impact point, has probability density function
f (x) = xe−x 0 ≤ x < ∞
=0
otherwise
find the probability that a batch is accepted.
Further exercises. . .
4.12 A continuous random variable X has probability density function
f (x) = k a ≤ x ≤ b
= 0 otherwise
for arbitrary constants a and b. Find the value of k.
4.13 Find values for c so that the following functions may serve as probability density
functions:
110
INTROSTAT
(a)
f (x) = c + e−x 0 ≤ x ≤ 1
=0
otherwise
(b)
f (x) = x +
=0
∗ 4.14
1
2
0≤x≤c
otherwise
The density function for a random variable X is given by
f (x) = 34 (kx − x2 ) 0 ≤ x ≤ 2
=0
otherwise
(a) Determine the value of k.
(b) Calculate Pr[0 < X < 1].
∗ 4.15
(a) Check whether
p(x) = x5
=0
4 2−x /36
x = 0, 1, 2
elsewhere
is a probability mass function.
(b) Calculate Pr[X = 0], Pr[X = 1] and Pr[X = 2].
Solutions to exercises. . .
4.1 (b) (c) (d) (g) and (h) are discrete
(a) (e) (f) and (i) are continuous.
(j) is an unusual example of a mixed continuous and discrete random variable:
although the random variable is, at face value, continuous, it cannot be modelled
by a conventional probability density function because the probability of no rain
in a day is not zero but positive. The probability function for X needs to be
something like
p(x) = p
x=0
= f (x) x > 0
=0
otherwise
with the “probability density function” f (x) integrating to 1 − p.
4.2 (a) (b) (e) and (f) satisfy conditions.
For (c), p(x) is not defined for all X.
For (d), f (x) < 0 for −1 < x < 0.
4.5 (a) k = 12
(b) k = 4
4.6 A = 1/2500, Pr[2 < X < 5] = 0.0609, Pr[X < 3] = 0.0081.
4.7 0.6931
4.8 0.8660
4.9 0.7937
4.10 8/27
4.11 0.9850
CHAPTER 4. RANDOM VARIABLES
4.12 k = 1/(b − a)
4.13 (a) c = e−1
4.14 (a) k = 2
(b) c = 1
(b)
1
2
4.15 Pr[X = 0] = 6/36, Pr[X = 1] = 20/36, Pr[X = 2] = 10/36
111
112
INTROSTAT