TITLE: mixture distribution moment generating function
QUESTION [5 upvotes]: Let $X$ and $Y$ be independent random variables, with known moment generating
functions $M_X(t)$ and $M_Y (t)$ and $I$ be such that $P(I = 1) =
1 − P(I = 0) = p \in (0, 1)$. Compute the moment generating function
of the random variable $S = IX + (1−I)Y $.
I am given the hint that taking condition on I may help but still I have no idea how to compute. 
Any help would be appreciated.

REPLY [4 votes]: The idea is to use the double expectation theorem, that is 
$$
\DeclareMathOperator{\E}{\mathbb{E}}  
   \E X = \E \E X \mid Y
$$
and we use this with $I$ as the conditioning variable.
$$
    M_S(t) = \E e^{tS} = \E e^{t(IX+(1-I)Y)} \\
       = \E \left\{ \E e^{tIX +t(1-I)Y}\mid I \right\} \\
       =  p\E e^{tX+0} + (1-p)\E e^{tY+0} \\
       =  pM_X(t) + (1-p)M_Y(t)
$$
which, indeed, is simpler that the other answer (and correct).