# Given joint pdf find $f(z)$, where $Z=X+Y$

Let $f_{X,Y}(x,y)=\frac{1}{8}$ for $-2<x<2$, $0<y<2$. Find $f(z)$ where $Z=X+Y$.

I am having difficulty solving the above problem. My attempt at a solution relies on a convolution formula, which says that the $pdf$ of $Z=X+Y$, given the joint $pdf$ $f(x,y)$ is given by $$f_Z(z)= \int_{s+t=z} f(s,t)ds=\int_{-\infty}^{\infty} f(s,z-s)ds$$. So first note that $f(s,z-s)=\frac{1}{8}$ if $-2<s<2$ and $0<z-s<2$. Then note that $0<z-s<2$ is the same as $z-2<s<z$. But these regions depend on the value of $z$. Hence, $$$$f_Z(z)= \begin{cases} \int_{-2}^{z} \frac{1}{8}ds, & \text{if}\ 0\leq z \leq2\\ \int_{z-2}^{2} \frac{1}{8}ds, & \text{if}\ 2<z\leq4 \end{cases}$$$$. After evaluating the integrals, I get

$$$$f_Z(z)= \begin{cases} \frac{z-2}{8}, & \text{if}\ 0\leq z \leq2\\ \frac{4-z}{8}, & \text{if}\ 2<z\leq4 \end{cases}$$$$.

I have solved similar problems like this one but all of them have been defined over the intervals $0<x<1$ and $0<y<1$. In this problem, however, we have the intervals $(-2,2)$ for $x$ and $(0,2)$ for $y$.I have graphed these regions but I have no intuition on how to divide it. Any help would be appreciated. Thanks.

• Your PDF can't be right: When X is near -2 and Y is near 0, the sum can be negative. Your PDF makes no provision for negative values. In fact, the probability of a negative sum is 1/4. – BruceET Dec 11 '16 at 8:58

The joint distribution of $(X,Y)$ is uniform on a rectangle with corners at $(-2,0)$ and $(2,2),$ and with area 8. So just by geometry, you should be able to find the CDF of $S = X + Y.$ For example, draw the rectangle and the line $x + y = 1.5.$ Then what is the value of $F_S(s) = P(S \le s = 1.5)?$ (Consider three cases: $s < 0,\, 0 < s < 2,\, s > 2.$)

Here is a simulation in R statistical software of the distribution of $S$ based on a million realizations. The histogram suggests the shape of the PDF and the ECDF (empirical CDF) suggests the shape of the CDF. In one dimension, itegrate the CDF over three separate regions to get the (piecewise) PDF. (The CDF is linear between 0 and 2.)

m = 10^6
x = runif(m, 0, 2);  y = runif(m, -2, 2)
s = x + y
mean(s)
## 0.9980456  # aprx E(S) = 1

# plots
par(mfrow=c(1,2))  # 2 panels per figure
hist(s, prob=T, col="wheat", main="Simulated Distribution of S = X + Y")
plot(ecdf(s)); abline(v=c(0,2), col="green")
par(mfrow=c(1,1))  # returns to default single-panel plotting


• Since $F_z(z)$ gives the probability to the left of $z$, doing what you suggested I got that $F_Z(z)= \frac{z+1}{4}$ for $z<0$, $\frac{z}{4}$ for $0<z<2$, and $\frac{z-2}{4}$ for $z>2$. Assuming that I did this correctly, then $f_Z(z)$ is just the derivative of $F_Z(z)$. I think I got it. My only concern is whether or not I got the correct cdf. Thanks! – An P. Dec 11 '16 at 10:03
• Suggest you plot your CDF and compare with my ECDF. I would have expected quadratic functions to the left of 0 and to the right of 2. – BruceET Dec 11 '16 at 10:38