Anda di halaman 1dari 10

Change of Continuous Random Variable

All you are responsible for from this lecture is how to implement the Engineers Way (see page 4) to compute how the probability density function changes when we make a change of random variable from a continuous random variable X to Y by a strictly increasing change of variable y = h(x). So for the purpose of surviving Stat 400 you can start reading in 2. I give two examples following the statement of the theorem and its proof(s) where the method gives the correct result, then I give an example where it doesnt work when h(x) is not one-to-one. Let X be a continuous random variable. I will assume for convenience that the set of values taken by X is the entire real line R. If the set of values taken by X is an interval, for example [0, 1], the formula for the change of density if the same but we dont know the interval where the new density will be nonzero (the support). We will treat this point later. Let y = h(x) be a real-valued strictly-increasing function (so h is one-to-one). Since h is one-to-one it has an inverse function x = g (y ). We want to dene a new random variable Y = h(X ). There is only one possible denition, to nd it we pretend Y exists and compute for each pair of numbers c and d with c < d what the Y -probability P (c Y d) has to be in terms of an X -probability. P (c Y d) = P (c h(X ) d) = P (g (c) g (h(X )) g (d)) = P (a X b). Here we dene a and b by g (c) = a and g (d) = b or equivalently h(a) = c and h(b) = d. Note that the last equation holds because g (h(X )) = X since g is the inverse of h. Note c h(X ) d g (c) g (h(X )) g (d) because h is strictly increasing and the inverse of a strictly increasing function is strictly increasing so g preserves inequalities; that is, a b c g (a) g (b) g (c). So the above calculation forces us to dene the new random variable Y by P (c Y d) := P (a X b) where a = g (c) and b = g (d). (1)

In other words, the probability that the new random variable Y will be in an interval [c, d] is dened to be the probability that the old random variable X will be in the transformed interval [g (c), g (d)] = [a, b]. To begin with, Equation (1) is just a rule for assiging a real number to each interval [c, d]. It turns out (it follows from the second proof of the next theorem) that this formula (1) denes a probability measure P on the line. In other words if we dene P as above then P satises the axioms for a probability measure. Also it follows from the second proof that the new random variable Y (with probabilities dened using Equation (1)) is continuous with a new density function related to the density function of the original random variable X in a simple way via the inverse g (y ) of the function h(x). The fact that Y as dened by (1) is continuous also follows from the either proof of the next theorem. The point of this lecture is to see how this works and to show you how to make explicit computations in examples. 1

The Theoretical Justication of the Engineers Way

I will give two proofs of the formula for fY (y ) The rst proof assumes that Equation (1) does in fact dene a continuous random variable. It procedes in two stages. First, we compute the cdf FY of the new random variable Y in terms of FX . We then nd the density function fY (y ) of the new random variable Y we dierentiate the cdf fY (y ) = d FY (y ). dy

The second proof uses the change of variable theorem from calculus. Dont let the next proof(s) scare you - you wont be tested on them. But they justify the Engineers Way, a simple rule to compute the probability density function of the new random variable Y in terms of the probability density function of the original random variable X . Theorem 1.1 Suppose X is continuous with probability density function fX (x). Let y = h(x) with h a strictly increasing continuously dierentiable function with inverse x = g (y ). Then Y = h(X ) dened by (1) is continuous with probability density function fY (y ) given by (2) fY (y ) = fX (g (y ))g (y ) Proof. We will give two proofs of Equation (2). The rst proof has the advantage that it is easier to understand and gives a formula for the new cdf as well but involves a tricky point-the appearance of the constant C . To state it loosely, the problem is that we might not have g () = (we state this problem carefully in terms of limits below). The second proof Equation (2) uses the change of variable theorem. It has the advantage of giving a direct computation of P (c Y d). From this formula we see that Equation (1) does in fact dene a probability measure and moreover the associated random variable Y is continuous. Indeed, in the second proof we show directly by applying the change of variable formula to P (a X b) that we have
d

P (c Y d) =
c

fX (g (y ))g (y )dy

(3)

Equation (3) means that the equation (1) does in fact dene a probability measure and the corresponding random variable Y is continuous with probability density function fX (g (y ))g (y ). First proof We rst compute FY (y ) in terms of FX (x). There is a tricky point here. There is no reason why limy g (y ) = . But the limit does exist (I leave that to you). Suppose limy g (y ) = L. FY (y ) =P (Y y ) = P ( < Y y ) = P ( < h(X ) y ) =P (L X g (y )) = FX (g (y )) FX (L) = FX (g (y )) C. So we get FY (y ) = FX (g (y )) C 2 (4)

