I have three random real numbers from uniform distribution $[0,1]$, and also a constant $r\in [0,1]$. Supposed the three random numbers are sorted afterwards and denoted $a<b<c$.
I want to calculate the expected value of the following rule: if $r<a$, then result is $r+c-b-a$; if $a<r<c$, then result is $b+r-a-c$; if $r>c$, then result is $r+a-b-c$.
I have figured out the pdf of $a,b,c$, which is $3(1-p)^2,6p(1-p),3p^2$, and the expected values of those are $1/4,1/2,3/4$. However I cannot get the correct answer when putting these and different cases involving $r$.
Indeed, you cannot get the correct answer that way. The variables are not independent.
The joint probability density function is: $\mathsf p_{a,b,c}(x,y,z)=3!~\mathbf 1_{0\leqslant x\lt y\lt z\leqslant 1}$
Use that.