# Expectation of Mixed Random Variable (Contradiction with Manual Solution)

$$X \sim \mathcal{N}(1,\text{negligible variance})$$ and $$Y \sim \mathcal{N}(2,\text{negligible variance})$$

$$\begin{equation*} Z= \begin{cases} X, & \ \text{w/pr}\quad p\\ Y, & \ \text{w/pr}\quad 1-p \\ \end{cases} \end{equation*}$$

What is the $$\mathrm{E}[Z]$$?

$$\underline{\text{Solution}}$$

\begin{align*} \mathrm{E}[Z]&=p \times \mathrm{E}[X] +(1-p)\times \mathrm{E}[Y] \\ \mathrm{E}[Z]&=p \times 1+(1-p) \times 2 \\ \mathrm{E}[Z]&=p+2-2p \\ \mathrm{E}[Z]&=2-p \end{align*}

I have also used the transform method to prove the same answer. But the manual states that

"Take $$X$$ and $$Y$$ to be normal with means $$1$$ and $$2$$ respectively, and very small variances. Consider the random variable that takes the value of $$X$$ with some probability $$p$$ and the value of $$Y$$ with probability $$1-p$$. This random variable takes values near $$1$$ and $$2$$ with high probability, but takes values near its mean (which is $$3-2p$$) with relatively low probaility. Thus, this variable is not normal."

I can understand all other things but how he/she is saying mean is $$3-2p$$? Kindly someone guide, who is right and who is wrong?

tl;dnr version: The OP's final answer $$E[Z] = 2-p$$ is correct but the reasoning is not. The book's statement that $$Z$$ does not have a normal density is correct, but its mean computation incorrect (perhaps a typo).

As Chris Haug says, the OP's first statement (which the OP has deleted a few minutes ago) is incorrect. It is not true that $$Z = pX + (1-p)Y$$ regardless of whether $$X$$ and $$Y$$ are normal or not or independent or not. What is true is that $$Z$$ has what is called a mixture distribution. With $$F$$ denoting CDFs, the law of total probability says that

\begin{align}F_Z(\alpha) &\stackrel{\Delta}{=} P(Z\leq\alpha)\\&= pP(X\leq \alpha)+(1-p)P(Y\leq \alpha)\\&= pF_X(\alpha)+(1-p)F_Y(\alpha)\tag{1} \end{align}

and so, if $$X$$ and $$Y$$ are continuous random variables with density functions $$f_X$$ and $$f_Y$$ respectively, then $$Z$$ is also a continuous random variable with density function $$f_Z(\alpha) = pf_X(\alpha)+(1-p)f_Y(\alpha).\tag{2}$$ From $$(2)$$, it follows that \begin{align}E[Z] &= \int_{-\infty}^\infty \alpha f_Z(\alpha) \,\mathrm d\alpha\\ &= p \int_{-\infty}^\infty \alpha f_X(\alpha) \,\mathrm d\alpha + (1-p)\int_{-\infty}^\infty \alpha f_Y(\alpha) \,\mathrm d\alpha\\ &= pE[X] + (1-p)E[Y], \end{align} which for the OP's case works out to be $$2-p$$ as he computed. The OP's book's claim that $$Z$$ does not have a normal density even though $$X$$ and $$Y$$ have normal densities with different means is correct (as should be obvious from $$(2)$$ also) but the reasoning in support of this claim is dubious to say the least.

• What is dubious about the reasoning? No Normal density can behave in the way described in the quotation.
– whuber
Jun 20 '20 at 21:42

The very first line of your derivation is not correct (that's not the correct expression for the mixture $$Z$$). To illustrate, if $$X$$ and $$Y$$ are independent and if $$p=0.7$$, this is what these densities look like: Note that the mixture $$Z$$ is bimodal, but $$pX + (1-p)Y$$ is actually a linear combination of independent normal variables, and is also normal.

However, what follows after that is indeed true: the mean is $$2-p$$, not $$3-2p$$.

The easiest way to see that $$3-2p$$ is incorrect is to plug in $$p=0$$, in which case $$Z=Y$$ and so the mean must be 2, but the manual's answer says 3. Perhaps in a previous version of the problem, $$Y$$ had mean 3.

• Nowhere in the problem statement does it say that $X$ and $Y$ are independent. Jun 20 '20 at 19:58
• @DilipSarwate That's correct, which is why I explicitly made that additional assumption in order to produce that illustration (it also doesn't say that $p=0.7$, but I had to pick something). The rest of what I said doesn't hinge on that assumption. Jun 20 '20 at 20:19
• You don't need the assumption that $X$ and $Y$ are independent: the result that the density of $Z$ is a mixture of the densities of $X$ and $Y$ holds even when $X$ and $Y$ are dependent random variables and even when $Y=X+1$ (say). The variance does not need to be negligible either; it could even be infinite as with Cauchy random variables. Jun 20 '20 at 20:37
• @DilipSarwate I am fully aware of that, as I just said. I wanted to show a visual representation of why that line was wrong, and that requires actually fixing a specific joint distribution to be able to draw it. Besides, a specific counterexample is legitimate proof that the statement is false, the fact that it doesn't need to be this specific example is completely irrelevant. Jun 20 '20 at 21:41