where (roughly) C = FX (g ()). Note that the third equality holds because g (y ) is also strictly increasing (because the inverse of a strictly increasing function is strictly increasing) so g preserves inequalities; that is, a b g (a) g (b). So apply g to each side of the inequality h(X ) y to get g (h(X )) h(y ). But g (h(X ) = X since g h = Id because g is the inverse of h. Next we dierentiate the function on the right of Equation (4) with respect to y using the Chain Rule to get fY (y ) (since the derivative of the cdf FY (y ) with respect to y is the pdf fY (y )). fY (y ) = d d FY (y ) = (FX (g (y )) C ) = FX (g (y ))g (y ). dy dy (5)

But since FX (x) = fX (x) for any number x we get FX (g (y )) = fX (g (y )) and substituting into the last term of Equation (5) we get fY (y ) = fX (g (y ))g (y ). This completes the rst proof of the Engineers Way. Second proof Let a, b be real numbers with a < b. By denition P (c Y d) = P (a X b) with a = g (c) and b = g (d). But since X is continuous with density function fX we have
b g (d) d

P (a X b) =
a

fX (x)dx =
g (c)

fX (x)dx =
c

fX (g (y ))g (y )dy.

The last inequality is the change of variable theorem for denite integrals. So we get: for every c, d R with c < d we have
d

P (c Y d) =
c

fX (g (y ))g (y )dy.

But this says that fX (g (y ))g (y ) is the probability density function of Y . I didnt prove this theorem in class. The previous proofs are probably a little hard for many of you right now but they justify what I called The Engineers Way in class. The Engineers Way from Class Here is the way I stated the Engineers Way in class. Start with fX (x)dx. Substitute x = g (y ) for the x in fX (x) and the x in dx to get f (g (y ))dg (y ). Now use dg (y ) = g (y )dy to get f (g (y ))g (y )dy . Then I told you that the function f (g (y ))g (y ) multiplying dy is the probability density function of the new (transformed) random variable Y . This is the Engineers Way from class. But the function f (g (y ))g (y ) really is the density function of the new random variable Y according to the theorem above. So the simple rule works. There is only one problem, to implement the Engineers Way given X ,Y and h you have to compute the inverse function x = g (y ) to y = h(x). This amounts to solving the equation h( x) = y (6)

for x in terms of y . This can be impossible to do. However the functions I give you on tests will be easy to invert. 3

How to Implement the Engineers Way

Here is where you should start reading for the purpose of preparing for tests. I will work out two examples.

2.1

An easy example

Suppose X has the linear density so 2x, 0 x 1 0, otherwise. We will make the change of variable y = x. So h (x) = x so we want to compute the density function of the random variable Y = X . The inverse function to h(x) is given by x = y 2 = g (y ). Now we implement the Engineers Way. fX (x) = Step One: Multiply the density by dx to get fX (x)dx = 2xdx. Step Two: nd the inverse function g (y ) to h(x) = x, so we have to solve Equation (6), that is we have to solve for x in terms of y in the equation x=y The solution is clearly x = y 2 so g (y ) = y 2. Step Three: Using the formula x = y 2 rewrite fX (x)dx = 2xdx in terms of y . So substituting y 2 for x in both places we get fX (g (y ))dg (y ) = 2y 2 d(y 2) = 2y 22ydy = 4y 3 dy. Step Four: The Engineers Way tells us the result must be the new density function fY (y ) of y multiplied by dy and hence fY (y )dy = 4y 3dy and so fY (y ) = 4y 3 Step Five: Find the support of Y , roughly, the domain where Y is nonzero (see Section 4). From Section 4, we know that the support is [h(0), h(1)] = [ 0, 1] = [0, 1]. On the complement of [0, 1] the fY (y ) is zero. So Y has the cubic density fY (y ) = 4y 3 , 0 y 1 0, otherwise.

2.2

A much more important example

We will use the Engineers way to prove that standardizing a general normal random variable produces a standard normal variable. This is a result we use over and over in the course so it is nice to understand why it is true. Note that we will be using z instead of y in what follows. We will use the change of variable z = h(x) = x hence x = g (z ) = z + . Theorem 2.1 Suppose X N (, 2 ). Then Z = Proof. We have
x) 2 1 fX (x) = e( ) . 2 Now we apply the Engineers Waystep by step. This is what you need to learn to do.

