Variance of a combination of two uniform distribution Suppose a variable $X$ is uniformly distributed over (1,5) with probability 0.9 and is uniformly distributed over (2,44) with probability 0.1, what would be the variance of $X$? 
I guess it would be something more than just a weighted sum of the variance of unif(1,5) and unif(2,44), but I have no idea how to solve it.
Thanks!
 A: Let $Y \sim \operatorname{Bernoulli}(p = 0.1)$.  Then note $$\operatorname{E}[X \mid Y = 0] = \frac{1+5}{2} = 3, \\ \operatorname{E}[X \mid Y = 1] = \frac{2+44}{2} = 23.$$  Similarly, $$\operatorname{Var}[X \mid Y = 0] = \frac{(5-1)^2}{12} = \frac{4}{3}, \\ \operatorname{Var}[X \mid Y = 1] = 147.$$  We in turn can write these as $$\operatorname{E}[X \mid Y] = 3 + 20Y,$$ and $$\operatorname{Var}[X \mid Y] = \frac{4}{3} + \frac{437}{3}Y.$$
Hence
$$\begin{align*}
\operatorname{Var}[X] 
&= \operatorname{Var}[\operatorname{E}[X \mid Y]] + \operatorname{E}[\operatorname{Var}[X \mid Y]] \\
&= \operatorname{Var}[3 + 20Y] + \frac{1}{3}\operatorname{E}[4+437Y] \\
&= 400\operatorname{Var}[Y] + \frac{1}{3}(4 + 437 \operatorname{E}[Y]) \\
&= 400(0.1)(0.9) + \frac{1}{3}(4 + 437(0.1)) \\
&= \frac{519}{10}. \end{align*}$$
Alternatively, we can perform the computation directly by expressing the unconditional density of $X$ as $$f_X(x) = \begin{cases}\frac{9}{40}, & x \in [1,2) \\
\frac{191}{840}, & x \in [2, 5) \\
\frac{1}{420}, & x \in [5,44] \end{cases}$$ and performing the integration $$\operatorname{E}[X^k] = \int_{x=1}^{44} x^k f_X(x) \, dx,$$ for $k \in \{1, 2\}$ and then using the usual variance formula to compute the variance.
