### Lecture 5

```5. Functions of a Random Variable
Let X be a r.v defined on the model (  , F , P ), and suppose
g(x) is a function of the variable x. Define
Y  g ( X ).
(5-1)
Is Y necessarily a r.v? If so what is its PDF FY ( y ), pdf
fY ( y ) ?
Clearly if Y is a r.v, then for every Borel set B, the set of for
Y ( ) must
B
which
belong to F. Given that X is a r.v, this is
gis (also
B ) a Borel set, i.e., if g(x) is a Borel
assured if
function. In that case if X is a r.v, so is Y, and for every Borel
set B
1
1
P (Y  B )  P ( X  g ( B )).
(5-2)
1
PILLAI
In particular
FY ( y )  P (Y ( )  y )  P  g ( X ( ))  y   P  X ( )  g (  , y ]  .
1
(5-3)
Thus the distribution function as well of the density
function of Y can be determined in terms of that of X. To
obtain the distribution function of Y, we must determine the
Borel set on the x-axis such that X ( )  g ( y ) for every
given y, and the probability of that set. At this point, we
shall consider some of the following functions to illustrate
the technical details.
1
aX  b
X nis
1
X
X
2
Y  g(X )
|X |
X
log X
e
X
| X |U ( x)
2
PILLAI
Example 5.1: Y 
Solution: Suppose
aX  b
(5-4)
a  0.
yb

 yb
FY ( y )  P Y ( )  y   P aX ( )  b  y   P  X ( ) 

F

 .
X 
a 

 a 
and
 yb
fY ( y ) 
fX 
 .
a
 a 
1
On the other hand if
a  0,
(5-5)
(5-6)
then
yb

FY ( y )  P Y ( )  y   P aX ( )  b  y   P  X ( ) 

a 

 yb
 1  FX 
 ,
 a 
(5-7)
and hence
fY ( y )  
 yb
fX 
 .
a
 a 
1
(5-8)
3
PILLAI
From (5-6) and (5-8), we obtain (for all a)
fY ( y ) 
Example 5.2:
 yb
fX 
.
|a |  a 
1
(5-9)
(5-10)
Y  X .
2
FY ( y )  P Y ( )  y   P  X ( )  y  .
(5-11)
2
If
y  0,
then the event  X
FY ( y )  0 ,
2
( )  y    ,
(5-12)
y  0.
For y  0 , from Fig. 5.1, the event
is equivalent to { x  X ( )  x }.
1
and hence
{Y ( )  y }  { X ( )  y }
2
2
Y  X
2
y
x1
Fig. 5.1
x2
X
4
PILLAI
Hence
FY ( y )  P  x 1  X ( )  x 2   F X ( x 2 )  F X ( x 1 )
 FX (
y )  FX ( 
y  0.
y ),
(5-13)
By direct differentiation, we get
 1

fY ( y )   2 y


If
fX (x)
f
X

y )  f X (
(
y) ,
0,
y  0,
otherwise
.
(5-14)
represents an even function, then (5-14) reduces to
fY ( y ) 
In particular if
X
1
y
fX

 U ( y ).
y
(5-15)
 N ( 0 ,1), so that
f X ( x) 
1
2
e
x
2
/2
,
(5-16)
5
PILLAI
and substituting this into (5-14) or (5-15), we obtain the
p.d.f of Y  X 2 to be
fY ( y ) 
1
2 y
e
(5-17)
y /2
U ( y ).
On comparing this with (3-36), we notice that (5-17)
represents a Chi-square r.v with n = 1, since  (1 / 2 )   .
Thus, if X is a Gaussian r.v with   0 , then Y  X
represents a Chi-square r.v with one degree of freedom
(n = 1).
2
Example 5.3: Let
 X  c,

Y  g ( X )   0,
 X  c,

X  c,
 c  X  c,
X   c.
6
PILLAI
In this case
P ( Y  0 )  P (  c  X ( )  c )  F X ( c )  F X (  c ).
For
we have
y  0,
x  c,
and
Y ( )  X ( )  c
(5-18)
so that
FY ( y )  P Y ( )  y   P ( X ( )  c  y )
 P  X ( )  y  c   F X ( y  c ),
Similarly
y  0,
if
x   c,
and
y  0.
Y ( )  X ( )  c
(5-19)
so that
FY ( y )  P Y ( )  y   P ( X ( )  c  y )
Thus
 P  X ( )  y  c   F X ( y  c ),
y  0.
y  0,
 f X ( y  c ),

f Y ( y )   [ F X ( c )  F X (  c )] ( y ),
 f ( y  c ),
y  0.
 X
g(X )
FX ( x )
c
c
(5-21)
FY ( y )
X
x
(a)
(5-20)
(b)
Fig. 5.2
y
(c)
7
PILLAI
Example 5.4: Half-wave rectifier
Y  g ( X );
 x,
g(x)  
 0,
x  0,
x  0.
(5-22)
Y
In this case
P ( Y  0 )  P ( X ( )  0 )  F X ( 0 ).
and for
y  0,
since
X
(5-23)
Fig. 5.3
Y  X ,
FY ( y )  P Y ( )  y   P  X ( )  y   F X ( y ).
(5-24)
Thus
y  0,
 f X ( y ),

f Y ( y )   F X (0 ) ( y ) y  0,

0,
y  0,


f X ( y )U ( y )  F X (0 )  ( y ).
(5-25)
8
PILLAI
Note: As a general approach, given Y  g ( X ), first sketch
the graph y  g ( x ), and determine the range space of y.
Suppose a  y  b is the range space of y  g ( x ).
Then clearly for y  a , FY ( y )  0 , and for y  b , FY ( y )  1, so
that F ( y ) can be nonzero only in a  y  b. Next, determine
whether there are discontinuities in the range space of y. If
so evaluate P Y ( )  y  at these discontinuities. In the
continuous region of y, use the basic approach
Y
i
FY ( y )  P  g ( X ( ))  y 
and determine appropriate events in terms of the r.v X for
every y. Finally, we must have F ( y ) for    y    , and
obtain
Y
fY ( y ) 
dFY ( y )
dy
in
a  y  b.
9
PILLAI
However, if Y  g ( X ) is a continuous function, it is easy to
establish a direct procedure to obtain f ( y ). A continuos
function g(x) with g ( x ) nonzero at all but a finite number
of points, has only a finite number of maxima and minima,
and it eventually becomes monotonic as | x |  . Consider a
specific y on the y-axis, and a positive increment  y as
shown in Fig. 5.4
Y
g(x)
y  y
y
x
x 3 x3   x3
x 1 x1   x1
x2   x2
x2
Fig. 5.4
fY ( y )
for
Y  g ( X ),
where
g ()
is of continuous type.
10
PILLAI
Using (3-28) we can write
P  y  Y ( )  y   y  

y  y
y
f Y ( u ) du  f Y ( y )   y .
(5-26)
But the event  y  Y ( )  y   y  can be expressed in terms
of X ( ) as well. To see this, referring back to Fig. 5.4, we
notice that the equation y  g ( x ) has three solutions x1 , x 2 , x 3
(for the specific y chosen there). As a result
when  y  Y ( )  y   y , the r.v X could be in any one of the
three mutually exclusive intervals
{ x1  X ( )  x1   x1 }, { x 2   x 2  X ( )  x 2 } or { x 3  X ( )  x 3   x 3 } .
Hence the probability of the event in (5-26) is the sum of
the probability of the above three events, i.e.,
P  y  Y ( )  y   y   P { x 1  X ( )  x 1   x 1 }
 P { x 2   x 2  X ( )  x 2 }  P { x 3  X ( )  x 3   x 3 } . (5-27) 11
PILLAI
For small
we get
 y ,  xi ,
making use of the approximation in (5-26),
f Y ( y )  y  f X ( x1 )  x1  f X ( x 2 )(   x 2 )  f X ( x 3 )  x 3 .
In this case,
rewritten as
 x1  0 ,  x 2  0
fY ( y ) 

f X ( xi )
and
|  xi |
y
i
and as
 y  0,
so that (5-28) can be
x 3  0 ,


i
(5-28)
1
 y /  xi
f X ( xi )
(5-29)
(5-29) can be expressed as
fY ( y ) 

i
1
dy / dx
f X ( xi ) 
xi

i
1
g ( x i )
f X ( x i ).
(5-30)
The summation index i in (5-30) depends on y, and for every
y the equation y  g ( x i ) must be solved to obtain the total
number of solutions at every y, and the actual solutions x1 , x 2 , 
12
all in terms of y.
PILLAI
For example, if Y  X , then for all y  0 , x1   y and x 2   y
represent the two solutions for each y. Notice that the
solutions x i are all in terms of y so that the right side of (5-30)
is only a function of y. Referring back to the example Y  X
(Example 5.2) here for each y  0 , there are two solutions
given by x1   y and x 2   y . ( f Y ( y )  0 for y  0 ).
Y  X
Moreover
2
2
2
dy
 2 x so that
dx
dy
dx
2
y
y
x  xi
and using (5-30) we get
 1

fY ( y )   2 y


f
x1
X
(
which agrees with (5-14).
y )  f X (
0,

y) ,
Fig. 5.5
X
x2
y  0,
(5-31)
otherwise
,
13
PILLAI
Example 5.5:
1
Y 
X
.
Find
Solution: Here for every y,
dy
 
dx
1
x
2
(5-32)
f Y ( y ).
x1  1 / y
dy
so that
dx
is the only solution, and
1

1/ y
x  x1
 y ,
2
2
and substituting this into (5-30), we obtain
fY ( y ) 
1
f X  .
 y
1
y
2
(5-33)
In particular, suppose X is a Cauchy r.v as in (3-39) with
parameter  so that
fX (x) 
 /
 x
2
In that case from (5-33), Y
fY ( y ) 
 /
1
y 
2
2
 (1 / y )
2

2
,
   x   .
 1/ X
has the p.d.f
(1 /  ) / 
(1 /  )  y
2
(5-34)
2
,
   y   .
(5-35)
14
PILLAI
But (5-35) represents the p.d.f of a Cauchy r.v with
parameter 1 /  . Thus if X  C ( ), then 1 / X  C (1 /  ).
Example 5.6: Suppose f X ( x )  2 x /  2 , 0  x   , and Y  sin X .
Determine f ( y ).
Solution: Since X has zero probability of falling outside the
interval ( 0 ,  ), y  sin x has zero probability of falling outside
the interval ( 0 ,1). Clearly f ( y )  0 outside this interval. For
any 0  y  1, from Fig.5.6(b), the equation y  sin x has an
infinite number of solutions  , x1 , x 2 , x 3 ,  , where x1  sin  1 y
is the principal solution. Moreover, using the symmetry we
also get x 2    x1 etc. Further,
Y
Y
dy
 cos x 
1  sin
2
x 
1 y
2
dx
so that
dy
dx

x  xi
1 y .
2
15
PILLAI
fX (x)
x3

(a)
x
y  sin x
y
x1
x 1
x2
x
x3

(b)
Fig. 5.6
Using this in (5-30), we obtain for

fY ( y ) 
1

1 y
i  
i0
2
0  y  1,
f X ( x i ).
(5-36)
But from Fig. 5.6(a), in this case f ( x )  f ( x )  f ( x
(Except for f ( x ) and f ( x ) the rest are all zeros).
X
X
1
X
2
1
X
3
X
4
) 0
16
PILLAI
Thus (Fig. 5.7)
fY ( y ) 

1
1 y
2
 f X ( x1 ) 
2 ( x1    x1 )

2
1 y
2
f X ( x2 )  


 


2
1 y
0,
2
,
1
1 y
2
fY ( y )
2 x2 
 2 x1
 2 
2 
 
 
2
0  y  1,
(5-37)

y
1
otherwise.
Fig. 5.7
Example 5.7: Let Y  tan X where X  U    / 2 ,  / 2  .
Determine f ( y ).
Solution: As x moves from   / 2 ,  / 2  , y moves from    ,    .
From Fig.5.8(b), the function Y  tan X is one-to-one
for   / 2  x   / 2 . For any y, x1  tan  1 y is the principal
solution. Further
Y
dy
dx

d tan x
 sec
2
x  1  tan
2
x 1 y
2
dx
17
PILLAI
so that using (5-30)
fY ( y ) 
1
f X ( x1 ) 
| dy / dx | x  x1
1/
1 y
2
,
   y   ,
(5-38)
which represents a Cauchy density function with parameter
equal to unity (Fig. 5.9).
fX (x)
 /2
 /2
x
fY ( y ) 
1
1 y
2
(a)
y  tan x
y
y
Fig. 5.9
 /2
x1  / 2
(b)
Fig. 5.8
x
18
PILLAI
Functions of a discrete-type r.v
Suppose X is a discrete-type r.v with
P ( X  x i )  p i , x  x1 , x 2 ,  , x i , 
(5-39)
and Y  g ( X ). Clearly Y is also of discrete-type, and
when x  x i , y i  g ( x i ), and for those y i
P (Y  y i )  P ( X  x i )  p i , y  y 1 , y 2 ,  , y i , 
Example 5.8: Suppose
X
(5-40)
 P (  ), so that
P( X  k )  e


k
,
k  0 ,1, 2 , 
(5-41)
k!
Define Y  X 2  1 . Find the p.m.f of Y.
Solution: X takes the values 0 ,1, 2 ,  , k ,  so that Y only
takes the value 1, 2 , 5, , k 2  1,
and
19
PILLAI
P (Y  k  1)  P ( X  k )
2
j  k 1
so that for
2

P (Y  j )  P X 

j 1  e


(
j 1
j  1)!
,
j  1, 2, 5,
, k  1,
2
.
(5-42)
20
PILLAI
```