When is the sum of two uniform random variables uniform? Suppose that $X$ and $Y$, two random variables, are both uniformly distributed over $[0,1]$. Let $Z=\frac{1}{2}X+\frac{1}{2}Y$.
I know that in general, $Z$ is not uniform. For instance, $Z$ is not uniform if $X$ and $Y$ are independent.
On the other hand, if $X=Y$, then $Z$ is uniformly distributed over $[0,1]$.
My question: Suppose $Z$ is uniformly distributed over $[0,1]$. Is $X=Y$? In other words, is $X=Y$ the only case where $Z$ is uniform over $[0,1]$?

The answer is YES.
We have $$
\begin{align*}
\frac 1 3 &=E[Z^{2}]
\\ &=\frac  1 4 E[(X+Y)^{2}]\\
 &=\frac  1 4(E[X^{2}]+E[Y^{2}]+2E[XY])\\
 &=\frac   1 4(\frac   1 3+\frac   1 3+2E[XY]).
\end{align*}$$  This gives $E[XY]=\frac   1 3$. This implies that we have equality in Cauchy-Schwarz inequality: $$E[XY]=\sqrt {E[X^{2}]}\sqrt {E[Y^{2}]}$$ and hence $X$ and $Y$ are constant multiples of each other. But  the constant factor has to be $1$ since $X$ and $Y$ have uniform distribution on $[0,1]$. Hence $X=Y$.
