# The difference of two i.i.d random variables by convolution

Let $X$ and $Y$ be i.i.d. and uniformly distributed random variables on $[1/2,1]$. Furthermore, we define $Z:=X-Y$ and want to calculate the pdf by convolution as follows:

$f_Z(z)=\int^{\infty}_{-\infty}f_X(x)f_Y(x-z)\mathrm{d}x$

First, note that $Z$ can take values from $-1/2\le z \le 1/2$ and $f_Y$ is zero outside $1/2\le x -z \le 1$. Thus we can write the convolution

$f_Z(z)=\int^{\infty}_{-\infty} 1/4 \chi_{[1/2,1]}\chi_{[1/2+z,z+1]}\mathrm{d}x$,

where $\chi$ is the indicator function (also denoted $\mathbb{1}$).

I now divide the interval of $z$ into $-1/2\le z\le 0$ and $0\le z \le 1/2$ and obtain

$f_Z(z)=\begin{cases} \int^1_{1/2+z}\frac{\mathrm{d}x}{4}=\frac{0,5-z}{4},& \ \ 0\le z \le 1/2 \\ \int^{z+1}_{1/2}\frac{\mathrm{d}x}{4}=\frac{0,5+z}{4},& \ \ -1/2\le z \le 0\end{cases}$

This density is wrong and I could not figure out the problem for hours.

• Are $X$ and $Y$ uniform on $[1/2,1]$? May 23 '17 at 12:59
• Yes, I forgot to add. May 23 '17 at 13:01
• The title should probably read 'difference of two iid variables' May 23 '17 at 13:03
• $\frac14$ should change into $4$. May 23 '17 at 13:21
• Your mistake is in $f_X,f_Y$, you divide by the length of the interval to get the density for the uniform distribution. Hence the $1/4$ in your calculation should be $4$ which gives the correct answer. May 23 '17 at 13:22

Let $X,Y$ be uniformly distributed on $[a,b]$. Then the pdf of $Z = X-Y$ is

$$p(z) = \int_\mathbb{R} dx\int_\mathbb{R} dy \ p(x) p(y) \ \delta(z-(x-y)) =$$ $$= \frac{1}{(b-a)^2} \int_\mathbb{R} dx \int_\mathbb{R} dy \ \mathbb{1}^x_{[a,b]} \mathbb{1}^y_{[a,b]} \delta(z-(x-y))=$$ $$= \frac{1}{(b-a)^2} \int_\mathbb{R} dx \int_\mathbb{R} dy \ \mathbb{1}^x_{[a,b]} \mathbb{1}^y_{[a,b]} \delta(y-(x-z))=$$ $$= \frac{1}{(b-a)^2} \int_\mathbb{R} dx \ \mathbb{1}^x_{[a,b]} \mathbb{1}^{x-z}_{[a,b]} =$$

The product of the two indicators is equivalent to the conditions:

$$a \leq x \leq b \quad \wedge \quad z+a\leq x \leq z+b.$$

For different values of $z$, these conditions can be reduced to a single inequality, for instance if $0 \leq z \leq b-a$, then the inequality $a+z \leq x$ is "stronger" than $a \leq x$, and the inequality $x \leq b+z$ is "weaker" than $x \leq b$. So for those values of $z$, you have the product of the indicators simplifying to:

$$\mathbb{1}^x_{[a,b]} \mathbb{1}^{x-z}_{[a,b]} = \mathbb{1}^x_{[a+z,b]}, \quad 0 \leq z \leq b-a.$$

Similarly, for another set of values of $z$ (negative $z$, but not too negative), you'll have a different total constraint, and if $z +a \geq b$ or $z+b \leq a$, the two indicators will be totally disjoint and give zero.

To help visualize this, you can draw a picture like this:

$$...---[--*---------]--*---...$$

where the square brackets denote the interval $[a,b]$, and the stars are $a+z$ and $b+z$ respectively.

In your solution you had the wrong numerical factor, $1/4$ instead of a $4$.