Sunday, August 22, 2021

Jiminy Crickets! I did not expect that!

Help, there’s a cricket on my floor! I want to trap it with a cup so that I can safely move it outside. But every time I get close, it hops exactly $1$ foot in a random direction.I take note of its starting position and come closer. Boom — it hops in a random direction. I get close again. Boom — it takes another hop in a random direction, independent of the direction of the first hop. What is the most probable distance between the cricket’s current position after two random jumps and its starting position?


Despite my lingering questions about the seemingly explosive nature of this cricket's jumping, I get to work by first setting up the coordinate system to most easily calculate the cricket's whereabouts. Let's make the cricket's starting point the origin and draw the $x$-axis between the origin and the cricket's position after its first hop, ensuring that its location after its first hop is $(1,0)$ on the plane. Thus, the cricket's position after its second hop can be modeled as $$X(\theta) = (1+\cos \theta, \sin \theta)$$ where $\theta \in U[0,2\pi).$ The distance for $X(\theta)$ is given by $$\|X\| = \|X(\theta)\| = \sqrt{ (1+\cos \theta)^2 + \sin^2 \theta } = \sqrt{2 + 2\cos \theta}.$$

The cumulative distribution of $\|X\|$ is then \begin{align*}F_{\|X\|} (r) &= \mathbb{P} \{ \|X\| \leq r \} = \mathbb{P} \{ \sqrt{2 + 2\cos \theta} \leq r \}\\ &= \mathbb{P} \{ \cos \theta \leq \frac{r^2}{2} - 1 \} \\&= 1 - \frac{\arccos \left( \frac{r^2}{2} - 1 \right)}{\pi},\end{align*} for all $r \in [0,2],$ while $F_{\|X\|} (r) = 0$ for $r \in (-\infty, 0)$ and $F_{\|X\|}(r) = 1,$ for $r \in (2,\infty).$ Differentiating, the probability density is thus $$f_{\|X\|}(r) = \frac{d}{dx} F_{\|X\|}(r) = \begin{cases} 0, &\text{if $r \in (-\infty, 0) \cup (2,\infty)$}\\ \frac{2}{\pi \sqrt{4-r^2}}, &\text{if $r \in (0,2).$}\end{cases}$$ Therefore, the most probable distance (or mode) of the cricket's distance from the origin density is thus interestingly at $r = 2.$ I know that the question prompt explicitly warned against calculating the expected distance, but as we shall see in the following, for sanity's sake, we see that the expected distance is $$\mathbb{E} \|X\| = \int_0^2 rf_{\|X\|}(r)\,dr = \frac{1}{\pi} \int_0^2 \frac{2r\,dr}{\sqrt{4-r^2}} = \left[-\frac{2\sqrt{4-r^2}}{\pi}\right]^{r=2}_{r=0} = \frac{4}{\pi}.$$


While I am a grisled veteran of Riddler's and weird mathematical oddities in general, this result somewhat shocked me at first blush. Essentially, this would indicate that the most probable case is that the cricket's first and second jumps are aligned. Not to mention the testing paradox of ``Wait?! The correct answer for how far away the cricket will most probably be after two jumps is just $2$ jumps times $1$ foot per jump?'' I mean, I get that it is a Riddler express, but .... So I also set up a quick simulation just to confirm.


In the simulation, I dispensed with the setting up of clever axes and just simulated two random directions, $U_1, U_2 \overset{\text{i.i.d.}}{\sim} U[0,2\pi)$ and defining the position after two hops as $X=e^{iU_1} + e^{iU_2}.$ Lo and behold! The histogram of the modulus of X shows that the result holds and that evidently the cricket will most probably land along the perimeter of the two foot circle around the cricket's intial location after its the second jump. To confirm that I haven't just made up two completely different weird results, we also see that the average modulus in the simulated sample is $1.273907 \approx \frac{4}{\pi},$ as expected (pun intended?).

Crickets
In [1]:
import matplotlib.pyplot as plt
import numpy as np
from numpy.random import uniform
%matplotlib inline
num_sims = 1000000
U = uniform(low=0.0, high=2*np.pi, size=(num_sims,2))
X = np.zeros(shape=(num_sims,2))
X[:,0] = np.cos(U[:,0])+np.cos(U[:,1])
X[:,1] = np.sin(U[:,0])+np.sin(U[:,1])
r = np.linalg.norm(X,axis=1)
_ = plt.hist(r, bins='auto')
plt.show()
print('Average of the simulation is %1.6f which is approximately 4/pi with rel. error %1.6f%%' % (r.mean(), np.abs(r.mean()*np.pi/4 -1.0)))
Average of the simulation is 1.273907 which is approximately 4/pi with rel. error 0.000524%

Sunday, August 15, 2021

