# Combining discrete and continuous variables

I need to find the pdf of a random variable which is a mixture of discrete and continuous random variables. I have seen on this website but it does not exist in the general case, but maybe in this one it does.

In any case, I have $X \sim Bern(p)$ where $p$ is known, and I have $Y = XW+(1-X)Z$ where $W,Z$ are both continuous with pdf also known. For the moment, I've tried to \begin{align*} \text{cdf}_Y (y) & = P( Y \leq y) = P( XW+(1-X)Z \leq y) \\ & = P( ... \leq y \mid X=0 ) + P( ... \leq y \mid X =1) \\ & = \text{cdf}_W(y) + \text{cdf}_Z(y) \end{align*} I am just not sure I am allowed to go from the first line to the second...is this correct ? Does anyone have any suggestion on this problem ?

Thank you very much !

• Is this for some subject? Note that your first, second, and third lines are all wrong in some way. The first line is missing a $Z$, the second is missing a term out in front of each $P$ and the third is plainly wrong without even trying to think about the problem, since the sum of two cdfs can't itself be a cdf. – Glen_b Oct 27 '13 at 23:08
• There's some information here en.wikipedia.org/wiki/… – Glen_b Oct 27 '13 at 23:16
• Thanks Glen for the constructive comment. This actually isn't homework. As for the mistakes above, I apologise for those due to not proofreading myself (ligns 1 and 2) and the third one is just my ignorance. – user62423 Oct 28 '13 at 13:06
• The third line you should be able to reject from knowing nothing more than: cdfs are monotonic nondecreasing, and must approach 0 at the left and 1 at the right. (From which you should see that eventually the sum of two cdfs with the same argument must exceed 1 and so cannot be a cdf.) If not for some subject, how did such a question arise? – Glen_b Oct 28 '13 at 21:39
• I do not understand why you are being aggressive here. 1) If I did not have anything to learn I would not post here, 2) it can be "for some subject " without being homework (ie not being assigned/marked/looked at by anyone). I do understand now that the third line is easily seen to be wrong, thanks for the explanation. – user62423 Oct 30 '13 at 10:47

$P( Y \leq y)$
$= P( Y \leq y|X=1)P(X=1) + P( Y \leq y|X=0)P(X=0)$
$=P( Y \leq y|X=1)p + P( Y \leq y|X=0)(1-p)$
$=pP( W\leq y) + (1-p)P( Z \leq y)$
So $F_Y(y)=pF_W(y)+(1-p)F_Z(y)$ and thus $f_Y(y)=pf_W(y)+(1-p)f_Z(y)$