PDF of probabilistic sum of Random variables.

Let's say that $X \sim \operatorname{U}[0,1]$ and $Y \sim \operatorname{U}[0, 2].$

So $f_X(x) = 1$ and $f_Y(y) = 0.5$ and $F_X(x) = x$ and $F_Y(y) = y/2$.

If $Z$ is distributed with $X$ half the time, and $Y$ half the time is the $\operatorname{pdf}(Z) = f_Z(z) = (1/2)(1) + (1/2)(1/2) = 3/4$?

I believe, but I'm not sure, that this works for uniform random variables, but does this method to find the $\operatorname{pdf}(z)$ also work for any random variables?

• There is a reason why in the expression $f_X(x),$ the subscript $X$ is capital and the argument $x$ is in lower case. The capital $X$ refers to the random variable. This makes it possible to understand the difference between $f_X(0.7)$ and $f_Y(0.7)$ and the meaning of expressions like $\Pr(X\le x)$ and other things. I edited accordingly. – Michael Hardy Dec 10 '17 at 22:14

Note that $f_X(x) =1$ if $0<x<1,$ but $f_X(1.2) = 0 \ne 1,$ whereas $f_Y(1.2) = 1/2 \ne 0,$ and $f_Y(2.2) = 0,$ etc.
Now suppose $A$ is some subset of the interval $[0,2].$ Suppose $Z=X$ or $Z=Y$ each with probability $1/2$, and that choise is independent of the values of $X$ and $Y.$ (Your question doesn't mention independence.) Then \begin{align} \int_A f_Z(z)\,dz & = \Pr(Z\in A) \\[10pt] & = \Pr(Z\in A\mid Z=X) \Pr(Z=X) + \Pr(Z\in A \mid Z=Y)\Pr(Z=Y) \\[10pt] & = \frac 1 2 \cdot \Pr(X\in A) + \frac 1 2 \cdot\Pr(Y\in A) \\[10pt] & = \int_A \left( \frac 1 2 f_X(w) + \frac 1 2 f_Y(w) \right) \, dw. \\[10pt] \text{Therefore } & f_Z(z) = \frac 1 2 f_X(z) + \frac 1 2 f_Y(z) = \begin{cases} 3/4 & \text{if } 0<z<1 \\ 1/4 & \text{if } 1<z<2 \\ 0 & \text{if }z>2 \text{ or } z<0. \end{cases} \end{align}
The name for such a "probabilistic sum" is "mixture". Yes: if $Z$ is $X$ with probability $p$ and $Z$ is $Y$ with probability $1-p$ then the probability density function of $Z$ is the corresponding weighted average of the pdfs of $X$ and $Y$, namely $f_Z = pf_X+(1-p)f_Y$. Similarly for the cumulative distribution functions, moment generating functions, and characteristic functions, and also similarly for the central moments.