You're clev'rest arou-ound, 65-ish percent of the time!

You are very clever when it comes to solving Riddler Express puzzles. You are so clever, in fact, that you are in the top 10 percent of solvers in Riddler Nation (which, as you know, has a very large population). You don’t know where in the top $10$ percent you are — in fact, you realize that you are equally likely to be anywhere in the topmost decile. Also, no two people in Riddler Nation are equally clever.

One Friday morning, you walk into a room with nine members randomly selected from Riddler Nation. What is the probability that you are the cleverest solver in the room?

Assume that the cleverest scale is continuous and runs from $0$, utter dunce, to $1,$ utter genius. Each member in Riddler nation can be assumed to have a cleverness level that is uniformly distributed on the unit interval from $[0,1].$ So let's say that your score is $C$ and your nine fellow Riddlerites in the room each have cleverness scores $C_i, i = 1, \dots, 9,$ with $C$ and $C_i$ i.i.d. as $U(0,1).$ The probability that you are the cleverest in the room, conditional on the the fact that $C \in [0.9,1]$ is given by \begin{align*}\mathbb{P} \{ C \geq C_i, i = 1, \dots, 9 \mid C \geq 0.9 \} &= \frac{1}{\mathbb{P} \{ C \geq 0.9 \}} \int_{0.9}^1 \left(\prod_{i=1}^9 \int_0^c \, dc_i \right) \, dc\\ &= 10 \int_{0.9}^1 c^9 \, dc = \left[c^{10} \right]_{c=0.9}^{c=1}\\ &= 1 - (0.9)^{10} = 0.6513...\end{align*}

Sunday, August 1, 2021

Involutary Spirals

Suppose you have a chain with infinitely many flat (i.e., one-dimensional) links. The first link has length 1, and the length of each successive link is a fraction $f$ of the previous link’s length. As you might expect, $f$ is less than $1.$ You place the chain flat on a table and some ink at the very end of the chain (i.e., the end with the infinitesimal links).

Initially, the chain forms a straight line segment, and the longest link is fixed in place. From there, the links are constrained to move in a very specific way: The angle between each chain and the next, smaller link is always the same throughout the chain. For example, if the $N$th link and the $N+1$st link form a $40$ degree clockwise angle, then so do the $N+1$st link and the $N+2$nd link.

After you move the chain around as much as you can, what shape is drawn by the ink that was at the tail end of the chain?

While the problem already provides for flexibility in terms of the value of $f \in (0,1),$ we will generalize the fixed angle between successive links to $\theta \in (0, 2\pi).$ Let's first figure out the points on the one-dimensional chain where the ends of each link are depending on the values of $f$ and $\theta.$

Assume that $X_0 = (0,0)$ and that $X_1 = (1,0)$ is the end of the first chain link of unit length. The end of the next link will be at $X_2 = (1+f\cos\theta, f\sin\theta),$ or in complex notation $X_2 = 1 + fe^{i\theta}.$ Similarly, since the end of the third link and the second link will have an angle of $\theta$ between them, it will make an angle of 2\theta with the positive real axis. Also, since the length of the third link is $f^2,$ we have $X_3 = 1 + fe^{i\theta} + f^2e^{i2\theta}.$ So on and so forth, we eventually get $$X_n = 1 + fe^{i\theta} + \cdots + f^{n-1}e^{i(n-1)\theta} = \sum_{k=0}^{n-1} (fe^{i\theta})^k = \frac{1 - f^n e^{in\theta}}{1- fe^{i\theta}}.$$

Depending on the values of $f$ and $\theta,$ the sequence $X(f,\theta) = \{X_n(f,\theta)\}_{n \in \mathbb{N}}$ has slightly different properties but is generally a sequence that spirals around its limit of $X_\infty(f,\theta) = \frac{1}{1-fe^{i\theta}} \in \mathbb{C}.$ The figure below shows the final position of the chain for several values of $f$ and $\theta$ in orange.

Now by construction, we are constructing involutes of these piecewise linear tracings of these complex sequences. Denote $Y_n = Y_n(f,\theta) \in \mathbb{C}$ denote the end of the chain after the completion of $n$ rotations/chain links. We start with $Y_0 = \frac{1}{1-f} \in (1,\infty).$ When we fix the point $X_1,$ the remaining link length of the remaining chaing to be rotated is $\frac{1}{1-f} -1 = \frac{f}{1-f},$ so after rotating through an angle of $\theta$ with the positive real axis, we have $$Y_1 = X_1 + \frac{f}{1-f} e^{i\theta}.$$ After fixing the point $X_2 = 1 + fe^{i\theta}$ the remaining chain to be rotated is $\frac{1}{1-f} - 1 -f = \frac{f^2}{1-f}$, so after rotation through another angle of $\theta,$ we have $$Y_2 = X_2 + \frac{f^2}{1-f} e^{i2\theta}.$$ Continuing the process we have $$Y_n(f,\theta) = X_n(f,\theta) + \frac{f^n}{1-f} e^{in\theta},$$ for each $n \in \mathbb{N}.$

