Given that $X$ and $Y$ are two independent univariate random variables sampled uniformly from the unit interval [0,1]. I am trying to find the expected value and the variance of the random variable $Z = \mid X - Y \mid ^2 $ (the squared distance between $X$ and $Y$.
So far, I'm assuming that $X$ and $Y$ are uniformly distributed and this is what I have: \begin{align} Z &= \mid X - Y\mid ^2 \\ Z &= \mid X^2 - 2XY + Y^2 \mid \\ E[Z] &= \mid E[X^2] - 2E[XY] + E[Y^2]\mid \\ &= \mid E[X^2] - 2E[X]E[Y] + E[Y^2]\mid \\ &= \frac{1}{3}\frac{1}{b-a}(b^3-a^3)-2(\frac{a+b}{2})(\frac{a+b}{2})+\frac{1}{3}\frac{1}{b-a}(b^3-a^3) \end{align}
But I am not sure if this is the right approach or the right direction and what is E[Z] = $\mid X - Y\mid ^2$. If so, can I do something similar to the variance?
If I substitute 0 and 1 for a and b respectively to:
\begin{align} &= \frac{1}{3}\frac{1}{b-a}(b^3-a^3)-2(\frac{a+b}{2})(\frac{a+b}{2})+\frac{1}{3}\frac{1}{b-a}(b^3-a^3) \\ &=\frac{1}{6} \end{align}
Would the answer (the expected value of Z) be $\frac{1}{6}$?