[Math] sum of two independent variables Z=X+Y, find pdf for Z

convolutionprobabilityprobability distributionsrandom variables

There are two independent random variables. Find density function of Z=X+Y

$\mathbf{\\ f_X(x)=\begin{cases}
1- \frac{x}{2} & 0\leq x\leq 2\\
0 & \text{otherwise}
\end{cases}}
\ \hspace{20pt} \
\mathbf{f_Y(y)=\begin{cases}
2-2y & 0\leq y\leq 1\\
0 & \text{otherwise}
\end{cases}}$

Would you please advice if the way I analyse this problem is correct.
The limits would be derived geometrically from the lines $y+x=3$, $y= -\frac{1}{2} x+1$ and $x+y=z$. Point A=(2z-2,2-z) where the $y= -\frac{1}{2} x+1$ crosses y+x=z

My understanding is that there would be two ways to solve this problem:

1) by finding the joint distribution function for $f_{X,Y}(x,y) = f_X(x)*f_Y(y)$ and then integrating the areas using double integrals

2) using the marginal $f_X(x)$ $f_Y(y)$ and applying the convolution concept.
Is it correct to think that the convolution is represented here by the line x+y=z sliding from down left to upper right ?

I guess the first method seems to be more computational intensive so the convolution should be easier, therefore I am trying to solve it using the convolution.

I found the correct function $f_X+Y(z)z$ for the first interval $0\leq z \leq 1$ but I got lost at the next ones.
Correct if I am mistaken, the function to integrate will be the same for the all the cases and there will be just the limits changing. I have difficulty with applying the correct limits for the integral.

Can anybody help to clarify it?

That's what I got for the $0\leq z \leq 1$

$\int_{0}^{z} f_X(z-y)f_Y(y) \ dy = \int_{0}^{z} (1-\frac{z-y}{2})(2-2y) \ dy =\\
\\
= \int_{0}^{z} (2-2y-z+y+zy-y^2) dy= [2y-y^2-zy+\frac{1}{2}y^2+\frac{1}{2}zy^2-\frac{1}{3}y^3]_{0}^{z}=2z-\frac{3}{2}z^2+\frac{1}{6}z^3$

The correct solution should be:

$\left\{\begin{matrix}
f_{X+Y}(z)=2z-\frac{3}{2}z^2 + \frac{1}{6}z^3 & 0\leq z \leq 1 \\
f_{X+Y}(z)=\frac{7}{6} + \frac{1}{2}z & 1 \leq z \leq 2 \\
f_{X+Y}(z)=\frac{9}{2} -\frac{9}{2}z -\frac{3}{2}z^2 – \frac{1}{6}z^3 & 2 \leq z \leq 3 \\
0 & z>3
\end{matrix}\right.$

Best Answer

$$f_X(x)=\begin{cases} 1- \frac{x}{2} & 0\leq x\leq 2\\ 0 & \text{otherwise} \end{cases} \ \hspace{20pt} f_Y(y)=\begin{cases} 2-2y & 0\leq y\leq 1\\ 0 & \text{otherwise} \end{cases}$$

1) by finding the joint distribution function for $f_{X+Y} =f_X (x)\cdot f_Y (y)$ and then integrating the areas using double integrals

You mean $f_{X,Y}(x,y)=f_X (x)\cdot f_Y (y)$, because they are independent. Plus, you don't need double integrals. See below.

2) using the marginal $f_X (x)$, $f_Y (y)$ and applying the convolution concept. Is it correct to think that the convolution is represented here by the line $x+y=z$ sliding from down left to upper right ?

I guess the first method seems to be more computational intensive so the convolution should be easier, therefore I am trying to solve it using the convolution.

The first method is the second method, because $f_X(x)f_Y(z-x)=f_{X,Y}(x,z-x)$ (see above).

tl;dr Convolution is the way to go.


