Let $X$ be a random variable distributed uniformly on [0,20]. Define a new random variable $Z$ by $Z= [X+.5 ]$ (the greatest integer in $X$). Find the expected value of $Z$. Compute $E(|X-Z|)$.
Attempt:
I attempted to set up the integral $$\int_{0}^{20}\frac 1 {20}\,dx,$$ since I found out that it was uniformly distributed on $[0,1]$. Also, I thought the distribution function would be $\dfrac 1 {20}$. Then, I used the formula $E(|X-Z|)=E(X)-E(Z)$, I found out that $E(X)=10$, after doing the calculation, then I took the integral $$\int_{0}^{20}(X^2+.5X)dx,$$ but was unable to find the right answer.
Humor my whim and write $X=1/2 + k +\theta$, where $k$ is an integer and $\theta\in[0,1)$. Then $[X+1/2] = k+1$ and $X-[X+1/2] = \theta-1/2$. Now observe that the value of $X-[X+1/2]$ depends only on the fractional part of $X+1/2$. When $X$ ranges uniformly over $[0,20]$, the quantity $\theta$ ranges uniformly on $[0,1]$ and $X-[X+1/2]$ ranges uniformly over $[-1/2,1/2]$. Can you finish from there?