I am trying to understand an example from my textbook.

Let’s say Z=X+Y, where X and Y are independent uniform random variables with range [0,1]. Then the PDF

is

f(z)={zfor 0<z<12−zfor 1≤z<20otherwise.How was this PDF obtained?

Thanks

**Answer**

If we want to use a *convolution*, let fX be the full density function ofX, and let fY be the full density function of Y. Let Z=X+Y. Then

fZ(z)=∫∞−∞fX(x)fY(z−x)dx.

Now let us apply this general formula to our particular case. We will have fZ(z)=0 for z<0, and also for z≥2. Now we deal with the interval from 0 to 2. It is useful to break this down into two cases (i) 0<z≤1 and (ii) 1<z<2.

**(i)** The product fX(x)fY(z−x) is 1 in some places, and 0 elsewhere. We want to make sure we avoid calling it 1 when it is 0. In order to have fY(z−x)=1, we need z−x≥0, that is, x≤z. So for (i), we will be integrating from x=0 to x=z. And easily

∫z01dx=z.

Thus fZ(z)=z for 0<z≤1.

**(ii)** Suppose that 1<z<2. In order to have fY(z−x) to be 1, we need z−x≤1, that is, we need x≥z−1. So for (ii) we integrate from z−1 to 1. And easily

∫1z−11dx=2−z.

Thus fZ(z)=2−z for 1<z<2.

**Another way:** (Sketch) We can go after the cdf FZ(z) of Z, and then differentiate. So we need to find Pr(Z≤z).

For a few **fixed** z values, draw the lines with equation x+y=z on an x-y axis plot. Draw the square S with corners (0,0), (1,0), (1,1), and (0,1).

Then Pr(Z≤z) is the area of the part S that is "below" the line x+y=z. That area can be calculated using basic geometry. For example, when z is 2, the whole square area is under the line so Pr=1. There is a switch in basic shape at z=1.

**Attribution***Source : Link , Question Author : Zhulu , Answer Author : ymzkala*