This is an example in the book (A First Course in Probability by Sheldon Ross).
A stick of length 1 is split at a point U that is uniformly distributed over $(0,1)$. Determine the expected length of the piece that contains the point $0 \leq p \leq 1 $.
The problem with this is I don't know how would I go about solving this. They have solved this in the book but I do not understand their solution.
For example I don't know how to setup the probability density formula and then to find the expected value from there.
Best Answer
Let $X$ be the length of the piece containing $p$.
Given that $U\gt p,$ then $X$ is uniformly distributed on $[p,1]$, so the conditional expectation is $\frac{p+1}2.$
Given that $U\lt p,$ then $X$ is uniformly distributed on $[1-p,1]$, so the conditional expectation is $\frac{(1-p)+1}2.$
So $$E(X)=P(U\gt p)\cdot\frac{p+1}2+P(U\lt p)\cdot\frac{(1-p)+1}2=(1-p)\cdot\frac{p+1}2+p\cdot\frac{(1-p)+1}2$$ which simplifies to $\frac12+p(1-p).$
I don't know if this is how you're supposed to do it, or if you're supposed to derive the probability distribution etc. Is my solution anything like the solution in the book?