Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently learned about finding density functions of functions of random variables using the cumulative distribution function. For example, computing the density function for the difference of two uniform random variables on [0,1] (as in Grinstead & Snell's free online book). I gave myself the following problem.

Say $X$ and $Y$ are independent random variables with exponential density $f(t) = a e^{-at}$. I'm trying to compute the density function for $Z = X-Y$, but I'm getting nonsense. Since $z<0$ is ok and the density function will go like $e^{-az}$, trying to check that $\int_{-\infty}^\infty f_{X-Y}(z) dz$ diverges! What is going wrong?

EDIT: The calculations are as follows. If $z > 0$, then $$ \begin{split} P(Z < z) &= \int_0^\infty dy \int_0^{y+z} dx a^2 e^{-a(x+y)} \\ &= 1 - \frac 1 2 e^{-a z} \end{split} $$ I found this by thinking about the (x,y) points satisfying $Y > X - z$, giving a region $y > 0, y+z > x > 0$. If $ z < 0$, $$ \begin{split} \displaystyle P(Z < z) &= \int_z^\infty dy \int_0^{y+z} dx a^2 e^{-a(x+y)} \\ &= -\frac 1 2 e^{-3 a z } + e^{-a z}.\end{split}$$

share|cite|improve this question
Can you show your computations for $f_{X-Y}$? In particular, when computing the distribution function of $Z=X-Y$, you need to be very careful that you are integrating over appropriate regions. I get $f_{X-Y}(z) = \frac{1}{2} a e^{-a|z|}$ which certainly integrates to 1. – Nate Eldredge Dec 6 '10 at 19:36
Your $z<0$ case is not quite right. In fact it cannot be, because your formula goes to $1$ as $z \to -\infty$ but it should go to 0. Since you are trying to consider the region where $y+z>x$, you should integrate $\int_{y=0}^{y=\infty} \int_{x=y+z}^{x=\infty}$. – Nate Eldredge Dec 6 '10 at 20:42
And for the $z > 0$ case, you want to integrate over the region $x > 0$, $y > 0$, $y+z>x$. Sketch this region for say $z=1$ and compare it to the region over which you are integrating. – Nate Eldredge Dec 6 '10 at 20:44
Nate, I had a typo, the $z>0$ and $z<0$ regions were flipped. I agree that my $z<0$ part is giving the problem, but I don't see how to fix it. – James Davidoff Dec 6 '10 at 21:01
Ahh!! I'm foolish. My integral for z < 0 should be $\displaystyle\int_{-z}^\infty$. Thanks Nate. – James Davidoff Dec 6 '10 at 21:17

In general, you are actually interested in Cross-correlation.

Let's consider your problem in the setting of cross-correlation. We'll begin by considering the distribution function of $X-Y$ for $t>0$ (this is enough, since $X-Y$ is a symmetric random variable, hence having a symmetric density function). Then, by the law of total probability (conditioning on $Y$), we have $$ {\rm P}(X - Y \le t) = \int_0^\infty {{\rm P}(X - Y \le t|Y = \tau )f(\tau ){\rm d}\tau } = \int_0^\infty {{\rm P}(X \le t + \tau )f(\tau ){\rm d}\tau }. $$ Of course, you can now calculate the right-hand side integral directly, and then differentiate with respect to $t$, but it is instructive to first differentiate with respect to $t$. Thus, we get $$ f_{X - Y} (t) = \frac{{\rm d}}{{{\rm d}t}}\int_0^\infty {F(t + \tau )f(\tau ){\rm d}\tau } = \int_0^\infty {f(t + \tau )f(\tau ){\rm d}\tau } , $$ where $F$ denotes the distribution function of $X$ (and $Y$). According to Wikipedia's link given above, this can be denoted as $f_{X-Y}(t) = (f \star f)(t)$ (read "$f_{X-Y}(t)$ is the cross-correlation of $f$ with itself"). Finally, from $f(u)= a {\rm e}^{-a u}$, $u > 0$, we find $f_{X-Y}(t) = (a/2){\rm e}^{-at}$, $t > 0$; then, by the aforementioned symmetry, $f_{X-Y}(t) = (a/2){\rm e}^{ - a|t|}$, for all $t \in \mathbb{R}$.

share|cite|improve this answer

You could also use transformation theorem for linear transformations like this

$V = X + Y, U = X$.

Then find Joint law ( law means cumulative distribution function) and then derive its marginal through

$ f_{V}(v)=\int_{-\infty}^{\infty} f_{U,V}(U,V) du $

share|cite|improve this answer
I doubt the OP is willing to work an answer out of your hint 5 years after asking it. – G. Sassatelli Oct 27 '15 at 11:32
Yeah... just noticed – Trelokoritso Oct 27 '15 at 11:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.