Random Variables
Random Variables
Chapter 3
RANDOM VARIABLES
AND
DISTRIBUTION FUNCTIONS
3.1. Introduction
In many random experiments, the elements of sample space are not nec-
essarily numbers. For example, in a coin tossing experiment the sample space
consists of
S = {Head, Tail}.
not holy, it was not Roman, and it was not an empire. A random variable is
neither random nor variable, it is simply a function. The values it takes on
are both random and variable.
S = {Head, Tail}.
X(Head) = 0
X(T ail) = 1.
Tail
X
Head
Real line
0 1
Sample Space
The cardinality of S is
|S| = 210 .
Let X : S ! R I be a function from the sample space S into the set of reals R
I
defined as follows:
Then X is a random variable. This random variable, for example, maps the
sequence HHT T T HT T HH to the real number 5, that is
X(HHT T T HT T HH) = 5.
S S
X X
A B
Real line Real line
x
a b
Sample Space Sample Space
(X=x) means the event A (a<X<b) means the event B
f (x) = P (X = x)
Define a function X : S ! R
I as follows:
X(F r) = 1, X(So) = 2
X(Jr) = 3, X(Sr) = 4.
RX = {1, 2, 3, 4}.
11
f (1) = P (X = 1) =
50
19
f (2) = P (X = 2) =
50
14
f (3) = P (X = 3) =
50
6
f (4) = P (X = 4) = .
50
Example 3.4. A box contains 5 colored balls, 2 black and 3 white. Balls
are drawn successively without replacement. If the random variable X is the
Probability and Mathematical Statistics 49
number of draws until the last black ball is obtained, find the probability
density function for the random variable X.
Answer: Let ‘B’ denote the black ball, and ‘W’ denote the white ball. Then
the sample space S of this experiment is given by (see the figure below)
B B B B
B
W W W
2B B B B
B
3W
W
W W
B
B
W
B
W
B
W B
Hence the sample space has 10 points, that is |S| = 10. It is easy to see that
the space of the random variable X is {2, 3, 4, 5}.
BB X
BWB
2
WBB
BWWB
3
WBWB
WWBB
4
BWWWB
WWBWB
5
WWWBB
WBWWB
Real line
Sample Space S
1 2
f (2) = P (X = 2) = , f (3) = P (X = 3) =
10 10
3 4
f (4) = P (X = 4) = , f (5) = P (X = 5) = .
10 10
Random Variables and Distribution Functions 50
Thus
x 1
f (x) = , x = 2, 3, 4, 5.
10
RX = {2, 3, 4, 5, 6, 7, 8, 9, 10}.
1 2
f (2) = P (X = 2) = , f (3) = P (X = 3) =
24 24
3 4
f (4) = P (X = 4) = , f (5) = P (X = 5) =
24 24
4 4
f (6) = P (X = 6) = , f (7) = P (X = 7) =
24 24
3 2
f (8) = P (X = 8) = , f (9) = P (X = 9) =
24 24
1
f (10) = P (X = 10) = .
24
Example 3.6. A fair coin is tossed 3 times. Let the random variable X
denote the number of heads in 3 tosses of the coin. Find the sample space,
the space of the random variable, and the probability density function of X.
Answer: The sample space S of this experiment consists of all binary se-
quences of length 3, that is
TTT X
TTH 0
THT
HTT 1
THH
HTH 2
HHT
HHH 3
RX = {0, 1, 2, 3}.
Answer: X
1= f (x)
x2RX
X
= k (2x 1)
x2RX
12
X
= k (2x 1)
x=1
" 12
#
X
=k 2 x 12
x=1
(12)(13)
=k 2 12
2
= k 144.
Hence
1
k= .
144
for x 2 RX .
Then
X 1
F (1) = f (t) = f (1) =
144
t1
X 1 3 4
F (2) = f (t) = f (1) + f (2) = + =
144 144 144
t2
X 1 3 5 9
F (3) = f (t) = f (1) + f (2) + f (3) = + + =
144 144 144 144
t3
.. ........
.. ........
X
F (12) = f (t) = f (1) + f (2) + · · · + f (12) = 1.
t12
f (x1 ) = F (x1 )
f (x2 ) = F (x2 ) F (x1 )
f (x3 ) = F (x3 ) F (x2 )
.. ........
.. ........
f (xn ) = F (xn ) F (xn 1 ).
Random Variables and Distribution Functions 54
F(x4) 1
f(x4)
F(x3)
f(x3)
F(x2)
f(x2)
F(x1)
f(x1)
0
x1 x2 x3 x4 x
Theorem 3.2 tells us how to find cumulative distribution function from the
probability density function, whereas Theorem 3.4 tells us how to find the
probability density function given the cumulative distribution function.
Example 3.9. Find the probability density function of the random variable
X whose cumulative distribution function is
8
> 0.00 if x < 1
>
>
>
>
>
>
>
> 0.25 if 1 x < 1
>
>
<
F (x) = 0.50 if 1 x < 3
>
>
>
>
>
>
>
> 0.75 if 3 x < 5
>
>
>
:
1.00 if x 5 .
Also, find (a) P (X 3), (b) P (X = 3), and (c) P (X < 3).
Answer: The space of this random variable is given by
RX = { 1, 1, 3, 5}.
f ( 1) = 0.25
f (1) = 0.50 0.25 = 0.25
f (3) = 0.75 0.50 = 0.25
f (5) = 1.00 0.75 = 0.25.
and
X2 ( head ) = 1 and X2 ( tail ) = 0.
It is easy to see that both these random variables have the same distribution
function, namely (
0 if x < 0
FXi (x) = 12 if 0 x < 1
1 if 1 x
for i = 1, 2. Hence there is no one-to-one correspondence between a random
variable and its distribution function.
Answer: We have to show that f is nonnegative and the area under f (x)
is unity. Since the domain of f is the interval (0, 1), it is clear that f is
nonnegative. Next, we calculate
Z 1 Z 2
f (x) dx = 2x 2
dx
1 1
2
1
= 2
x 1
1
= 2 1
2
= 1.
Example 3.12. For what value of the constant c, the real valued function
f :R
I !R
I given by
c
f (x) = , 1 < x < 1,
1 + (x ✓)2
we use the fact that for pdf the area is unity, that is
Z 1
1= f (x) dx
1
Z 1
c
= dx
1 1 + (x ✓)2
Z 1
c
= dz
1 1+z
2
⇥ ⇤1
= c tan 1 z 1
⇥ ⇤
= c tan 1 (1) tan 1 ( 1)
1 1
=c ⇡+ ⇡
2 2
= c ⇡.
Hence c = 1
⇡ and the density function becomes
1
f (x) = , 1 < x < 1.
⇡ [1 + (x ✓)2 ]
This density function is called the Cauchy distribution function with param-
eter ✓. If a random variable X has this pdf then it is called a Cauchy random
variable and is denoted by X ⇠ CAU (✓).
This distribution is symmetrical about ✓. Further, it achieves it maxi-
mum at x = ✓. The following figure illustrates the symmetry of the distribu-
tion for ✓ = 2.
Example 3.13. For what value of the constant c, the real valued function
f :R
I !R
I given by (
c if a x b
f (x) =
0 otherwise,
Probability and Mathematical Statistics 59
The cumulative distribution function F (x) represents the area under the
probability density function f (x) on the interval ( 1, x) (see figure below).
Random Variables and Distribution Functions 60
Like the discrete case, the cdf is an increasing function of x, and it takes
value 0 at negative infinity and 1 at positive infinity.
Theorem 3.5. If F (x) is the cumulative distribution function of a contin-
uous random variable X, the probability density function f (x) of X is the
derivative of F (x), that is
d
F (x) = f (x).
dx
Proof: By Fundamental Theorem of Calculus, we get
✓Z x ◆
d d
(F (x)) = f (t) dt
dx dx 1
dx
= f (x) = f (x).
dx
This theorem tells us that if the random variable is continuous, then we can
find the pdf given cdf by taking the derivative of the cdf. Recall that for
discrete random variable, the pdf at a point in space of the random variable
can be obtained from the cdf by taking the di↵erence between the cdf at the
point and the cdf immediately below the point.
Example 3.14. What is the cumulative distribution function of the Cauchy
random variable with parameter ✓?
Answer: The cdf of X is given by
Z x
F (x) = f (t) dt
1
Z x
1
= dt
1 ⇡ [1 + (t ✓)2 ]
Z x ✓
1
= dz
1 ⇡ [1 + z2]
1 1
= tan 1 (x ✓) + .
⇡ 2
Probability and Mathematical Statistics 61
Next, we briefly discuss the problem of finding probability when the cdf
is given. We summarize our results in the following theorem.
Theorem 3.6. Let X be a continuous random variable whose cdf is F (x).
Then followings are true:
(a) P (X < x) = F (x),
(b) P (X > x) = 1 F (x),
(c) P (X = x) = 0 , and
(d) P (a < X < b) = F (b) F (a).
P (X q) p and P (X > q) 1 p.
two parts, one having probability mass p and other having probability mass
1 p (see diagram below).
Example 3.17. What is the 87.5 percentile for the distribution with density
function
1
f (x) = e |x| 1 < x < 1?
2
Answer: Note that this density function is symmetric about the y-axis, that
is f (x) = f ( x).
Probability and Mathematical Statistics 63
Hence
Z 0
1
f (x) dx = .
1 2
Z
87.5 q
= f (x) dx
100 1
Z Z
0
1 q
1
= e |x|
dx + e |x|
dx
1 2 0 2
Z Z q
0
1 x 1
= e dx + e x
dx
1 2 0 2
Z q
1 1 x
= + e dx
2 0 2
1 1 1 q
= + e .
2 2 2
1 q
0.125 = e
2 ✓ ◆
25
q = ln = ln 4.
100
Example 3.18. Let the continuous random variable X have the density
function f (x) as shown in the figure below:
Random Variables and Distribution Functions 64
Definition 3.11. The 50th percentile of any distribution is called the median
of the distribution.
The median divides the distribution of the probability mass into two
equal parts (see the following figure).
If a probability density function f (x) is symmetric about the y-axis, then the
median is always 0.
1 1
x2
f (x) = p e 2 , 1 < x < 1.
2⇡
Answer: Notice that f (x) = f ( x), hence the probability density function
is symmetric about the y-axis. Thus the median of X is 0.
y
Relative Maximum
f(x)
0 x
mode mode
Random Variables and Distribution Functions 66
1
f (x) = 1 < x < 1.
⇡ (1 + x2 )
Hence
2x
f 0 (x) = .
⇡ (1 + x2 )2
Setting this derivative to 0, we get x = 0. Thus the mode of X is 0.
Example 3.22. Let X be a continuous random variable with density func-
tion 8
< x2 e bx for x 0
f (x) =
:
0 otherwise,
where b > 0. What is the mode of X?
Answer:
df
0=
dx
= 2xe bx
x2 be bx
= (2 bx)x = 0.
Hence
2
x=0 or x= .
b
Probability and Mathematical Statistics 67
Thus the mode of X is 2b . The graph of the f (x) for b = 4 is shown below.
for some ✓ > 0. What is the ratio of the mode to the median for this
distribution?
Answer: For fixed ✓ > 0, the density function f (x) is an increasing function.
Thus, f (x) has maximum at the right end point of the interval [0, ✓]. Hence
the mode of this distribution is ✓.
Hence
1
q=2 3 ✓.
for some ✓ > 0. What is the probability of X less than the ratio of the mode
to the median of this distribution?
Answer: In the previous example, we have shown that the ratio of the mode
to the median of this distribution is given by
mode p
3
a := = 2.
median
Hence the probability of X less than the ratio of the mode to the median of
this distribution is Z a
P (X < a) = f (x) dx
0
Z a 2
3x
= dx
0 ✓3
3 a
x
= 3
✓ 0
a3
=
✓3
p 3
3
2 2
= = .
✓3 ✓3
3.5. Review Exercises
1. Let the random variable X have the density function
8 q
< k x for 0 x 2
k
f (x) =
:
0 elsewhere.
p
If the mode of this distribution is at x = 4 ,
2
then what is the median of X?
2. The random variable X has density function
8
< c xk+1 (1 x)k for 0 < x < 1
f (x) =
:
0 otherwise,
What is the P 0 eX 4 ?
11. Let X be a continuous random variable with density function
8
< a x2 e 10 x for x 0
f (x) =
:
0 otherwise,
where a > 0. What is the probability of X greater than or equal to the mode
of X?
12. Let the random variable X have the density function
8 q
< k x for 0 x 2
k
f (x) =
:
0 elsewhere.
p
If the mode of this distribution is at x = 4 ,
2
then what is the probability of
X less than the median of X?
13. The random variable X has density function
8
< (k + 1) x2 for 0 < x < 1
f (x) =
:
0 otherwise,
2
f (x) = for x = 1, 2, 3, ....
3x
What is the probability that X is even?
Probability and Mathematical Statistics 71
16. An urn contains 5 balls numbered 1 through 5. Two balls are selected
at random without replacement from the urn. If the random variable X
denotes the sum of the numbers on the 2 balls, then what are the space and
the probability density function of X?
17. A pair of six-sided dice is rolled and the sum is determined. If the
random variable X denotes the sum of the numbers rolled, then what are the
space and the probability density function of X?
18. Five digit codes are selected at random from the set {0, 1, 2, ..., 9} with
replacement. If the random variable X denotes the number of zeros in ran-
domly chosen codes, then what are the space and the probability density
function of X?
19. A urn contains 10 coins of which 4 are counterfeit. Coins are removed
from the urn, one at a time, until all counterfeit coins are found. If the
random variable X denotes the number of coins removed to find the first
counterfeit one, then what are the space and the probability density function
of X?
2c
f (x) = for x = 1, 2, 3, 4, ..., 1
3x
for some constant c. What is the value of c? What is the probability that X
is even?
then what is the value of c for which f (x) is a probability density function?
What is the cumulative distribution function of X. Graph the functions f (x)
and F (x). Use F (x) to compute P (1 X 2).
then what the probability a student finishes in less than a half hour?
Random Variables and Distribution Functions 72
23. What is the probability of, when blindfolded, hitting a circle inscribed
on a square wall?
24. Let f (x) be a continuous probability density function. Show that, for
every 1 < µ < 1 and > 0, the function 1 f x µ is also a probability
density function.
25. Let X be a random variable with probability density function f (x) and
cumulative distribution function F (x). True or False?
(a) f (x) can’t be larger than 1. (b) F (x) can’t be larger than 1. (c) f (x)
can’t decrease. (d) F (x) can’t decrease. (e) f (x) can’t be negative. (f) F (x)
can’t be negative. (g) Area under f must be 1. (h) Area under F must be
1. (i) f can’t jump. (j) F can’t jump.