How would I find the distributional characteristics (mean, variance) of the following scenario:
A Bernoulli random variable $X \sim B(1,p)$.
If the $X = 1$, then $Y \sim N(\mu_1, \sigma_1^2)$.
If the $X = 0$, then $Y \sim N(\mu_0, \sigma_0^2)$.
One random variable is conditional on another. I know the mean of this scenario is $p \mu_1 +(1-p) \mu_0$, but what is the variance?
Thank you so much.
edit -- based on further research, this is what I have come up with:
$Y | X=1 \sim N(\mu_1, \sigma_1^2)$
$Y | X=0 \sim N(\mu_0, \sigma_0^2)$
$E(Y) = E(E(Y|X)) = p \times E(Y|X=1) + (1-p) \times E(Y|X=0) = p \mu_1 + (1-p) \mu_0$
And,
$Var(Y) = E(V(Y|X)) +V(E(Y|X))$
$E(V(Y|X)) = p \sigma_1^2 + (1-p) \sigma_0^2$
$V(E(Y|X)) = E(E(Y|X)^2) - E(E(Y|X))^2 =E(E(Y|X)^2) - E(Y)^2$
$ = p \mu_1^2 + (1-p) \mu_0^2 - (p \mu_1 + (1-p) \mu_0)^2$
$ = p(1-p) \mu_1^2 + p(1-p) \mu_0^2 - 2p(1-p) \mu_1 \mu_0 $
Hopefully this is correct?
I was fooled by randomness after running a quick computer simulation and getting an extremely close result to what I posted as a comment, i.e. $\require{enclose}\enclose{horizontalstrike}{{\color{red}{\mathrm{Var}(Y)=\sigma_1^2\times p + \sigma_0^2 \times (1-p)}}}.$ @Just_to_Answer pointed out the fact that this was incorrect since the problem was asking for the variance of a mixture distribution - a mistake I confirmed by simply changing the computer simulation to different parameters.
There is nothing I can add to the post on the topic by @whuber here, and you can credit him appropriately. So you can take this as an extended comment.
The variance does indeed contain the formula above, plus a factor that accounts for the dispersion of the means:
$$\mathrm{Var}(Y) =\color{red}{ \sigma_1^2 \times p + \sigma_0^2\times (1-p)}\color{black}{+\Big[ \mu_1^2\times p +\mu_0^2\times (1-p) - \big(\mu_1 \times p + \mu_o \times(1-p) \big)^2\Big]}$$
And since making the same mistake twice is so human, I ran a simulation again (this time with different settings) to "confirm" the correct equation: