# PDF of sum of random variables (with uniform distribution)

How can I solve this:

Random variables $X,Y$ ~ Unif$(0, 1)$ are independent. Calculate the probability density function of sum $X + 3Y$.

I couldn't find a sum for uniformally distributed random variables. I assume I have to go straight to the PDF and solve it that way.

• Welcome to math.SE: since you are new, I wanted to let you know a few things about the site. In order to get the best possible answers, it is helpful if you say in what context you encountered the problem, and what your thoughts on it are; this will prevent people from telling you things you already know, and help them give their answers at the right level. – Theoretical Economist Apr 3 '18 at 5:55
• Also, for some basic information about writing math at this site see e.g. basic help on mathjax notation, mathjax tutorial and quick reference, main meta site math tutorial and equation editing how-to. – Theoretical Economist Apr 3 '18 at 5:56
• Look up pdf convolution. – J.G. Apr 3 '18 at 6:09
• An alternative is via the cumulative distribution function in several intervals such as $(-\infty,0], (0,1], (1,3], (3,4], (4,\infty)$ and then take the derivative – Henry Apr 3 '18 at 7:11

One way to avoid explicit convolution (although convolution is always involved, in the end), is to define $Z = 3Y \sim \text{Uniform}(0, 3)$, and look at the distribution of $(X, Z)$ in the $x$-$z$ plane: a uniformly distributed rectangle.

Within this rectangle, the bands of equal values of $X+Z$ correspond to diagonal stripes. The lengths of these stripes, where $X+Z =$ some value $w$, is proportional to the value of the PDF $f_{X+Z}(w)$. All you need to do, then, is to find the proportionality constant that makes it a PDF; that is, it must integrate to $1$.

Easy Understanding of Convolution The best way to understand convolution is given in the article in the link,using that

I am going to solve the above problem and hence you could follow the same for any similar problem such as this with not too much confusion.

$Z = X+ 3Y$ where X and Y are U(0,1).

I am going to define a new variable W where W is distributed according to U(0,3)

Thus $Z = X + 3Y = X+ W$ where X is U(0,1) and W is U(0,3).

Now I am going define the bounds

$t_{X_0} = 0$

$t_{X_1} = 1$

$t_{W_0} = 0$

$t_{W_1} = 3$

Thus $$f_Z(z) = 0, z \le t_{X_0}+t_{W_0} ,$$

$$f_Z(z) = \int_{max(t_{W_0}, t-t_{X_1})}^{min(t_{W_1}, t-t_{X_0})} f_W(w)f_X(z-w)dw, \text{ } t_{X_0}+t_{W_0} \le z \le t_{X_1}+t_{W_1},$$

$$f_Z(z) = 0, z \ge t_{X_1}+t_{W_1} ,$$

These translate to the following:

$$f_Z(z) = 0, z \le 0 ,$$

$$f_Z(z) = \int_{max(0, z-1)}^{min(3, z)} f_W(w)f_X(z-w)dw, \text{ } 0\le z \le 4,$$

$$f_Z(z) = 0, z \ge 4 ,$$

$f_W(w) = \frac{1}{3}$ as $W$ is $U(0,3)$.

$f_X(x) = 1$ as $X$ is $U(0,1)$,

The middle one needs to be split into three intervals, and they are a) $0\le z\le 1$, b) $1\le z\le 3$, and c) $3\le z\le 4$.

Thus

$f_Z(z) = \int_{0}^{z}\frac{1}{3}dw = \frac{z}{3}$, $0\le z\le 1$

$f_Z(z) = \int_{z-1}^{z}\frac{1}{3}dw = \frac{1}{3}$, $1\le z\le 3$

$f_Z(z) = \int_{z-1}^{3}\frac{1}{3}dw = \frac{4-z}{3}$, $3\le z\le 4$

Sanity check is to find if $\int_{0}^{4} f_Z(z) = 1$ which it is in this case and hence the solution.

Goodluck

• What is the motivation behind choosing the integral bounds via the min , max functions. – Alexander Cska Dec 20 '18 at 19:42

So we define $Z=X+3Y$ and the distribution is therefore

$P(Z) dZ = \int_0^1 dX \int_0^1 dY \delta(X+3Y-Z)$

where $\delta(X+3Y-Z)$ is the delta function that enforces the constraint $Z=X+3Y$. The double integral is effectively summing over all possible combinations of $X$ and $Y$ that produce a value of $X+3Y$ that equals $Z$.

We may be tempted to remove the delta function by simply setting $Y=(Z-X)/3$. But this is not enough to solve the problem as the finite ranges of $X,Y$ can limit the number of ways they can combine to produce a given $Z$. Note that the support of $Z$ is between $0$ and $4$.

As a result the distribution of $Z$ can depend on the value of $Z$, which may seem counterintuitive given that $X$ and $Y$ both have distributions that are uniform with a probability density that is independent of $X$ and $Y$. But it is not counterintuitive once you realise that the probability of $Z=4$ which requires $X=1$ and $Y=1$ must be less than the probability of $Z=2$ which can be created by an infinite number of combinations of values of $X$ and $Y$.

We need to consider each range of values separately:

If $1\le Z \le 3$ then $Y$ must go from $(Z-1)/3$ to $Z/3$. The length of the $Y$ range is independent of $Z$ and equals $1/3$. So in this range $P(Z) = 1/3$.

If $Z<1$ the $Y$ range is $[0,Z/3]$. So the length of the $Y$ range is $Z/3$. So $P(Z)=Z/3$.

If $Z>3$ the $Y$ range is $[(Z-1)/3,1]$ and so the length of the range is $(4-Z)/3$. So the probability density is $P(Z)=(4-Z)/3$.

So we have five ranges:

If $Z<0$, $P(Z)=0$

If $0 \le Z < 1$, $P(Z)=Z/3$

If $1 \le Z < 3$, $P(Z)=1/3$

If $3 \le Z < 4$, $P(Z)=(4-Z)/3$

If $Z \ge 4$, $P(Z)=0$

I have provided Python code below that simulates the random variable $Z$ and plots its distribution.