# Sum of two independent non-identical uniform random variables

Let's say we have two independent random variables, $X$ is uniform on $[0,1/2]$ and $Y$ is uniform on $[1/2,1]$. If we look at the distribution of $X+Y$, is it triangular distribution between $[1/2,3/2]$ where the peak is $1$?

I used to same logic as in the calculation of two identical uniform random variables but my calculations give a different result. If p.d.f. of $X$ and $Y$ is $f$ and $g$, respectively, \begin{align} f_{X+Y}(z)=\int_{-\infty}^{\infty} f(z-y)g(y)dy \end{align}

If $y\leq 1/2$ or $y\geq 1$, $g(y)=0$. So, \begin{align} f_{X+Y}(z)&=\int_{1/2}^{1} f(z-y)2 dy\\ \end{align}

If $0\leq z \leq 1/2$ or $z\geq 3/2$, $f(z-y)=0$.

If $1/2\leq z \leq 1$, $f(z-y)=1$ if $1/2 \leq y \leq z$. Then, \begin{align} f_{X+Y}(z)&=\int_{1/2}^{1} f(z-y)2 dy\\ &=\int_{1/2}^{z} 2*2 dy\\ &=4z-2 \end{align}

If $1/2\leq z \leq 3/2$, $f(z-y)=1$ if $z-1 \leq y\leq 1$. \begin{align} f_{X+Y}(z)&=\int_{z-1}^{1} f(z-y)2 dy\\ &=\int_{z-1}^{1} 2*2 dy\\ &=8-4z \end{align}

Could you tell me if my calculations are correct? If they are, I still feel like the result should be triangular ad I cannot see why not.

-

The first integral is correct; the second is incorrect. You should write that if $1 < z \le \tfrac{3}{2}$, then $f(z-y) = 2$ if $z - \tfrac{1}{2} \le y \le 1$. This gives the correct density $f_{X+Y}(z) = 6-4z$ over $1 < z \le \tfrac{3}{2}$.
A simpler way to do this calculation is to observe that $X^* = Y - \tfrac{1}{2} \sim {\rm Uniform}(0,\tfrac{1}{2})$, so the distribution of $X+Y$ is equal to the distribution of $X + X^* + \frac{1}{2}$, where $X$ and $X^*$ are IID.