# Expected length of a stick broken into two pieces — explaining the length function and PDF

We break a unit length rod into two pieces at a uniformly chosen point. Find the expected length of the smaller piece

In one of the answers, the following reasoning is provided to begin with:

The length function is $f(x)=min(x,1−x)$ as you found. This is $x$ on the interval $[0,0.5]$ and $1−x$ on the interval $[0.5,1]$

Since the length of the stick is $x$, shouldn't we have $E(X) =\int_{x=0}^1 x f(x)dx = \int_{x=0}^1 x^2 dx = \frac{1}{3}$ ? Intuitively, that does not make sense but I would like to know what is amiss.

Why do we have the length function defined as $f(x)=min(x,1−x)$ and why is it $x$ on the interval $[0,0.5]$ and $1−x$ on the interval $[0.5,1]$ ?

• You seem to confuse $f$ with the PDF of some random variable $X$, but $f(x)$ is simply the length of the smaller piece when one breaks the rod at point $x$. – Did Mar 24 '14 at 12:58
• The notation used in the other answer can be a bit confusing since $f(x)$ is commonly used to denote the probability density function (pdf) of a random variable. Write the length function as $g(x) = \min(x,1-x)$ instead and then use LOTUS to write $$E[g(X)] = \int_{-\infty}^\infty g(x)\cdot f_X(x)\,\mathrm dx = \int_0^1 g(x)\cdot 1\,\mathrm dx = \int_0^{0.5}x\,\mathrm dx + \int_{0.5}^1 1-x\,\mathrm dx = \frac{1}{4}$$ or notice that the area of the triangular shape of $g(x)$ is $\frac{1}{4}$ via formulas remembered from school instead of working out the integrals in detail. – Dilip Sarwate Mar 24 '14 at 13:01
• @DilipSarwate Why is the length $min(x,1-x)$ instead of just $x$ ? – curryage Mar 24 '14 at 13:05
• OK, let us start from basics. The stick is broken at a random point $X$ where $0 < X < 1$. The left-hand piece is of length $X$ and the right-hand piece is of length $(1-X)$? Which piece is shorter? Don't answer before looking at what you are holding in your hands first. If you do so, you will realize that the shorter piece is in your left hand (and is thus of length $X$) if and only if $X < \frac{1}{2}$; otherwise the shorter piece is in your right hand and has length $(1-X)$ (and, of course, $X >\frac{1}{2}$ in this case). Thus, $g(X)$, the length of the shorter piece, is $\min(X,1-X)$. – Dilip Sarwate Mar 24 '14 at 13:24
• @DilipSarwate Lovely explanation ! Your students were fortunate to get you as their instructor. – curryage Mar 24 '14 at 13:46