PROBABILITY AND STATISTICS FOR ENGINEERING Functions of a Random Variable Hossein Sameti Department of Computer Engineering Sharif University of Technology Functions of a Random Variable X: g(X): a r.v defined on the model (, F , P ), a function of the variable x, Y g ( X ). Is Y necessarily a r.v? If so what is its PDF FY ( y), pdf fY ( y ) ? 2 Functions of a Random Variable With Y ( ) B , In particular FY ( y ) P (Y ( ) y ) P g ( X ( )) y For a specific 𝑦, the values of 𝑥 such that 𝑔(𝑥) ≤ 𝑦 form a set on the 𝑥 axis denoted by 𝑅𝑦 . Clearly, g(X ξ ) ≤ 𝑦 if 𝑋(𝜉) is a number in the set 𝑅𝑦 . Hence 𝐹𝑌 𝑦 = 𝑃(𝑋𝜖𝑅𝑦 ) 3 For 𝑔(𝑋) to be a random variable, the function 𝑔(𝑥) must have these properties: – Its domain must include the range of the random variable 𝑋. – It must be a Borel function, that is, for every 𝑦, the set 𝑅𝑦 such that 𝑔 𝑥 ≤ 𝑦 must consist of the union and intersection of a countable number of intervals. Only then {𝑌 ≤ 𝑦} is an event. – The events {𝑔 𝑋 = ±∞} must have zero probability. 4 Example: Y aX b For a 0 : For a 0, FY ( y ) PY ( ) y FY ( y ) PY ( ) y PaX ( ) b y PaX ( ) b y y b P X ( ) a y b 1 FX , a y b P X ( ) a y b FX . a And fY ( y ) 1 y b fX . a a We conclude: and hence fY ( y ) fY ( y ) 1 y b fX . |a | a 1 y b fX . a a 5 Example: Y X 2 FY ( y ) PY ( ) y PX 2 ( ) y . y 0, For X 2 ( ) y , FY ( y ) 0, y 0. For y 0, Y X2 y according to the figure, 2 the event {Y ( ) y} { X ( ) y} is equivalent to {x1 X ( ) x2 }. x1 x2 X 6 Example: Y X 2 - continued FY ( y ) Px1 X ( ) x2 FX ( x2 ) FX ( x1 ) FX ( y ) FX ( y ), y 0. 1 f ( y ) f X ( y ) , y 0, fY ( y ) 2 y X 0, otherwise . If f X (x ) represents an even function, fY ( y ) 1 fX y y U ( y ). 7 Example: Y X 2 - continued If X ~ N (0,1), so that f X ( x ) 1 x2 / 2 e , 2 We obtain the p.d.f of Y X 2 to be fY ( y ) 1 e y / 2U ( y ). 2y which represents a Chi-square r.v with n = 1, since (1 / 2) . Thus, if X is a Gaussian r.v with 0, then Y X2 represents a Chi-square r.v with one degree of freedom (n = 1). 8 Example For: X c, X c, Y g ( X ) 0, c X c, X c, X c. g( X ) c X c We have P(Y 0) P(c X ( ) c) FX (c) FX (c). For y 0, we have x c, and Y ( ) X ( ) c so that FY ( y ) P Y ( ) y P( X ( ) c y ) P X ( ) y c FX ( y c), For y 0, we have x c, and y 0. Y ( ) X ( ) c so that FY ( y ) P Y ( ) y P( X ( ) c y ) P X ( ) y c FX ( y c), y 0. 9 Example – continued Thus, f X ( y c ), y 0, fY ( y ) [ FX ( c ) FX ( c)] ( y ), f ( y c ), y 0. X FX (x) FY ( y ) g( X ) c c X x y 10 Example: Half-wave Rectifier Consider Y g ( X ); g ( x ) x, x 0, Y 0, x 0. X In this case P(Y 0) P( X ( ) 0) FX (0). For y 0, Thus, Y X, FY ( y ) PY ( ) y P X ( ) y FX ( y). since y 0, f X ( y ), fY ( y ) FX (0) ( y ) y 0, 0, y 0, f X ( y )U ( y ) FX (0) ( y ). 11 Continuous Functions of a Random Variable A continuous function g(x) g (x ) nonzero at all but a finite number of points has only a finite number of maxima and minima eventually becomes monotonic as | x | . Consider a specific y on the y-axis, and a positive increment y g (x ) y y y x1 x1 x1 x2 x2 x2 x3 x3 x3 x 12 Continuous Functions of a Random Variable For fY ( y ) Y g (X ) where g () is of continuous type, Py Y ( ) y y y y y y g (x ) has three solutions x1 , x2 , x3 fY (u )du fY ( y ) y. when y Y ( ) y y, X could be in any one of three disjoint intervals: g ( x) {x1 X ( ) x1 x1}, y y {x2 x2 X ( ) x2 } or {x3 X ( ) x3 x3} . y x1 x1 x1 x2 x2 x2 x x3 x3 x3 So, Py Y ( ) y y P{x1 X ( ) x1 x1} P{x2 x2 X ( ) x2 } P{x3 X ( ) x3 x3} . 13 Continuous Functions of a Random Variable For small y, xi , we get fY ( y )y f X ( x1 )x1 f X ( x2 )( x2 ) f X ( x3 )x3. Here, x1 0, x2 0 and x3 0, so | xi | 1 fY ( y ) f X ( xi ) f X ( xi ) y i i y / xi As y 0, 1 1 fY ( y ) f X ( xi ) f X ( xi ). i dy / dx x i g ( xi ) i If the solutions are all in terms of y, the right side is only a function of y. 14 Example YX 2 Revisited For all y 0, x1 y and x2 y Y X2 y fY ( y ) 0 for y 0 . x1 Moreover dy 2 x so that dx and using fY ( y ) i X x2 dy 2 y dx x xi 1 f X ( xi ) , g ( xi ) 1 f ( y ) f X ( y ) , y 0, fY ( y ) 2 y X 0, otherwise , which agrees with previous solution. 15 1 Example: Y X Find fY ( y ). Here for every y, x1 1 / y is the only solution, and dy 1 2 so that dx x and substituting this into dy dx fY ( y ) i x x1 1 2 y , 2 1/ y 1 f X ( xi ) , we obtain g ( xi ) 1 1 fY ( y ) 2 f X . y y 16 Example Suppose f X ( x) 2 x / 2 , 0 x , and Y sin X . Determine fY ( y ). X has zero probability of falling outside the interval (0, ). y sin x has zero probability of falling outside (0,1). fY ( y) 0 outside this interval. For any 0 y 1, the equation y sin x solutions , x1 , x2 , x3 ,, where x1 sin 1 using the symmetry we also get so that x2 x1 has an infinite number of y is the principal solution. etc. Further, dy cos x 1 sin 2 x 1 y 2 dx dy dx 1 y2 . x xi 17 Example – continued f X ( x) (a) y sin x x3 x y x1 x1 x2 x3 x (b) for 0 y 1, fY ( y ) i i 0 1 1 y 2 f X ( xi ). In this case f X ( x1 ) f X ( x3 ) f X ( x4 ) 0 (Except for f X ( x1 ) and f X ( x2 ) the rest are all zeros). 18 Example – continued Thus, fY ( y ) 1 1 y f X ( x1 ) f X ( x2 ) 2 2 x1 2 x2 2 2 2 1 y 1 2 , 0 y 1, 2( x1 x1 ) 1 y 2 2 1 y2 0, otherwise. fY ( y ) 2 1 y 19 Example: Y tan X , X / 2, / 2 . As x moves in / 2, / 2 , y moves in , . The function Y tan X is one-to-one for / 2 x / 2 . f X (x ) 1 For any y, x1 tan y is the principal solution. / 2 /2 dy d tan x sec 2 x 1 tan 2 x 1 y 2 dx dx y tan x / 2 1 1/ fY ( y ) f X ( x1 ) , 2 | dy / dx | x x1 1 y y x y x x1 / 2 (Cauchy density function with parameter equal to unity) fY ( y ) 1 1 y2 y 20 Functions of a Discrete-type R.V Suppose X is a discrete-type r.v with P( X xi ) pi , x x1, x2 ,, xi , and Y g ( X ). Clearly Y is also of discrete-type, and when x xi , yi g ( xi ), and for those yi s, P(Y yi ) P( X xi ) pi , y y1, y2 ,, yi , 21 Example Suppose X ~ P( ), so that P( X k ) e k k! , k 0,1,2, Define Y X 2 1. Find the p.m.f of Y. Solution: X takes the values 0,1,2,, k , Y only takes the values 1, 2, 5, , k 2 1, P(Y k 2 1) P( X k ) so that for j k 2 1 P(Y j ) P X j 1 j 1 e , j 1, 2,5, , k 2 1, . ( j 1)! 22