So the problem says: Inside interval [0,1] dot (a) is fixated.
Random variable X is uniformly distributed on interval [0,1].
What is the covariance moment between X and variable Y = |x-a| : distance from X to a. So this is the solution : https://i.stack.imgur.com/nG46X.jpg.
Now I understand E(x) of course, $\int_0^1 x* 1$ = 1/2. but what about E(y). why did we integrate (a - x)from 0 to a and then integrate (x - a) from a to 1. Can someone explain E(Y) to me please.
Thank you!
Note that
$$|x-a|=\begin{cases} x-a & x\geq a\\ a-x & x\leq a \end{cases},$$
so to compute the mean of $Y$, they use LOTUS and integrate piecewise:
$$E[|X-a|]=\int_0^1 |x-a|dx=\int_0^a (a-x) dx+\int_a^1 (x-a)dx.$$