Functions of Random Variables Let’s consider a continuous r.v., Y , which is a differentiable, increasing function of a second continuous r.v., X: Y = g(X). Because g is differentiable and increasing, g0 and g−1 are guaranteed to exist. Because g maps all x ≤ s ≤ x + ∆x to y ≤ t ≤ y + ∆y: Z x+∆x Z y+∆y fY (t)dt. fX (s)ds = x y It follows that for small ∆x: fY (y)∆y ≈ fX (x)∆x. fY (y) Y = g(X) ∆y ∆x fX (x) Dividing by ∆y, we get an approximate expression for fY in terms of fX : ∆x fY (y) ≈ fX (x) . ∆y Functions of Random Variables (contd.) This is exact in the limit ∆x → 0: ∆x fY (y) = lim fX (x) ∆x→0 ∆y 1 = lim fX (x) ∆x→0 ∆y/∆x fX (x) = lim . ∆x→0 ∆y/∆x From calculus we know that: ∆y g(x + ∆x) − g(x) lim = lim = g0(x). ∆x→0 ∆x ∆x→0 ∆x Consequently fX (x) fY (y) = 0 . g (x) Functions of Random Variables (contd.) Substituting g−1(y) for x: fX (g−1(y)) fY (y) = 0 −1 g (g (y)) yields an expression for fY in terms of g0, g−1, and fX . Linear Example Consider a continuous r.v., Y , which is a linear function of a continuous r.v., X. Specifically, Y = aX + b. It follows that g(x) = ax + b g0(x) = a g−1(y) = (y − b)/a. Substituting the above into fX (g−1(y)) fY (y) = 0 −1 g (g (y)) yields 1 y−b fY (y) = fX . a a Linear Example (contd.) Let fX (x) = 2 √1 e−(x−µ) /2, then 2π 2 y−b 1 − a −µ /2 fY (y) = √ e a 2π . Linear Example (contd.) Unfortunately, there is a problem. When a = −1, the function g is not increasing (it is decreasing). Consequently, − fY (y)∆y ≈ fX (x)∆x. It follows that for decreasing functions, fX (g−1(y)) . fY (y) = 0 −1 −g (g (y)) However, we can derive a function which is correct in both cases by replacing g0(.) with |g0(.)| in the expression relating fY (.) and fX (.): fX (g−1(y)) fY (y) = 0 −1 . |g (g (y))| Quadratic Example Consider a continuous r.v., Y , which is a quadratic function of a continuous r.v., X. Specifically, Y = X 2. It follows that g(x) = x2 g0(x) = 2x √ −1 g (y) = y. Substituting the above into fX (g−1(y)) fY (y) = 0 −1 |g (g (y))| yields √ fX ( y) fY (y) = √ . |2 y| Quadratic Example (contd.) Let fX (x) = 2 √1 e−x /2, 2π then 1 e−y/2 fY (y) = √ √ . 2π |2 y| Unfortunately, there is a problem: 1 e−y/2 1 √ fY (y)dy = √ dy = 6= 1. 2 0 0 2π |2 y| Can anyone see the mistake? Z ∞ Z ∞ Quadratic Example (contd.) The mistake is that two different values of Y satisfy Y = X 2: √ −1 g (y) = ± y. We decided to use the positive square root arbitrarily and ignored the negative square root. Hence the factor of two error. In general, if a function does not have a unique inverse, we must sum over all possible inverse values: fX (g−1 i (y)) fY (y) = ∑ 0 −1 . i=1 |g (gi (y))| n Quadratic Example (contd.) √ √ −1 −1 Let g1 (y) = y and g2 (y) = − y, then −1 fX (g−1 (y)) f (g X 1 2 (y)) fY (y) = 0 −1 + 0 −1 |g (g1 (y))| |g (g2 (y))| 1 e−y/2 = √ √ . 2π y This is an example of the χ2 distribution. Kinetic Energy Recall from physics, that the kinetic energy, K, of a moving body is given by 1 2 K = mV 2 where m is mass and V is velocity. Let V be a normally distributed random variable with mean, µ, and variance, σ2: 1 −(v−µ)2/2σ2 fV (v) = √ e . σ 2π We would like to compute fK (k), the p.d.f for the continuous random variable, K. Kinetic Energy (contd.) −1 We start by computing, g0, g−1 , and g 1 2 : 1 2 g(v) = mv 2 0 g (v) = mv p −1 g1 (k) = 2k/m p −1 g2 (k) = − 2k/m. Substituting fV (v) and the above into −1 (k)) fV (g−1 f (g V 1 2 (k)) fK (k) = 0 −1 + 0 −1 |g (g1 (k))| |g (g2 (k))| yields √ 2 − 2k/m−µ /2σ2 √ 2 − − 2k/m−µ /2σ2 +e p √ fK (k) = σ 2π m 2k/m √ 2 √ 2 2 − 2k/m−µ /2σ − 2k/m+µ /2σ2 e +e √ = . 2σ π k m e