# Convolution, sum of two independent random variables $X+Y$

Let $$f_{(X,Y)}(x,y) = 2x$$ for $$x \in (0,1), y \in (0,1)$$. I need to compute density of $$X+Y$$. So, I know that $$X \perp Y$$, because \begin{align} f_X(x) &= 2x, \ \ x\in(0,1)\\ f_Y(x) &= 1, \ \ \ \ y \in (0,1) \end{align} thus $$f_{(X,Y)}(x,y) = f_X(x)f_Y(y)$$.

Let $$Z=X+Y$$ and $$z\in(0,2)$$, then $$f_Z(z) = \int\limits_{-\infty}^{+\infty}f_Y(y)f_X(z-y)dy$$ Then, for $$z\in(0,1)$$ I need $$z-y\geq 0$$, so $$z \geq y$$ $$f_Z(z) = \int\limits_{0}^{z}1\cdot2(z-y)dy = 2z^2-z^2 = z^2$$ And for $$z\in(1,2)$$ inequality $$z \geq y$$ holds, but $$z-y \leq 1$$ $$f_Z(z) = \int\limits_{z-1}^{1}1\cdot2(z-y)dy = 2z-z^2$$ Thus $$f_Z(z) = \begin{cases} z^2, \ \ \ \ \ \ \ \ \ \ z \in (0,1)\\ 2z-z^2, \ \ \ z \in (1,2)\\ 0, \ \ \ \ \ \ \ \ \ \ \ \ \text{elsewhere} \end{cases}$$ Am I correct?

• This seems correct to me. Dec 7, 2022 at 19:15

$$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{{\displaystyle #1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\on}[1]{\operatorname{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\sr}[2]{\,\,\,\stackrel{{#1}}{{#2}}\,\,\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$$ Hereafter, $$\ds{\bracks{\cdots}}$$ is an Iverson's Bracket. The $$\ds{\underline{answer}}$$ is given by \begin{align} & \color{#44f}{\int_{0}^{1}2x\bracks{0 < z - x < 1}\dd x} = 2\int_{0}^{1}x\bracks{z - 1 < x < z}\dd x \\[5mm] = & \ 2\bracks{0 < z < 1}\int_{0}^{z}x\,\dd x\quad +\quad 2\bracks{0 < z - 1 < 1}\int_{z - 1}^{1}x\,\dd x \\[5mm] = & \ \bracks{0 < z < 1}z^{2}\quad +\quad \bracks{1 < z < 2}\pars{2z - z^{2}} \\[5mm] = & \ \bbx{\color{#44f}{ \color{black}{=} \left\{\begin{array}{lcl} \ds{0} & \mbox{if} & \ds{z \leq 0\ \mbox{or}\ z \geq 2} \\[2mm] \ds{z^{2}} & \mbox{if} & \ds{0 < z \leq 1} \\[2mm] \ds{2z - z^{2}} & \mbox{if} & \ds{1 < z < 2} \end{array}\right.}} \\[5mm] & \ \pars{~z = 0, 1, 2~}\mbox{-results}\ \mbox{are found as}\ limiting\ cases\ \mbox{in this approach.} \end{align}

I think you are correct. An alternate proof (with many steps omitted for concision) to sanity check: \begin{align} f_Z(z)&=\int_0^1f_Y(z-x)f_X(x)dx\tag{1} \end{align} For $$0\leq z \leq1$$, $$f_Z(z)=\int_{0}^{z}2xdx=z^2\tag{2}.$$ For $$1, $$f_Z(z)=\int_{z-1}^{1}2xdx=2z-z^2\tag{3}.$$ As such, f_Z(z)=\left\{ \begin{aligned} z^2 &\ \ \ \text{ for }0\leq z \leq 1,\\ 2z-z^2&\ \ \ \text{ for }1 < z \leq 2,\\ 0 &\ \ \ \text{ otherwise. } \end{aligned} \right.