# Expected Value of a Continuous Random Variable (Example from Sheldon Ross's Book)

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.

• I get $p(1-p)+\frac12$, is that the right answer?
– bof
Apr 13 '15 at 6:16
• Yes can you please explain how you got this? Apr 13 '15 at 6:18
• By definition of $U$ being uniformly distributed, the answer is $$\int_0^p(1-u)du+\int_p^1udu=\tfrac12+p-p^2.$$ If $U$ has density $f_U$ on $(0,1)$, consider $$\int_0^p(1-u)f_U(u)du+\int_p^1uf_U(u)du.$$
– Did
Apr 13 '15 at 6:37
• I understood your solution but how have you taken the function value to be 1 in both cases? Apr 13 '15 at 6:39
• Which function value? $f_U$? This is the definition of being uniformly distributed on $(0,1)$, no?
– Did
Apr 13 '15 at 6:39

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?

• In the book they've found the probability density formula and then calculated the expected value from there. Also in the method you've used may be correct but I don't know what condition expectation is. Apr 13 '15 at 6:37
• Conditioning is not needed (and might be seen as an unnecessary complication).
– Did
Apr 13 '15 at 6:38
• @Did Right, your solution is much better.
– bof
Apr 13 '15 at 6:42