Riddler puzzle - distance from origin after two random jumps of equal length I love the FiveThirtyEight Riddler puzzle.  I try to do it as much as possible, but I'm not really trained in maths or stats. This weeks puzzle has you calculating the expected distance of two random "jumps" in a 2D plane. The jumps can be any direction (0-360 degrees) and are always the same length $r$. The problem asks what is the expected distance from the starting point?
I simplified this problem to start with the second jump (since the first will always be distance $r$). I tried to perform a change of variable to the probability function:
$$P[\Theta] = \frac{\Theta}{2\pi},$$
using the function:
$$L = 2 r \sin \left(\frac{\theta}{2}\right) 
\quad \quad \implies \quad \quad 
\theta=2 \text{arcsin}\left(\frac{L}{2r}\right),$$
where $L$ is the length from the starting point (see figure at bottom of post for my depiction of the problem).  After I do the re-arranging and take the Jacobian of the new function, the probability function I end up with is:
$$P(L) = \frac{2 \text{arcsin}\left(\frac{L}{2r}\right)}{\pi\sqrt{1-\frac{L^2}{4r}}}.$$
I multiply by 2 since the function is symmetric about 180-degrees.  However, if I integrate over this function from $0$ to $2r$, the result is $\pi/2$, not one, as I would expect.  If I simulate the jumps and plot the simulations over this probability density function, they are "similar" but far from identical.  Where am I going wrong with calculating the probability density function?



That puzzle was asking for the mode, not the expected distance.  Here is how I solved it.
Without loss of generality, assume that the cricket starts at (1,0) and jumps to the origin.  The question is then about the density of distances from (1,0) to any point on the unit circle.
Let $\theta \sim \operatorname{U}(0, 1)$,  so $p(\theta) = 1$.  We are asked about the mode of the distribution of
$$l^2 = 2 - 2\cos(\pi \theta) \implies l = \sqrt{2(1-\cos(\pi \theta))} $$
Here, I have used the law of cosines and the fact that the jump distance is exactly 1 unit long and am only considering the top half of the circle (hence $\pi \theta$) so that $l$ is a monotonically increasing function on [0,1].  We know the distribution of $\theta$, so we can use some well known results from probability theory to derive the distribution of $l$.
$$g(\theta) = 1$$
$$f(l) = g(\theta(l)) \Big\vert  \dfrac{d\theta}{dl} \Big\vert $$
$$ \theta(l) = \dfrac{1}{\pi}\arccos \Big( \dfrac{l^2}{2}-1 \Big) $$
$$ \Big\vert \dfrac{d\theta}{dl} \Big\vert  = \frac{2 l}{\pi \sqrt{(2l-l^2)(2l+l^2)}} $$
So the density for $l$ is "simply"
$$f(l) = \frac{2 l}{\pi \sqrt{(2l-l^2)(2l+l^2)}}$$
We can plot this and we notice that the majority of the probability is concentrated around 2

So although there is a discontinuity at 2, it appears that 2 is the mode. Additionally, this is a proper probability density
$$ \int_0^2 f(l) \, dl = \theta(2) - \theta(0) = \dfrac{1}{\pi} \pi - \dfrac{1}{\pi}0 = 1  $$
Another eloquent way to consider this problem is to plot points around the circle and color them by their distance like so

If we plot these along the unit interval, we notice that the the points are quite literally most dense around 2

Credit where credit is due:  Thank you to Corey Yanofsky for correcting my math on this and reminding me that this change of variables approach only applies when $l(\theta)$ is monotic.  Thank you to Jake Westfall (who is an active member on this forum) for the very clever plots of dots around the unit the circle.  That was all his idea, not mine.