N (0, 1).

Step One: Multiply the density by dx to get fX (x)dx =

1 e( 2

x) 2 )

dx.

Step Two: nd the inverse function g (z ) to h(x) = x , so we have to solve Equation (6), that is we have to solve for x in terms of y in the equation

x =z The solution is clearly x = z + so g (z ) = z + .


1 Step Three: Using the formulas x = z + and z = x rewrite 2 e 2 ( ) dx 2 in terms of z . So we get (noting since z = x ), the argument ( x ) of the 2 exponential function is in fact just (z ) )
1 x) 2

fX (g (z ))dz =

1 1 1 1 2 2 e 2 (z) d(z + ) = e 2 (z) dz. 2 2

Step Four: Cancel the s to get 1 z2 fX (g (z ))dz = e 2 dz. 2 Step Five: We have h() = and h() = so the support of Z is still R = (, ). But the whole point of the Engineers Way is that fX (g (z ))dz is the density function fZ (z ) of the new random variable Z multiplied by dz . So
z2 1 fZ (z )dz = e 2 dz. 2

Cancelling the dz s we get 1 z2 fZ (z ) = e 2 , < z < . 2 But the right-hand side is the density function of a standard normal random variable, so Z has standard normal distribution. 5

Remark 2.2 Dont forget to substitute g (z ) for the x in the dx. I will now show that the Engineers Way does not always give the right answer if h(x) is not one-to-one.

A Quadratic Change of Variable

We will now prove the following theorem that is very important in statistics. Denition 3.1 A random variable X is said to have chi-squared distribution with degrees of freedom abbreviated X 2( ), if fX (x) =
x 1 x 2 1 e 2 2 2 ( ) 2

x0 otherwise

(7)

We are now going to prove a theorem which is very important in statistics - the square of a standard normal random variable has chi-squared distribution with one degree of freedom. This amounts to solving 4.4, Problem 71 in the text. In terms of equations Theorem 3.2 Z N (0, 1) Y = Z 2 2(1). We rst note that if = 1 (and changing x to y and X to Y in the Equation (7)) we have fY (y ) = Substituting ( 1 )= 2
1 y 1 1 e 2, 2 ( 2 ) y

x0 otherwise

(8)

0,

in Equation (8) we obtain fY (y ) =


1 y 1 e 2, 2 y

x0 otherwise

0,

(9)

So we have to get the density function on the right-hand side of Equation (9) when we make the change of variable y = z 2 starting with the standard normal density z2 1 fZ (z ) = e 2 . 2 Note that the change of variable is two-to-one, so there is no guarantee that the Engineers Way will work and in fact it gives 1 times the correct answer (try it). So 2 the answer is o by a factor of 1 . It is no coincidence that the map h(z ) is two-to-one. 2 So lets prove the theorem. Proof. The idea of the proof (what I called the Careful Way in class) is to rst compute the cdf FY (y ) of the transformed random variable Y = Z 2 in terms of the cdf of the original random variable Z . Recall we have denoted the cdf of the standard normal random variable by (z ). Once we have the cdf FY (y ) of Y we can get the pdf fY (y ) by dierentiating it with respect to y : fY (y ) = d FY (y ). dy 6

Away we go. We have FY (y ) = P (Y y ) = P (Z 2 y ) = P ( y Z y ) = 2( y) 1 Here the last equation comes from what I called the handy formula for the probability that a standard normal random variable is between a: P (a Z a) = 2(a) 1. In fact, the key step is the next-to-last equality. The point is that we can solve the nonlinear inequality y 2 c for y easily. Indeed we have (10) y 2 c c y c Thus we have our desired expression FY (y ) = 2( y) 1. Now we have to dierentiate this equation with respect to y using that the derivative z2 e 2 . of at z is the standard normal density (z ) = 1 2 First we get without eort d d d FY (y ) = [2( y) 1] = 2 [( y )]. dy dy dy Now comes the hard part - the chain rule part. We use the chain rule to get the rst z2 equality below. In the third term below the notation (e 2 )|z= y ) means you take y z2 the function e 2 and evaluate it at z = y to get e 2 which gives the fourth term. So
y y 1 1 1 1 1 1 1 1 z2 d d [( y)] = 2 ( y ) [ y ] = 2[ (e 2 |z=y )] [ ] = 2[ ] [ e 2 ] = e 2 . dy dy 2 y 2 y y 2 2 2

But this last expression is the pdf of a chi-squared random variable with one degree of freedom (compare with Equation (9)).

