Mean and variance for a random variable on an interval union So I'm not quite sure how to approach this problem.
We have a uniformly distributed random variable $Y$ on the interval $[0,1]\cup[10,20]$
Now I need to determine $\mathbb{E}[Y]$ and $Var(Y)$
But I don't know how to work with the union of the given intervals $[0,1]\cup[10,20]$
But determining mean and variance just for one given interval $[0,1]$ is easy.
Mean: $\mathbb{E}[Y]=\frac{1}{2}(0+1)=\frac{1}{2}$
Variance: $Var(Y)=\frac{1}{12}(1-0)^2=\frac{1}{12}$
But how do I calculate mean and variance for an interval union? Is there a trick?
 A: Hint:
The probability density function of a uniform distribution is a positive constant within the interval $A = [0, 1] \cup [10, 20]$ and $0$ elsewhere; i.e.,
$$f(x) = \begin{cases}
k, & x \in A \\
0, & x \notin A\text{.}
\end{cases}$$
$f$ must satisfy 
$$\int_{-\infty}^{\infty}f(x)\text{ d}x  = 1\text{.}$$
Now observe 
$$\int_{-\infty}^{\infty}f(x)\text{ d}x = \int_{A}f(x)\text{ d}x + \int_{\text{not} A}f(x)\text{ d}x=\int_{A}k\text{ d}x +0=k\int_{A}\text{ d}x$$
The integral 
$$\int_{A}\text{ d}x=\int_{0}^{1}\text{ d}x + \int_{10}^{20}\text{ d}x\text{.}$$
This allows you to find $k$.
For the expected value $\mathbb{E}[X] = \mu$, proceed similarly to the above except integrate
$$\int_{-\infty}^{\infty}xf(x) \text{ d}x$$
For the variance, use the formula $\mathbb{E}[X^2] - \mu^2$; for $\mathbb{E}[X^2]$, integrate
$$\int_{-\infty}^{\infty}x^2f(x) \text{ d}x$$
A: First, what does it mean for the distribution of $Y$ to be uniform over the set $[0,1]\cup[10,20]$? It must mean that the density is as follows
$$f_Y(y)=\begin{cases}0 & \text{for } \; y \notin [0,1]\cup[10,20] \; ,\\ c & \text{for } \; y \in [0,1]\cup[10,20]\; .\end{cases}$$
The constant $c$ has to be chosen such that the probability for $Y$ to be somewhere between $-\infty$ and $+\infty$ is $1$. Therefore
$$\int_{-\infty}^{+\infty}f_Y(y)dy=\int_{0}^{1}c \;dy+\int_{10}^{20}c \;dy=1$$
This gives that $c=1/11$. 
Now, going back to the definition of the expectation, we have that
$$\mathbb{E}[Y]=\int_0^1\frac{x}{11}dx+\int_{10}^{20}\frac{x}{11}dx = \frac{1}{22}+\frac{20^2-10^2}{22}=\frac{301}{22} \; .$$
You can do something similar for the variance.
