# Calculate the expected distance that the boat travels.

Its a discrete probability question.

Imagine a boat and two banks on an integer line. One of the banks is at the origin and the other bank can be at any integer in range $[B+1,2B]$

If the right bank is at distance $d$ from the origin, then the boat can be at any integer point in the river in the range $[1,d-1]$. The boat always goes towards the nearest bank.

What is the expected distance travelled by the boat?

The right bank can be any of the possible distances with equal probability and the boat can be at any of the possible feasible distances with equal probability.

Suppose the distance between two banks is $2D$, then the expected distance travelled by the boat is $(1+2\ldots +D)/D=(D+1)/2$

• OK, suppose $B = 3.$ Let $(x,y)$ signify that the distance between banks is $x$ and the boat is $y$ distance from the left bank. When you say the cases are equiprobable, do you mean that $(4,1)$ and $(6,1)$ have the same probability? Or do you mean that the distance between banks is equally likely to be $4$ or $6$? Also, can the distance of the boat from a bank be $0$ (an integer) or must it be at least $1$? – David K Jul 21 '18 at 14:41
• What I mean is the distance between two banks can be any integer in range of $B+1$ and $2B$ with equal probability and when the two banks are $D$ distance apart, the boat has equal probability to be at any distance from 0 to D from the left bank. If it helps you can assume that the distance is at least 1, but that may not be an important detail – Vk1 Jul 21 '18 at 14:54
• I have changed to question for clarity, hope that helps. Yes I meant that distance between banks is equally likely to be 4 or 6. – Vk1 Jul 21 '18 at 18:31
• People may be waiting to see what you tried. Supposing you knew the distance between banks was $D$ (not random), could you find the expected distance traveled? – David K Jul 21 '18 at 23:19
• It should be about $D/4$, since best case the distance is 0 and worst case the distance is $D/2$ – Vk1 Jul 22 '18 at 10:48

Let $X$ be the boat's initial location, then $X$ is uniformly distributed over $\{1,2,\ldots,d-1\}$. The distance the boat travels is $$Y := \min\{X, d-X\}.$$ Now, $X<d-X$ iff $X<d/2$, and since $X$ and $d$ are integer, this is equivalent to $X\leqslant \lfloor d/2\rfloor$. It follows that \begin{align} \mathbb E[Y] &= \sum_{j=1}^{d-1} (j\wedge d-j)\mathbb P(X=j)\\ &= \frac1{d-1}\left(\sum_{j=1}^{\lfloor d/2\rfloor} j + \sum_{j=\lfloor d/2\rfloor+1}^{d-1} (d-j) \right)\\ &= \frac d2 -\left\lfloor\frac d2\right\rfloor \left(1 - \frac{\left\lfloor\frac d2\right\rfloor}{d-1} \right) . \end{align}