We can obviously extend the process to fill in the gaps continuously between the sequence of points $Y(f,\theta) = \{Y_n(f,\theta)\}_{n\in \mathbb{N}}.$ Namely, let $\tilde{Y}(\cdot \mid f,\theta) : [0, \infty) \to \mathbb{C}$ denote the point where the ink is (at the end of the chain) at time $t \geq 0,$ as you are wrapping it around the sequence $X(f,\theta),$ such that $\tilde{Y}(t \mid f, \theta) = Y_t(f,\theta)$ for each $t \in \mathbb{N}.$ In particular, we have $$\tilde{Y}(t \mid f, \theta) = \frac{1 - (fe^{i\theta})^{\lceil t\rceil}}{1-fe^{i\theta}} + \frac{f^{\lceil t\rceil}}{1-f} e^{it\theta}$$ which is shown in the figure above shows the mapping $\tilde{Y}$ in blue for various values of $f$ and $\theta$.

Riddler Nation for the Win!

Riddler Nation is competing against Conundrum Country at an Olympic archery event. Each team fires three arrows toward a circular target 70 meters away. Hitting the bull’s-eye earns a team $10$ points, while regions successively farther away from the bull’s-eye are worth fewer and fewer points.

Whichever team has more points after three rounds wins. However, if the teams are tied after each team has taken three shots, both sides will fire another three arrows. (If they remain tied, they will continue firing three arrows each until the tie is broken.)

For every shot, each archer of Riddler Nation has a one-third chance of hitting the bull’s-eye (i.e., earning $10$ points), a one-third chance of earning 9 points and a one-third chance of earning $5$ points. Meanwhile, each archer of Conundrum Country earns $8$ points with every arrow.

Which team is favored to win? What is the probability that the team you identified as the favorite will win?

Despite its name the score of Conundrum Country's archery team is anything but. In any $3$-shot round, its perfectly imprecise archers will score $24$ points. While in expectation, the more volatile Riddler archers also average $24$, we need to figure out the probability that Ridder Nation will score more than $24$ points in any round.

Let $R_i$ be the score of the $i$th Riddler nation arrow, which is i.i.d. uniformly distributed over the discrete set $\Omega = \{5,9,10\}$ for $i = 1,2,3.$ There are $27 (=3^3)$ total outcomes for $(R_1, R_2, R_3) \in \Omega^3,$ which result in $10$ distinct possible outcomes for Riddler nation in any round, \begin{align*} 15 &= 5 + 5 + 5\\ 19 &= 5 + 5 + 9 = 5 + 9 + 5 = 9 + 5 + 5 \\ 20 &= 5 + 5 + 10 = 5 + 10 + 5 = 10 + 5 + 5\\ 23 &= 5 + 9 + 9 = 9 + 5 + 9 = 9 + 9 + 5\\ 24 &= 5 + 9 + 10 = 5 + 10 + 9 = 9 + 5 + 10 \\ & \,\,\,= 9 + 10 + 5 = 10 + 5 + 9 = 10 + 9 + 5 \\ 25 &= 5 + 10 + 10 = 10 + 5 + 10 = 10 + 10 + 5 \\ 27 & = 9 + 9 + 9 \\ 28 &= 9 + 9 + 10 = 9 + 10 + 9 = 10 + 9 + 9 \\ 29 &= 9 + 10 + 10 = 10 + 9 + 10 = 10 + 10 + 9 \\ 30 &= 10 + 10 + 10\end{align*}

So we see that \begin{align*}\mathbb{P} \{\text{loss}\} &= \mathbb{P} \{ R_1 + R_2 + R_3 \lt 24 \} = \frac{10}{27}\\ \mathbb{P} \{ \text{tie} \} &= \mathbb{P} \{ R_1 + R_2 + R_3 = 24 \} = \frac{6}{27}; \,\text{and}\\ \mathbb{P}\{\text{win}\} &= \mathbb{P} \{R_1 + R_2 + R_3 \gt 24\} = \frac{11}{27}.\end{align*} Since we can safely ignore the tie scenario, as this would (outside of a measure zero event) result in a finite number of rounds before eventually ending up in either a win or a loss for Riddler Nation. Therefore, we have $$\mathbb{P} \{\text{win} \mid \text{no ties}\} = \frac{\frac{11}{27}}{1 - \frac{6}{27}} = \frac{11}{21},$$ which implies that Riddler Nation should be the favorite to win the archery competition.