Mean and Variance of a distribution from other distributions.

Let X have mean μx and variance σ, Let Y have mean μy and variance σ.Let Z = X with probability p and Z- Y with probability 1 -p. What are E[Z] and Var[Z]?

This is a homework problem of mine and I don't know how to solve it. Any help would be appreciated.

The best thing to do here would be to use the tower property for mean and variance.

I.e, call $$B$$ the random variable which takes value $$1$$ with probability $$p$$, and value $$0$$ with probability $$1-p$$.

Now, $$\mathbb{E}[Z|B = 1] = \mu x$$

$$\mathbb{E}[Z|B = 0] = \mu y$$.

To find $$\mathbb{E}[Z]$$ we do $$\mathbb{E}[Z] = \mathbb{E}[\mathbb{E}[Z|B]]$$.

A similar formula exists for the variance: $$Var (Z)=\mathbb{E} [Var (Z|B)]+Var (\mathbb{E} [Z| B]))$$

Let me know if you need any more help.