= Solution
If $B$ and $U$ are <independent random variables>, conditioning on the <Bernoulli random variable> $B$ gives
$$
\boxed{M_Z(t)=(1-p)+pM_U(t)=1-p+p\frac{\sinh t}{t},}
$$
with the continuous value $M_Z(0)=1$. Indeed $Z=0$ when $B=0$, while the conditional <probability distribution> of $Z$ given $B=1$ is the original <uniform distribution>.
Under the literal assumptions alone, the <law of total expectation> gives only
$$
M_Z(t)=1-p+p\mathbb E[e^{tU}\mid B=1].
$$
This is not determined by $M_U$ and $p$. For an explicit counterexample, put $p=1/2$ and $B=\mathbf1_{\{U>0\}}$. Then $B$ has the required <Bernoulli distribution>, but
$$
M_Z(t)=\frac12+\frac12\int_0^1e^{tu}\,du=\frac12+\frac{e^t-1}{2t}\quad(t\ne0),
$$
which differs from the independent-case formula.
Back to article page