$$\begin{align}f_{X+Y}(z) & = \int_\Bbb R f_X(x)f_Y(z-x) \operatorname d x \\[1ex] ~ & = \int_\Bbb R (1-\tfrac x 2)\mathbf 1_{0<x<2}\;(2-2(z-x))\mathbf 1_{0<z-x<1)}\operatorname d x \\[1ex] ~ & = \int_\Bbb R (2-x)(1-z+x)\mathbf 1_{0<x<2, z-1<x<z, 0<z<3}\operatorname d x \\[1ex] ~ & = \mathbf 1_{0<z<3}\int_{\max(0,z-1)}^{\min(2,z)} -x^2+(z+1)x+2(1-z) \operatorname d x \\[1ex] ~ & = {\quad\mathbf 1_{0<z\leq 1}\int_{0}^{z} -x^2+(z+1)x+2(1-z) \operatorname d x +\ldots \\\quad +\mathbf 1_{1<z\leq 2}\int_{z-1}^{z} -x^2+(z+1)x+2(1-z) \operatorname d x +\ldots \\\quad +\mathbf 1_{2<z<3}\int_{z-1}^{2} -x^2+(z+1)x+2(1-z) \operatorname d x} \end{align}$$

Thus:

$$f_{X+Y}(z) =\begin{cases}\int\limits_{0}^{z} -x^2+(z+1)x+2(1-z) \operatorname d x & : 0<z\leq 1 \\[0ex] \int\limits_{z-1}^{z} -x^2+(z+1)x+2(1-z) \operatorname d x & : 1<z\leq 2\\[0ex]\int\limits_{z-1}^{2} -x^2+(z+1)x+2(1-z) \operatorname d x & : 2<z<3\\[0ex] 0 & :\text{otherwise}\end{cases}$$

Now integrate to complete.


Addendum:

How do we know that the corresponding limit to the $0≤z≤1$ is from $z-1$ to $z$ and for $2≤z≤3$ from $z-1$ to $2$. Could you explain how you derived it? I don't understand this moment. – Michal

Can anyone explain in an accessible way what determines the limits for the integrals? – Michal

Firstly, we know the support for $X$ is $0\leq X\leq 2$, and the support for $Y$ is $0\leq Y\leq 1$.   These are (by definition) the regions within which the density functions are non-zero.

We wish to determine the density function for $Z=X+Y$ by using the convolution method.   So we must take $0\leq X\leq 2$ and $0\leq Z-X\leq 1$ and separate out the intervals for $X$ and $Z$.   One being the bounds of the integral, the other the support for $Z$.

Firstly, the support for $Z$ is clearly: $$\begin{align}(0\leq X\leq 2)\; \wedge \;(0\leq Z-X \leq 1) & \iff (0\leq X \,\leq Z \leq\, 1+X \leq 1+2) \\ & \iff (0\leq Z\leq 3) \end{align}$$

Secondly, the integration for $X$ is over: $$\begin{align}(0\,\leq\, X\,\leq\, 2) \;\wedge\; (0\,\leq (Z-X) \leq\, 1) & \iff (0\,\leq\, X\,\leq\, 2)\; \wedge \; (Z-1\,\leq\, X\, \leq\, Z) \\ & \iff \big(\max(0, Z-1)\,\leq \,X\,\leq\, \min(2, Z)\big) \end{align}$$

Now, when $Z\leq 1$ then $\max(0, Z-1)=0$ and when $Z > 1$ then $\max(0,Z-1)=Z-1$

Likewise, when $Z\leq 2$ then $\min(2, Z)=Z$ and when $Z > 2$ then $\min(2,Z)=2$

Thus, the convolution integral will have three different bounds depending on where in the support $Z$ lies.

$$ \mathbf 1_{0\leq Z\leq 3} \int_{\max(0, Z-1)}^{\min(2, Z)} \ldots\operatorname d x = \begin{cases}\int_0^Z\ldots\operatorname d x & : 0\leq Z\leq 1\\[1ex]\int_{Z-1}^{Z} \ldots\operatorname d x & : 1< Z\leq 2\\[1ex]\int_{Z-1}^{2} \ldots\operatorname d x & : 2< Z\leq 3\\[1ex] 0 & :\text{elsewhere}\end{cases}$$

Related Question