How can I find the expected value of a random variable, with finite outcomes, which depend on a continuous variable?
For example, I am interested in the expected value of the random variable $Z$, which can take two values:
$Z=2$ with probability $p$ and $Z=a$ with probability $1-p$, where $a$ is a continuous uniform random variable with expectation $\overline{a}$.
My intuition is that $E(Z)= 2p + (1-p)\overline{a}$. Is this correct? If so, how can one show it?
EDIT: In my specific case, $a$ has a uniform distribution.
By law of total expectation,
\begin{align}\mathbb{E}[Z] &= \mathbb{E}[Z|Z=2]Pr(Z=2) + \mathbb{E}[Z|Z=a]Pr(Z=a) \\ &=2p+\mathbb{E}[a](1-p)\\ &=2p+\bar{a}(1-p) \end{align}