I dont expect many people to understand the next remark but Ill put it in for those people who have taken some more advanced math courses. Remark 3.3 The fact that the support (see the next denition) of fY is [0, ) is because the support of fZ was (, ) and the image of (, ) under the map h(z ) = z 2 is [0, ). The support of the new density is always the image of the support of the old density under the change of variable map.

How the End-Points Change under h(x)

We begin this section with a very useful denition (you will learn the denition of closure in Math 410). Denition 4.1 The support of a function f on the real line is the closure of set of all points x where f (x) is nonzero. In all our examples of density functions the set of points where f is nonzero is either a single closed interval [a, b], a single open interval (a, b) , a single half open interval (a, b] or [a, b) or [0, ), (0, ), (, ). Taking the closure just adds the missing end points. So, in the rst four cases the support is [a, b], in the next two the support is [0, ) and the last it is (, ). We now state Theorem 4.2 Suppose the density function fX (x) has support the interval [a, b] and y = h(x) with h strictly increasing. Then the support of the density function fY (y ) is the (image) interval [h(a), h(b)]. Proof. The next proof is not quite correct but it gives the main idea. For convenience we assume h (x) and hence g (y ),is never zero (this isnt true for the strictly increasing function h(x) = x3 but I want to keep things easy here). Suppose also for convenience that we are in the rst case. Then since fY (y ) = fX (g (y )))g (y )) and g (y ) is never zero we nd that fY (y ) = 0 fX (g (y )) = 0 a g (y ) b h(a) h(g (y )) h(b). The last step follows since h(y) is (strictly) increasing iand any increasing function preserves inequalities. But h(g(y)) =y since g is the inverse function to h. Hence we obtain fY (y ) = 0 h(a) y h(b). In other words the set where fY (y ) is nonzero is exactly the closed interval [h(a), h(b)].

Remark 4.3 The point is that h maps the set (no matter what it is) where fX is nonzero to the set where fX g is nonzero.

Linear change of a uniform random variable

We now do an example. Suppose X U (0, 1), that is X has uniform distribution on [0, 1] so 1, 0 x 1 fX (x) = 0, otherwise.
b Let y = h(x) = ax + b with a > 0 so x = g (y ) = y . So we are making the linear a change of random variable Y = aX + b. So the support of fX is the interval [0, 1]. Now h(0) = b and h(1) = a + b so the support of the density function of the transformed

random variable Y = aX + b is [a, a + b] by Theorem 4.2. We now compute the density of Y . Assuming y [0, 1] we have fY (y ) dy = fX ( So fY (y ) = We have proved Theorem 5.1 The linear change y = ax + b of a random variable X with uniform distribution on [0, 1] produces a random variable Y with uniform distribution on [a, a + b].
1 , a

yb 1 yb ) d( ) = 1 dy. a a a by a+b otherwise

The Law of the Unconscious Statistican

Theorem 6.1 Suppose X is a continuous random variable with density fX (x) with support [a, b]. Suppose we change variables to Y = h(X ). Then the expected value of the new random variable Y can be computed from the density of the original random variable X according to the formula
b

E (Y ) =
a

h(x)fX (x)dx.

(11)

The theorem gets its name because a statistician who didnt know what he was doing would get the right answer by plugging h(x) into the integral on the right-hand side of Equation (11) and would thereby unconsciously compute the expected value of the new random variable Y . One of the main points of the theorem is that you can compute E (Y ) without computing fY (y ). I want to emphasize that given y = h(x) it can be impossible to solve for the inverse function x = g (y ) so you cant use the Engineers Way. Even in this case you can still compute E (Y ).

Comparison with the Discrete Case

The corresponding result for how the probability mass function changes under a oneto-one change of variable y = h(x) is very easy. Theorem 7.1 Suppose X is a discrete random variable with probability mass function pX (x). Suppose h(x) is a one-to-one function. Put Y = h(X ). Then pY (y ) = pX (g (y )). There is no factor of g (y ) multiplying pX (g (y )) in the discrete case. (12)

Proof. By denition pY (y ) = P (Y = y ) = P (h(X ) = y ) = P (X = g (y )) = pX (g (y )).

The reason the continuous case is so dicult is because in the continuous case P (Y = y ) = 0 for all y. The density function fY (y ) does not have a description as a probability of an event involving Y . Also it is not true in the discrete case that pY (y ) = d FY (y ). dy

So there is no chain rule way to compute pY (y ).

10