How to find the variance of random variable that randomly equals one of two other random variables?

65 Views Asked by At

Say we have two random variables $X$ and $Y$ and a third random variable $Z$ which has probability $p_X$ of being $X$ and $p_Y=1-p_X$ probability of being $Y$. Then can we write the variance of $Z$ in terms of the variances of $X$ and $Y$?

2

There are 2 best solutions below

1
On

I think this can get you started. Notice that you can write $$Z = BX + (1-B)Y$$ where $B \sim \operatorname{Bernoulli}(p_X).$ With this, the variance can be written as \begin{align}\operatorname{Var}(Z) &= \operatorname{Var}(BX + (1-B)Y)\\[0.5em] & = \operatorname{Var}(BX) +\operatorname{Var}((1-B)Y) + 2 \operatorname{Cov}(BX,(1-B)Y). \end{align} This expression could be further reduced by applying the appropriate variance/covariance properties. Notice that $B$ is independent to both $X$ and $Y$. (However, $X$ and $Y$ are not necessarily independent.)

0
On

As @Bergson suggests, you should model $Z$ as depending on a Bernoulli variable $B$ that selects between $X$ and $Y$: $$ Z = BX + (1-B)Y. $$ Then the easiest way to get to a result is to use the law of total variance directly on $Z$: $$ \mathrm{Var}(Z)= \mathrm{Var}(\mathrm{E}[Z\mid B]) + \mathrm{E}(\mathrm{Var}[Z\mid B]). $$ Plug in the conditional expectation and variance of $Z$ given $B$: $$ \begin{aligned} \mathrm{E}[Z\mid B] &= \mu_X B + \mu_Y(1-B) \\ \mathrm{Var}[Z\mid B] &= B\sigma^2_X + (1-B)\sigma^2_Y, \end{aligned} $$ where $\mu_X=\mathrm{E} X$ and $\sigma^2_X = \mathrm{Var}X$ etc.
Then you get the result $$ \mathrm{Var} [Z] = p_X \sigma^2_X + p_Y \sigma^2_Y + p_X p_Y(\mu_X-\mu_Y)^2. $$

To derive these expressions, note that the Bernoulli variable $B$ can either take value $B=0$ or $1-B=0$ and that $$\begin{aligned} \mathrm{E}[Z\mid B]&=\begin{cases}1\cdot\mu_X+0\cdot\mu_Y,&B=1,\\ 0\cdot\mu_X+1\cdot\mu_Y,&B=0\end{cases} \\& = B\cdot\mu_X + (1-B)\cdot\mu_Y, \end{aligned}$$ and $$\begin{aligned} \mathrm{Var}[Z\mid B]&=\begin{cases}1^2\cdot\sigma^2_X+0^2\cdot\sigma^2_Y,&B=1,\\ 0^2\cdot\sigma^2_X+1^2\cdot\sigma^2_Y,&B=0\end{cases} \\& = B\cdot\sigma^2_X + (1-B)\cdot\sigma^2_Y. \end{aligned}$$ To find $\mathrm{Var}(\mathrm{E}[Z\mid B])$ you can regroup $\mathrm{E}[Z\mid B]$ such that becomes a constant times $B$ plus another constant: $$ \begin{aligned} \mathrm{Var}(\mathrm{E}[Z\mid B])&=\mathrm{Var}[(\mu_X-\mu_Y)B +\mu_Y] \\&=(\mu_X-\mu_Y)^2\mathrm{Var}(B). \end{aligned} $$