Sunday, October 26, 2025

Mob rules: implied odds for binary outcomes based on bet frequency

Suppose there are two leading candidates, A and B, for MVP in the Fiddler Baseball League.

Part 1:

Assume the odds for A winning the award have been set to $+100x$, where $x \gt 1$. Let $f$ represent the fraction of dollars wagered in favor of A. For many values of $f$, the oddsmaker can set the odds for B so that they’ll make the same amount of money regardless of whether A or B wins the award. However, below a certain value of $f$, it’s impossible for the oddsmaker to do this. What is this critical value of f?

In this case, if A wins then the oddsmaker must pay out $-xf$ to the bettors who supported A but receive $+(1-f)$ from the losing bettors who supported B, so the total cashflow if A wins is $$\pi_A(x,f) = 1-(x+1)f.$$ Let's assume that if B wins that the oddsmaker will have to pay out $-\rho(1-f),$ for some $\rho \gt 0,$ while they would receive $+f$ from all of the losing A bettors. In this case, the total cashflow if B wins is $$\pi_B(f,\rho) = f - \rho(1-f).$$ If the oddsmaker wants to make sure that $$\pi = \pi_A = 1 - (x+1)f = f - \rho(1-f) = \pi_B,$$ then we would need to set the payoff ratio for B to be $$\rho = \rho(x,f) = - \frac{1 - (2+x)f}{1-f}.$$ Since we need to have $\rho \gt 0,$ and $1-f \gt 0$ by definition since $f \in (0,1),$ we must have $1 - (2+x) f \lt 0$ or equivalently $$f \gt \frac{1}{2+x}.$$ Ideally, the bookmaker wants to make a profit so we would also want to make sure that $\pi = 1 - (x+1)f \gt 0,$ so $$f \lt \frac{1}{1+x}.$$ Now we can convert the payoff ratio as follows: if $\rho \geq 1,$ then the odds for B should be $+100\rho;$ whereas, if $\rho \in (0,1)$ then the odds for B should be $-100 / \rho.$ Therefore, if the odds for A are $+100x,$ then as long as $$f \in \left(\frac{1}{2+x}, \frac{1}{1+x}\right)$$ the oddsmaker can make a profit of $\pi = 1-(1+x)f \gt 0,$ regardless of outcome.

Part 2:

Now, assume the odds for A winning the award have been set to $-100y$, where $y \gt 1$. Again, for many values of $f$, the oddsmaker can set the odds for B so they’ll make the same amount whether A or B wins the award. What is the critical value of $f$ below which this isn’t possible?

In this case, if A wins the oddsmaker must pay out $-\frac{f}{y}$ to the bettors who supported A but receive +(1-f) from the losing bettors who support B, so the total cashflow if A wins is $$\pi_A(y,f) = 1 - \left(1 + \frac{1}{y}\right) f.$$ Let's assume that if B wins that the oddsmaker will have to payout $-\varrho (1-f),$ for some $\varrho \gt 0,$ while they would receive $+f$ from all of the losing A bettors. In this case, the total cashflow if B wins is $$\pi_B(f,\varrho) = f - \varrho(1-f).$$ If the oddsmaker wants to make sure that $$\pi = \pi_A = 1 - \left(1+\frac{1}{y}\right)f = f - \varrho(1-f) = \pi_B,$$ then we would need to set the payoff ratio for B to be $$\varrho = \varrho(y,f) = - \frac{y - (2y+1)f}{y(1-f)}.$$ Since we need to have $\varrho \gt 0,$ and $1-f \gt 0$ by definition since $f \in (0,1),$ we must have $y - (2y+1) f \lt 0$ or equivalently $$f \gt \frac{y}{2y+1}.$$ Ideally, the bookmaker wants to make a profit so we would also want to make sure that $\pi = 1 - \left(1+\frac{1}{y}\right)f \gt 0,$ so $$f \lt \frac{y}{1+y}.$$ Now we can convert the payoff ratio as follows: if $\varrho \geq 1,$ then the odds for B should be $+100\varrho;$ whereas, if $\varrho \in (0,1)$ then the odds for B should be $-100 / \varrho.$ Therefore, if the odds for A are $-100y,$ then as long as $$f \in \left(\frac{y}{2y+1}, \frac{y}{1+y}\right)$$ the oddsmaker can make a profit of $\pi = 1-\left(1+\frac{1}{y}\right)f \gt 0,$ regardless of outcome.

MAWGWTWFMVP

With the regular season over, there are two clear favorites for baseball’s American League Most Valuable Player (MVP) award according to ESPN:

  • Aaron Judge of the New York Yankees, whose odds are $-150$.
  • Cal Raleigh of the Seattle Mariners, whose odds are $+110$.

While these betting lines may be informed by an assessment of Judge’s and Raleigh’s real chances, they may also be informed by how much money people are betting on each player. Suppose all bettors have wagered on either Judge or Raleigh with the odds above. Some fraction $f$ of dollars wagered have been in favor of Judge, while $1−f$ has been wagered on Raleigh. For what fraction $f$ will the oddsmaker earn the same amount of money, regardless of which player earns the MVP award?

Let's normalize everything so that there is a total of one unit of total dollars wagered. When the Baseball Writers Association of America rightfully crowns Cal Raleigh as the AL MVP, the bookmaker will happily take the $+f$ from all the sad crybaby losers who were enthralled by everything New York Yankees. On the other hand in this case, the bookmaker would have to payout a total of $-1.1(1-f) = 1.1f - 1.1$ to the rational baseball afficianados who saw through the glitz, glamour and sour grapes of the East Coast media blitz for Judge and bet on Raleigh. So the total cashflow for the oddsmaker is $+f + 1.1f - 1.1 = 2.1f-1.1.$

On the other hand, just from a pure devil's advocacy perspective, there could be some happenstance where Raleigh could theoretically lose the AL MVP (tvu!, tvu!, tvu!, bli ayin hara!), ranging from the incompetent (the BBWAA forgot to change over its ballots from last year), to the patehtic (the geriatric writers couldn't stay up past their East Coast bedtimes to watch the pure and utter dominace of Raleigh), to any number of more nefarious, perverse chicanery. In this purely theoretical scenario, the oddsmaker would have a total payout of $-\frac{f}{1.5} = -\frac{2f}{3}$ to those delusional Judge patrons, while they would take the $+(1-f)$ from the hard-working, salt-of-the-earth, righteous Raleigh boosters. In this infinitesimally remote scenario, the total cashflow for the oddsmaker is $-\frac{2f}{3} + 1 -f = 1 - \frac{5f}{3}.$

A sober, dispassionate bookmaker would want these two cashflows to align, no matter how justified he might be in skewing it towards Raleigh's side. In this case, the only justification for having the oddsmaker set Raleigh as the underdog in this AL MVP race is because the two sides would net the same amount of positive cashflow if $$2.1f - 1.1 = 1 - \frac{5f}{3},$$ that is, $$f = \frac{2.1}{2.1 + \frac{5}{3}} = \frac{63}{113} \approx 0.55752212389\dots$$ of all bets were for Judge, for some ungodly reason.

Sunday, October 19, 2025

Average Distance from Center of a Unit Cube to Its Surface

Let’s raise the stakes by a dimension. Now, you start at the center of a unit cube. Again, you pick a random direction to move in, with all directions being equally likely. You move along this direction until you reach a point on the surface of the unit cube. On average, how far can you expect to have traveled?

So unlike shifting the shape that we are trying to hit the perimeter of, in the Extra Credit problem, we instead increase the dimensionality. Here $$B_\infty = \left\{ (x,y,z) \in \mathbb{R}^3 \mid \max \{ |x|, |y|, |z| \} = \frac{1}{2} \right\}.$$ Also, instead of parameterizing the direction of travel by a single bearing with respect to the positive $x$-axis, here we need to have two angles, one $\theta \in [0, \pi]$ with respect to the positive $z$-axis and a second $\varphi \in [0,2\pi)$ with respect to the positive $x$-axis. Since the differential of the solid angle of a region of the surface of the sphere is $d\Omega = \sin \theta \,d\varphi \,d\theta$ and the entire surface area of a unit sphere is $4\pi,$ we see that the join distribution function for $\theta$ and $\varphi$ is $$f(\theta, \varphi) = \frac{\sin \theta}{4\pi}.$$ Now, again assuming a unit speed, and given we get the position vector $$r(t) = ( t \cos \varphi \sin \theta, t \sin \varphi \sin \theta, t \cos \theta ).$$

Since you will hit $B_\infty$ whenever $t \max \{ |\cos \varphi \sin \theta|, |\sin \varphi \sin \theta|, |\cos \theta| \} = \frac{1}{2},$ so therefore the distance traveled is \begin{align*} d(\theta, \varphi) &= \frac{1}{2 \max \{ |\cos \varphi \sin \theta|, |\sin \varphi \sin \theta|, |\cos \theta| \}} \\ & = \frac{1}{2} \min \{ |\sec \varphi| \csc \theta, |\csc \varphi| \csc \theta, |\sec \theta | \}, \end{align*} where the final equation removes $\csc \theta$ from the absolute values since $\sin \theta, \csc \theta \geq 0$ for all $\theta \in [0,\pi]$

Therefore, the average distance is $$\hat{d} = \frac{1}{4\pi} \int_0^\pi \int_0^{2\pi} d(\theta, \varphi) \sin \theta \,d\varphi \, d\theta.$$ Now we can decompose this integral into three regions, two of which seem to have analytical solutions, so let's try even though we could just stop here and do the larger integral right here and right now.

Let's only worry about the upper hemisphere, that is $0 \leq \theta \leq \frac{\pi}{2}$. Here we can then break the range into the following three sections:

  • Region I - when $0 \leq \theta \leq \frac{\pi}{4},$ where you will eventually hit the top of the unit cube no matter what the value of $\varphi$;
  • Region II - when $\cos^{-1} \frac{1}{\sqrt{3}} \leq \theta \leq \frac{\pi}{2},$ where you will eventually hit one of the vertical sides of the unit cube no matter what the value of $\varphi$; and
  • Region III - when $\frac{\pi}{4} \leq \theta \leq \cos^{-1} \frac{1}{\sqrt{3}},$ where depending on the value of $\varphi$ you will either hit the top or the sides.

In other words, in Region I, $$d_1(\theta, \varphi) = \frac{1}{2} |\sec \theta|, \forall \varphi \in [0,2\pi),$$ so we have \begin{align*}I_1 &= \frac{1}{2\pi} \int_0^{\pi/4} \int_0^{2\pi} d_1(\theta, \varphi) \,d\varphi \, \sin \theta \,d\theta \\ &= \frac{1}{2\pi} \int_0^{\pi/4} \pi \tan \theta \, d\theta = \left.-\frac{1}{2} \ln | \cos \theta | \right|^{\pi/4}_0 \\ &= \frac{1}{4} \ln 2 \approx 0.17328679514\dots.\end{align*} In Region II, $$d_2(\theta, \varphi) = \frac{\csc \theta}{2} \min \{ |\sec \varphi|, |\csc \varphi| \},$$ so we have \begin{align*} I_2 &= \frac{1}{2\pi} \int_{\cos^{-1} (1/\sqrt{3})}^{\pi/2} \int_0^{2\pi} \frac{1}{2} \min \{ |\sec \varphi|, |\csc \varphi| \} \,d\varphi \csc \theta \sin \theta \,d\theta \\ &= \int_{\cos^{-1} (1/\sqrt{3})}^{\pi/2} \left( \frac{1}{2\pi} \int_0^{2\pi} \frac{1}{2} \min \{ |\sec \varphi|, |\csc \varphi| \} \,d\varphi \right) \,d\theta\\ & = \frac{2}{\pi} \ln ( 1 + \sqrt{2} ) \left( \frac{\pi}{2} - \cos^{-1} \left(\frac{1}{\sqrt{3}}\right) \right)\\ & = \left( 1 - \frac{ 2 \cos^{-1} \left( \frac{1}{\sqrt{3}} \right) }{\pi} \right) \ln (1 + \sqrt{2}) \approx 0.345345573653\dots,\end{align*} since the integral with respect to $\varphi$ is none other than the expected distance traveled inside a square, which we found the solution for in the Classic Problem. The trickier third region has integral $$I_3 = \int_{\pi/4}^{\cos^{-1} (1/\sqrt{3})} \int_0^{2\pi} d(\theta,\varphi) \,d\varphi \sin \theta \, d\theta \approx 0.0920550322989\dots,$$ which does not seem to have a readily available analytical solution. Putting these regions together we get that the overall average distance traveled to the surface of the unit cube when uniformly randomly choosing a direction is $$\hat{d} = I_1 + I_2 + I_3 = \frac{1}{4} \ln 2 + \left( 1 - \frac{ 2 \cos^{-1} \left( \frac{1}{\sqrt{3}} \right) }{\pi} \right) \ln (1 + \sqrt{2}) + I_3 \approx 0.610687401568\dots.$$

Average Distance from Center of a Unit Square to Its Perimeter

You start at the center of the unit square and then pick a random direction to move in, with all directions being equally likely. You move along this chosen direction until you reach a point on the perimeter of the unit square. On average, how far can you expect to have traveled?

Let's assume that you start at the origin, which is the center of the unit square $B_\infty = \{ (x,y) \in \mathbb{R}^2 \mid \max \{ |x|, |y| \} = \frac{1}{2} \}.$ Further, let's assume that your randomly chosen bearing makes an angle of $\theta$ with the positive $x$-axis, so $\theta \sim U(0,2\pi),$ and let's assume that you move at some unit speed, so your position through time will be $r(t) = (t \cos \theta, t \sin \theta).$

Since you will hit the $B_\infty$ exactly when $t \max \{ |\cos \theta|, |\sin \theta| \} = \frac{1}{2}$, therefore, the distance you would travel from the origin is given by $$d(\theta) = \frac{1}{2 \max \{ |\cos \theta|, |\sin \theta| \} } = \frac{1}{2} \min \{ |\sec \theta|, |\csc \theta| \}.$$ Relying on the periodicity of $d(\theta)$ to break the entire integral into 8 equal parts, we get thatthe expected distance is therefore \begin{align*}\hat{d} &= \frac{1}{2\pi} \int_0^{2\pi} d(\theta) \,d\theta \\ &= \frac{1}{2\pi} \left( 8 \int_0^{\pi/4} \frac{1}{2} \sec \theta \,d\theta \right) \\ &= \frac{2}{\pi} \Biggl.\ln \left| \sec \theta + \tan \theta \right| \Biggr|^{\pi/4}_0 \\ &= \frac{2}{\pi} \ln \left( 1 + \sqrt{2} \right) \approx 0.561099852339\dots.\end{align*}

We can extend this problem to the slightly different problem of starting at the origin, pointing a random direction and traveling at a uniform, unit Euclidean speed until we get to any the perimeter of any half-unit ball, say $B_p = \{ (x,y) \in \mathbb{R}^2 \mid |x|^p + |y|^p = \frac{1}{2^p} \}.$ As you could possibly surmise, the official question was $B_\infty,$ which is the limit as $p \to \infty.$ In this case, we would get $$d_p (\theta) = \frac{1}{2 \sqrt[p]{\cos^p \theta + \sin^p \theta}}$$ and $$\bar{d}_p = \frac{2}{\pi} \int_0^{\pi/4} \frac{d\theta}{\sqrt[p]{\cos^p \theta + \sin^p \theta}} = \frac{4}{\pi} \int_0^{\sqrt{2}-1} \frac{dt}{\sqrt[p]{(1-t^2)^p + 2^p t^p}},$$ where the second integral is obtains through the mystical tangent half-angle substitution. In general, this is not an analytical answer, though in certain other cases it simplifies. Obviously, for the case of $p=2$ everything simplifies to $d_2(\theta) = \frac{1}{2}, \forall \theta \in [0,2\pi)$ and so $\bar{d}_2 = \frac{1}{2}$ as well. For $p=1$, we have $$d_1(p) = \frac{1}{2 (\cos \theta + \sin \theta)}$$ and \begin{align*}\bar{d}_1 &= \frac{4}{\pi} \int_0^{\sqrt{2}-1} \frac{dt}{(1-t^2) + 2t}\\ &= \frac{4}{\pi} \int_0^{\sqrt{2}-1} \frac{dt}{1+2t-t^2}\\ &= \frac{\sqrt{2}}{\pi} \int_0^{\sqrt{2}-1} \frac{1}{1 + \sqrt{2} - t} + \frac{1}{\sqrt{2} - 1 + t} \,dt \\ &= \frac{\sqrt{2}}{\pi} \left. \ln \left| \frac{\sqrt{2} - 1 + t}{\sqrt{2} + 1 - t} \right| \right|_0^{\sqrt{2}-1}\\ & = \frac{\sqrt{2}}{\pi} \left( \ln \left(\frac{2\sqrt{2}-2}{2} \right) - \ln \left( \frac{\sqrt{2}-1}{\sqrt{2}+1} \right) \right)\\ &= \frac{\sqrt{2}}{\pi} \ln ( 1 + \sqrt{2} ) \approx 0.396757510512\dots.\end{align*} For completeness's sake, below is a table for various other values of $p.$

$p$ $\bar{d}_p$
$1$ $0.396757510512\dots$
$1.5$ $0.466430018867\dots$
$2$ $0.500000000000\dots$
$2.5$ $0.518545527769\dots$
$3$ $0.529817160992\dots$
$4$ $0.542203450927\dots$
$5$ $0.548481398011\dots$
$10$ $0.557672594762\dots$
$100$ $0.561063099606\dots$
$1000$ $0.56109948237\dots$
$\infty$ $0.561099852339\dots$

Monday, October 13, 2025

Let's Make a Tic-Tac-Deal, Extra Credit

In the actual game, you get five rolls instead of three. But as with rolling a 2 or 12, rolling a number that you have already rolled is a wasted turn. With five rolls of the dice, what are your chances of getting three Xs in a row, either horizontally, vertically, or diagonally?

Let's just simulate our way out of this. We have the same 8 possible winning sets, that we will encode as sets in Python and then after simulating a 5 rolls of two dice, we can check whether the resulting set of roll outcomes contains any of the winning sets. See the code snippet below that we can use to encode playing a random round of Tic-Tac-Deal.

Running $1$ million simulations, we infer that the probability of winning the game with $5$ dice rolls is about $36.0907\dots\%.$ In particular, the $95\%$ confidence interval is $(35.996568\%, 36.184832\%).$ Further, note that if we run these simulations with the parameter $rolls = 3,$ then we get a $95\%$ confidence interval of $(5.725294\%, 5.816706\%)$ which certainly contains our analytics answer of $\frac{113}{1944}.$

Let's Make a Tic-Tac-Deal!

The game of Tic-Tac-Deal $2.0$ has a $3$-by-$3$ square grid with the numbers $3$ through $11$, arranged as follows:

$3$ $4$ $5$
$6$ $7$ $8$
$9$ $10$ $11$

You start by rolling a standard pair of six-sided dice and add the two numbers rolled. You place an X on the board on the square that contains the sum. If the sum is a $2$ or $12$, your roll is wasted. If you have exactly three rolls of the dice, what are your chances of getting three Xs in a row (either horizontally, vertically, or diagonally)?

First, we see that $$p_n = \frac{\min\{n-1,13-n\}}{36}$$ is the probability of getting a vakue of $n$ on a roll of two standard dice. Secondly, we see that there are a total of 8 winning configurations: $\{3,4,5\}$, $\{3,6,9\}$, $\{3,7,11\}$, $\{4,7,10\}$, $\{5,7,9\}$, $\{5,8,11\}$, $\{6,7,8\}$, and $\{9,10,11\}.$

Since order doesn't matter here, the probability of getting a winning configuration $W=\{w_1, w_2, w_3\}$ is given by $$p(W)= 3! \prod_{i=1}^3 p_{w_i}.$$ So the overall probability of winning in three rolls is \begin{align*}P=\sum_W p(W)&= 3! \left( p_3p_4p_5 + p_3p_6p_9 + p_3p_7p_{11}\right. \\ &\quad\quad +p_4p_7p_{10} + p_5p_8p_{11} + p_5p_7p_9 \\ &\left.\quad\quad\quad + p_6p_7p_8 + p_9p_{10}p_{11} \right)\\ &= \frac{\left( 144 + 240 + 144 + 324 + 576 + 240 + 900 + 144 \right)}{46656} \\ &= \frac{113}{1944} \approx 5.812757\dots\%\end{align*}

Monday, October 6, 2025

What is Anita's 𝝋?

It’s time for you to check Anita’s work. What was the measure of angle $\varphi$?

Ok, so as we saw in the prior Classic Fiddler problem, Anita will be crossing the $1$-inch segment while she is on her $4$-inch line segment, that is when she is traveling from $$X_3 = (1+2\cos \varphi+3\cos 2\varphi, 2\sin \varphi + 3\sin 2\varphi)$$ to $$X_4 = (1 + 2 \cos \varphi + 3 \cos 2\varphi + 4\cos 3\varphi, 2 \sin \varphi + 3 \sin 2\varphi + 4 \sin 3 \varphi).$$ We have already somewhat loosely located $\varphi \in ( \frac{3\pi}{4}, \frac{4\pi}{5} ).$

We see that the line from $X_3$ to $X_4$ is given by $$y - 2 \sin \varphi - 3 \sin 2\varphi = \tan 3\varphi \left( x - 1 - 2 \cos \varphi - 3 \cos 2\varphi \right).$$ Additionally we note that since for large angles (e.g., $\phi = \pi$) the crossing point is near $(0,0)$ and since the crossing point for the smaller $\phi = \frac{4\pi}{5}$ being closer towards the $(1,0)$ endpoint of the initial segment, it stands to reason that for the optimal angle $\varphi,$ that the crossing point would be precisely at the endpoint $(1,0).$ In this cas we would have $$ - 2 \sin \varphi - 3 \sin 2 \varphi = \tan 3\varphi \left( -2 \cos \varphi - 3 \cos 2\varphi \right).$$ Since $$\tan 3 \varphi = \frac{ 3 \tan \varphi - \tan^3 \varphi }{ 1 - 3 \tan^2 \varphi } = \tan \varphi \frac{ 3 - \tan^2 \varphi }{ 1 - 3 \tan^2 \varphi } = \tan \varphi \frac{ 4 \cos^2 \varphi - 1}{ 4 \tan^2 \varphi - 3},$$ $$-2 \cos \varphi - 3 \cos 2\varphi = 3 - 2 \cos \varphi - 6 \cos^2 \varphi,$$ and $$2 \sin\varphi + 3 \sin 2\varphi = 2 \tan \varphi \cos \varphi ( 1 + 3 \cos \varphi ),$$ the above equality is equivalent (which much algebraic expansion and reduction) to \begin{align*} 0 &= \tan \varphi \frac{4 \cos^2 \varphi - 1}{4 \cos^2 \varphi - 3} ( 3 - 2\cos \varphi - 6 \cos^2 \varphi) + 2 \tan \varphi \cos \varphi (1 + 3 \cos \varphi) \\ &= \frac{\tan \varphi}{4 \cos^3 \varphi - 3} \left( (4 \cos^2 \varphi - 1) ( 3 - 2 \cos\varphi - 6 \cos^2 \varphi ) + 2 \cos \varphi ( 4 \cos^2 \varphi - 3 ) (1 + 3 \cos \varphi) \right) \\ &= - \frac{\tan \varphi (4 \cos \varphi + 3)}{4 \cos^2 \varphi - 3},\end{align*} so we have that $\varphi = \cos^{-1} \left(-\frac{3}{4}\right) \approx 2.41885840578\dots.$

Anita's Walk

Anita the ant is going for a walk in the sand, leaving a trail as she goes. First, she walks $1$ inch in a straight line. Then she rotates counterclockwise by an angle $\varphi$, after which she walks another $2$ inches. She rotates counterclockwise an angle $\varphi$ again, after which she walks $3$ inches. She keeps doing this over and over again, rotating counterclockwise an angle $\varphi$ and then walking $1$ inch farther than she did in the previous segment.

At some point during her journey, she crosses over her initial $1$-inch segment. By “cross over,” I am including the two end points of that first segment. Anita realizes that $\varphi$ was the smallest possible angle such that she crossed over her $1$-inch segment. (Among the ants, she’s known for her mathematical prowess.) How long was the segment along which she first crossed over the $1$-inch segment? Your answer should be a whole number of inches.

Let's let Anita's position on the $xy$-plane with origin centered at her trail's beginning after completing her line segment of length $n$, be $X_n = (x_n, y_n)$. In particular we then see that $$x_n = \sum_{k=1}^n k \cos ((k-1) \varphi) \,\,\text{and}\,\, y_n = \sum_{k=1}^n k \sin ((k-1) \varphi).$$ One thing we notice immediately is that as $n \to \infty,$ $X_n$ does not converge and in fact $\|X_n\| \to \infty.$ Therefore, if there is crossing over the initial segment it would have to happen in the first handful of steps, rather than after some extremely large cycle.

We see that if $\phi=\pi,$ then obviously Anita would de facto double back into her first line segment in her $n=2$ step, since she would start retracing her steps immediately. Let's try to see whether or not there can be some $\phi \lt \pi$ such that Anita crosses the first line segment in her $n=3$ step. In this case we see that $X_2 = (1 + 2\cos \phi, 2\sin \phi)$ and $X_3 = (1 + 2 \cos \phi + 3 \cos 2\phi, 2\sin \phi + 3\sin 2\phi),$ so the line connecting $X_2$ and $X_3$ is given by $$y - 2\sin \phi = \tan 2\phi \left( x - 1 - 2 \cos \phi \right).$$ In particular, if we assume that Anita crossed at some point $(h, 0)$ on the initial line segment, that is with $0 \leq h \leq 1,$ then we would get the equality \begin{align*}0 &= 2 \sin \phi \left( 1 - \frac{ \cos \phi \left( 2 \cos \phi + 1 - h \right) }{ \cos 2\phi } \right)\\ &= \frac{2 \sin \phi}{\cos 2\phi} \left( \cos 2\phi - \cos \phi \left( 2\cos \phi + 1 - h \right) \right) \\ &= \frac{2 \sin \phi}{\cos 2\phi} \left( 2 \cos^2 \phi - 1 - \left(2 \cos^2 \phi + (1-h) \cos \phi\right) \right) \\ &= -\frac{2\sin \phi}{\cos 2\phi} \left( 1 + (1-h) \cos \phi \right)\end{align*} For $h \in (0,1],$ we have $-\frac{1}{1-h} \lt -1,$ so there are no solutions of $\phi \in \mathbb{R}$ with $1 + (1-h) \cos \phi = 0.$ Therefore, besides the case of $\phi = \pi$ as we saw before, there are no solutions where Anita crosses the $1$-inch segment on her $n=3$ step.

Let's look at the case of say $\phi = \frac{4\pi}{5}.$ In this case, we see that $X_3 = (0.309017\dots, -1.677599\dots)$ and $X_4=(1.545085\dots, 2.126627\dots),$ so the $n=4$ line segment crosses the $1$-inch line segment at $(h,0)$ for $h\approx 0.854102\dots.$ So there is some value of $\phi$ for which Anita would cross the $1$-inch segment on the $n=4$ segment.

Let's look at another case where $\phi=\frac{3\pi}{4}.$ Here we see the $X_3=(1-\sqrt{2}, \sqrt{2}-3)$ and $X_4=(1+\sqrt{2},3\sqrt{2}-3).$ The line segment between $X_3$ and $X_4$ narrowly missed the $1$-inch segment, crossing at $(4-2\sqrt{2},0)$. We can show (or at least vigorously wave our hands) that there are no angle $\phi \leq \frac{3\pi}{4}$ that there are similarly no instances where Anita would cross the $1$-inch segment.

Therefore, we see that the length of the segment that Anita crossed the initial path with was four.

Monday, September 29, 2025

Riskier Risk, Now with Wilds!

The full deck of Risk cards also contains two wildcards, which can be used as any of the three types of cards (infantry, cavalry, and artillery) upon trading them in. Thus, the full deck consists of $44$ cards.

You must have at least three cards to have any shot at trading them in. Meanwhile, having five cards guarantees that you have three you can trade in.

If you are randomly dealt cards from a complete deck of $44$ one at a time, how many cards would you need, on average, until you can trade in three? (Your answer should be somewhere between three and five. And no, it’s not four.)

Let $S$ be the random number of cards you have when you can first turn in a set of three cards. Obviously we have $3\leq S\leq 5,$ so lets go about calculating $p_s = \mathbb{P} \{ S= s\},$ for $s \in \{3, 4, 5\},$ which we can then compute $$\mathbb{E} [S] = \sum_{s=3}^5 sp_s.$$

From the Classic wildless Risk problem, we see that there remain $3836$ possible combinations of three card sets without using any wilds. To this we must at $\binom{2}{1} \binom{42}{2} = 1722$ possible combinations of three card sets with ome wild card and $\binom{2}{2}\binom{42}{1}=42$ possible combinations of three card sets with two wild cards. In total, there are $5600$ possible sets of three cards, out of a total $\binom{44}{3}=13244$ possible hands of three Risk cards, so we have $$p_3 = \frac{5600}{13244}=\frac{200}{473}\approx 42.283\dots\%$$

Rather than the messiness of figuring out the exact combinations for $S=4$, let's instead tackle $S=5.$ We see that if you do not get a set on your fourth card then you will automatically get a set by your fifth card, so we only need to figure out what situations lead you to not have a set after four cards. This can only happen whenever you have two of one type and two of a different type (with no wilds, obviously). There are $\binom{14}{2}\binom{14}{2}\binom{3}{2}=24843$ possible hands that have exactly two cards in two different types. Since there are $\binom{44}{4} = 135751$ possible combinations of four distinct Risk cards, we thus have $$p_5=\frac{24843}{135751}=\frac{3549}{19393}\approx 18.300\dots\%$$

Since we can reason that $p_4=1-p_3-p_5 = \frac{7644}{19393}\approx 39.416\dots\%,$ we have the expected number of Risk cards needed to turn in a set is $$\mathbb{E}[S]= 3 \frac{200}{473} + 4 \frac{7644}{19393} + 5 \frac{3549}{19394} = \frac{72921}{19393} \approx 3.760171\dots$$

Risk without Wilds

There are $42$ territory cards in the deck—$14$ that depict an infantry unit, $14$ that depict a cavalry unit, and $14$ that depict an artillery unit. Once you have three cards that either (1) all depict the same kind of unit, or (2) all depict different kinds of units, you can trade them in at the beginning of your next turn in exchange for some bonus units to be placed on the board.

If you are randomly dealt three cards from the $42$, what is the probability that you can trade them in?

In this case, we see that there are $\binom{42}{3}=11480$ possible hands combined of three Risk cards if you remove the wild cards. There are $\binom{14}{3}=364$ possible combinations of three cards within any kind and three different kinds (that is, infantry, cavalry and artillery), so a total of $1092$ different three of a kind sets that can be formed. There are also $14^3 = 2744$ different one of each sets. So there a total of $3836$ sets of three Risk cards without wild cards, which implies that the probability of being able to trade in a randomly dealt set of three cards when the wild cards have been removed is $$p = \frac{3836}{11480} = \frac{137}{410} \approx 33.41463\dots \%$$

Monday, September 15, 2025

Letters Boxed, Like Surgeons General

Consider the following diagram, which consists of eight points (labeled $A$ through $H$), two on each side of the square. A valid “letter boxed” sequence starts at any of the eight points, and proceeds through all of the other points exactly once. However, adjacent points in the sequence can never be on the same side of the square. The first and last points in the sequence can be on the same side, but do not have to be.

As an illustration, $AFBCHEDG$ is a valid sequence of points. However, $AFBCHGED$ is not a valid sequence, since $H$ and $G$ are adjacent in the sequence and on the same side of the square. How many distinct valid “letter boxed” sequences are there that include all eight points on the square?

Well in total, there are $8! = 40,320$ different words that can be made up of the letters $A$ through $H$ with no repeated letters. One possible way is to get this answer is to just enumerate all $40,320$ possible words and throw away any words with forbidden doublets, like $AB$, $EF$ or $HG$. This is not too terribly time consuming in a short Python script, which yields that there are a total of $13,824$ different letters boxed that include all eight points on the square.

Instead of two points on each side of the square (and eight points in total), now there are three points on each side (and twelve points in total), labeled A through L in the diagram below. How many distinct valid “letter boxed” sequences are there that include all $12$ points on the square?

While $8!$ might be well within a modern programming languages wheelhouse to try to iterate through, $12!$ is more than $500$ million possible words that are composed of the letters $A$ through $L$ with no repeated letters. So unless we want to run a script all weekend, let's try a different approach. We can encode the 12 points on the square and the adjacency of the letter boxed game into a graph $\mathcal{G},$ where for instance there is an edge from $A$ to each letter $D, E, F, \dots, L,$ but no edge between $A$ and $B$, $A$ and $C$ or $B$ and $C,$ since they all share the same side of the square. A letter boxed that contains all twelve letters would then be a Hamiltonian path on $\mathcal{G},$ so let's liberally borrow the Python3 code provided by user Gaslight Deceive Subvert from this StackOverflow post related to enumerating all Hamiltonian paths on a graph and get to countings. Since I don't particularly care about the paths themselves and just the number of them, instead of printing the entire list of all Hamiltonian paths, I modified it to just print the number of distinct Hamiltonian paths.

To confirm that everything seemed above board, I started out with the graph from the Classic problem given by \begin{align*}\textsf{G} &\textsf{= \{'A':'CDEFGH', 'B':'CDEFGH', 'C':'ABEFGH', 'D':'ABEFGH',}\\ &\quad\quad \textsf{'E':'ABCDGH', 'F':'ABCDGH','G':'ABCDEF', 'H' : 'ABCDEF'\}}.\end{align*} THankfully, the code retrieved the answer of $13,824$ letters boxed, so I then felt confident enough to encode the Extra Credit graph as \begin{align*}\tilde{G} &\textsf{= \{'A':'DEFGHIJKL', 'B':'DEFGHIJKL', 'C':'DEFGHIJKL',}\\ &\quad\quad\quad \textsf{'D':'ABCGHIJKL', 'E':'ABCGHIJKL', 'F':'ABCGHIJKL',}\\ &\quad\quad\quad\quad \textsf{'G':'ABCDEFJKL', 'H' : 'ABCDEFJKL', 'I':'ABCDEFJKL',}\\ &\quad\quad\quad\quad\quad \textsf{ 'J' : 'ABCDEFGHI', 'K' : 'ABCDEFGHI', 'L' : 'ABCDEFGHI'\}}.\end{align*}.$$ Here, after running the code for roughly 15 minutes, we get a grand total of $53,529,984$ letters boxed with all $12$ points on the square.

Monday, September 8, 2025

High-Low Hijinks Extra Credit

Your friend is playing an epic game of “high-low” and has made it incredibly far, having racked up a huge number of points. Given this information, and only this information, what is the probability that your friend wins the next round of the game?

Let's define this problem as the following probabilistic statement, what is the conditional probability that $N \geq n+1$ given that $N \geq n,$ when $n$ is large? That is, find $$\lambda = \lim_{n \to \infty} \mathbb{P} \left \{ N \geq n+1 \mid N \geq n \right\} = \lim_{n\to \infty} \frac{\mathbb{P} \{ N \geq n+1 \}}{\mathbb{P} \{ N \geq n \} } = \lim_{n\to\infty} \frac{p_{n+1}}{p_n}.$$

One method that we can do is to just compute successive values of $p_n,$ as per the following table:

$n$ $p_n$
1 $\frac{3}{4}$
2 $\frac{13}{24}$
3 $\frac{25}{64}$
4 $\frac{541}{1920}$
5 $\frac{1561}{7680}$
6 $\frac{47293}{322560}$
7 $\frac{36389}{344064}$
8 $\frac{7087261}{92897280}$
9 $\frac{34082521}{619315200}$
10 $\frac{1622632573}{40874803200}$

Even by this point, it seems that the ratio of $p_{n+1} / p_n$ approaches roughly $0.72134752\dots,$ but let's see if we can make sense of this otherwise mysterious limit.

Let's focus on the recursion $h_{n+1}(t) = \int_0^1 I(t,x) h_n(x) \,dx$ that we saw in the Classic problem. Let's assume that we have $h_{n+1} (x) \approx \lambda h_n (x),$ for large values of $n \gg 1.$ Then the recursion formula would settle down to something like $$\lambda h^*(t) = \int_0^1 I(t,x) h^*(x) \,dx = \begin{cases} \int_t^1 h^*(x)\,dx, &\text{if $t \lt \frac{1}{2};$}\\ \int_0^t h^*(x) \,dx, &\text{if $t \gt \frac{1}{2};$}\end{cases}.$$ Differentiating both sides of the equation, we get $$\lambda \frac{d}{dt} h^*(t) = \begin{cases} -h^*(t), &\text{if $t \lt \frac{1}{2};$}\\ h^*(t), &\text{if $t \gt \frac{1}{2}.$}\end{cases}.$$ Let's focus on when $t \gt \frac{1}{2},$ in which case we have $\lambda \frac{d}{dt} h^*(t) = h^*(t),$ so we would have $h^*(t) = C \exp \left( \frac{t}{\lambda} \right)$ for $t \gt \frac{1}{2},$ with $h^*(t) = h^*(1-t) = C \exp \left( \frac{ 1-t}{\lambda} \right)$ for $t \lt \frac{1}{2}.$ In this case, plugging back in, if our recursion formula still holds for $t \gt \frac{1}{2},$ we would need to have \begin{align*}\lambda C e^{t/\lambda} &= \int_0^\frac{1}{2} C \exp \left( \frac{1-t}{\lambda} \right)\,dt + \int_\frac{1}{2}^t C\exp \left(\frac{t}{\lambda}\right) \,dt \\ &= \lambda C \left( e^{1/\lambda} - e^{1/(2\lambda)} \right) + \lambda C \left( e^{t/\lambda} - e^{1/(2\lambda)} \right) \\ &= \lambda C e^{t/\lambda} + \lambda C \left( e^{1/\lambda} - 2 e^{1/(2\lambda)} \right).\end{align*} Therefore, we must have either $\lambda = 0$ or $e^{1/\lambda} - 2 e^{1/(2\lambda)} = 0$ in order tof the recursion formula to hold, which implies that the conditional probability of winning the next round in a long game of high-low is $$\lambda = \lim_{n \to \infty} \frac{p_{n+1}}{p_n} = \frac{1}{2\ln 2} \approx 0.721347520444\dots.$$

High-Low Hijinks

You’re playing a game of “high-low,” which proceeds as follows:

  • First, you are presented with a random number, $x_1$, which is between $0$ and $1.$
  • A new number, $x_2$, is about to be randomly selected between $0$ and $1$, independent of the first number. But before it’s selected, you must guess how $x_2$ will compare to $x_1$. If you think $x_2$ will be greater than $x_1$ you guess “high.” If you think $x_2$ will be less than $x_1$, you guess “low.” If you guess correctly, you earn a point and advance to the next round. Otherwise, the game is over.
  • If you correctly guessed how $x_2$ compared to $x_1$ then another random number, $x_3$, will be selected between $0$ and $1$. This time, you must compare $x_3$ to $x_2$, guessing whether it will be “high” or “low.” If you guess correctly, you earn a point and advance to the next round. Otherwise, the game is over.

You continue playing as many rounds as you can, as long as you keep guessing correctly. You quickly realize that the best strategy is to guess “high” whenever the previous number is less than $0.5,$ and “low” whenever the previous number is greater than $0.5.$ With this strategy, what is the probability you will earn at least two points? That is, what are your chances of correctly comparing $x_2$ to $x_1$ and then also correctly comparing $x_3$ to $x_2$?.

Let's define the indicator function $$I(s,t) = \begin{cases} 1, &\text{if $(t-s)(s-\frac{1}{2}) \leq 0;$} \\ 0, &\text{otherwise,}\end{cases}$$ such that $I(x_1,x_2) = 1$ whenever you successfully earned a point in the first round and $I(x_2,x_3) = 1$ whenever you successfully earned a second point. Let $N = N(x_1, x_2, \dots, x_n, \dots)$ be the random variable that corresponds to your score from playing this game of high-low. We see that based on this setup we have $$\mathbb{P} \{ N \geq n \} = \int_0^1 \int_0^1 \cdots \int_0^1 \prod_{i=1}^n I(x_i, x_{i+1}) \,dx_{n+1} \,dx_n \,dx_{n-1}\, \cdots \,dx_2 \,dx_1.$$ Further, let's define $h_0(t) = 1$ and $$h_1(t) = \int_0^1 I(t, x) \,dx = \begin{cases} \int_t^1 \,dx = 1-t, &\text{if $t \lt \frac{1}{2};$}\\ \int_0^t \,dx = t, &\text{if $t \geq \frac{1}{2};$} \end{cases} = \max \{ t, 1-t \}.$$ Finally, for any $n \in \mathbb{N},$ define $$h_{n+1}(t) = \int_0^1 I(t,x) h_n(x) \,dx.$$

In particular, if we want to see the probability of haveing a score of at least $2$ is \begin{align*}p_2 = \mathbb{P} \{ N \geq 2 \} &= \int_0^1 \int_0^1 \int_0^1 I(x_1,x_2) I(x_2, x_3) \,dx_3\,dx_2\,dx_1 \\ &= \int_0^1 \int_0^1 I(x_1,x_2) \left(\int_0^1 I(x_2, x_3) \,dx_3 \right) \,dx_2\,dx_1 \\ &= \int_0^1 \int_0^1 I(x_1,x_2) h_1(x_2) \,dx_2 \,dx_1\\ &= \int_0^1 h_2(x_1) \,dx_1.\end{align*} If we extrapolate further, which we will need primarily for the Extra Credit problem, we see that $$p_n = \mathbb{P} \{ N \geq n \} = \int_0^1 h_n(t) \,dt, \,\, \forall n \in \mathbb{N}.$$

Returning to the Classic problem here, we have $h_1(t) = \max \{ t, 1-t \}$ and \begin{align*}h_2(t) = \int_0^1 I(t,x) \max \{x, 1-x\} \,dx &= \begin{cases} \int_t^1 \max \{ x, 1 - x\} \,dx, &\text{if $t \lt \frac{1}{2};$} \\ \int_0^t \max \{x, 1-x\}\,dx, &\text{if $t \geq \frac{1}{2};$}\end{cases} \\ &= \begin{cases} \int_t^\frac{1}{2} (1-x) \,dx + \int_\frac{1}{2}^1 x\,dx, &\text{if $t \lt \frac{1}{2};$} \\ \int_0^\frac{1}{2} (1-x) \,dx + \int_\frac{1}{2}^t x \,dx, &\text{if $t \geq \frac{1}{2};$}\end{cases} \\ &= \begin{cases} \frac{3}{4} - t + \frac{t^2}{2}, &\text{if $t \lt \frac{1}{2};$} \\ \frac{1}{4} + \frac{t^2}{2}, &\text{if $t \geq \frac{1}{2};$}\end{cases} \\ &= \max \left\{ \frac{3}{4} -t + \frac{t^2}{2}, \frac{1}{4} + \frac{t^2}{2} \right\}.\end{align*} So we have the probability of earning at least two points is \begin{align*}p_2 = \mathbb{P} \{ N \geq 2 \} &= \int_0^1 h_2(t) \,dt\\ &= \int_0^\frac{1}{2} \left( \frac{3}{4} - t + \frac{t^2}{2} \right) \,dt + \int_\frac{1}{2}^1 \left( \frac{1}{4} + \frac{t^2}{2} \right) \,dt\\ &= \left[ \frac{3}{4}t -\frac{1}{2}t^2 + \frac{1}{6} t^3 \right]^{t=\frac{1}{2}}_{t=0} + \left[ \frac{1}{4} t + \frac{1}{6} t^3 \right]^{t=1}_{t=\frac{1}{2}} \\ &= \left(\frac{3}{8} - \frac{1}{8} + \frac{1}{48}\right) + \left(\frac{1}{4} + \frac{1}{6}\right) - \left( \frac{1}{8} + \frac{1}{48} \right) \\ &= \frac{13}{24}.\end{align*}

Monday, August 25, 2025

Sundown Trail Race with a Mulligan

Now let’s add one more wrinkle. At some point during the race, if you’re unhappy with the loop you’ve just been randomly assigned, you’re granted a “mulligan,” allowing you to get another random assignment. (Note that there’s a $25$ percent chance you’ll be assigned the same loop again.) You don’t have to use your mulligan, but you can’t use it more than once.

As before, the time is $5$:$55$ p.m. You have just completed a loop, and you haven’t used your mulligan yet. With an optimal strategy (i.e., using the mulligan at the right moment, if at all), on average, what score can you expect to earn between $5$:$55$ p.m. and $7$ p.m.?

As we saw in the Classic post, let's use the absorption probabilities matrix $B = \left(B(t,s)\right)_{t \in \mathfrak{T}, s \in \mathfrak{S}},$ which is the probability of starting at transient state $t$ and ending up at the final, absorbing state $s.$ This will give us the expected score of starting at transient state $i$ with no mulligans $$E(i) = \mathbb{E} [ S \mid S_0 = i ] = \sum_{s \in \mathfrak{S}} s B(i,s).$$ In particular, we have the vector $$E = \left(E(t)\right)_{t \in \mathfrak{T}} = \begin{pmatrix} \frac{19933}{4096} \\ \frac{5245}{1024} \\ \frac{1437}{256} \\ \frac{317}{64} \\ \frac{293}{64} \\ \frac{69}{16} \\ \frac{77}{16} \\ \frac{21}{4} \\ \frac{23}{4} \end{pmatrix}.$$

We can only use a single mulligan, but it is enough to change the overall expected score. Let's denote $$\tilde{E}(t) = \tilde{\mathbb{E}}[ S \mid S_0 = s ],$$ as the expected score when starting at state $s$. In particular, let's say that we are currently finishing up our lap to attain the transient score of $t \in \mathfrak{T},$ where we haven't yet used our mulligan, and we are quickly decide for which new laps we want to use our mulligan. Let's say the randomly assigned lap will move us from $t$ to $t^\prime \in \mathfrak{T}.$ If we use our mulligan in this turn then we will end up with an expected score of $E(t);$ whereas if we don't use the mulligan, then we would end up with an expected score of $\tilde{E}(t^\prime),$ since we would still have our mulligan remaining. So the optimal choice if we end up moving from $t$ to $t^\prime \in \mathfrak{T}$ would be to give us $\max \{ E(t), \tilde{E}(t^\prime) \}.$ Similarly, if we are randomly assigned to move from $t$ to some $s \in \mathfrak{S}$, then if we use our mulligan we end up with expected score of $E(t)$ versus a score of $s,$ if we don't. So if we are would move from $t$ to $s \in \mathfrak{S}$ the optimal choice gives us $\max \{E(t), s \}.$ Putting this altogether, we the corresponding transition probabilities from the $Q$ and $R$ matrices given in the Classic problem, we get the recursive formula $$\tilde{E}(t) = \sum_{t^\prime \in \mathfrak{T}} Q(t, t^\prime) \max \{ E(t), \tilde{E}(t^\prime) \} + \sum_{s \in \mathfrak{S}} R(t,s) \max \{ E(t), s \}.$$

So let's go recursing .... \begin{align*} \tilde{E}(5.5) &= \frac{3}{4} \max\{ E(5.5), 5.5 \} + \frac{1}{4} \max \{ E(5.5), 6.5 \} = \frac{3}{4} E(5.5) + \frac{1}{4} 6.5 = \frac{95}{16} \\ \tilde{E}(5) &= \frac{3}{4} \max \{ E(5), 5 \} + \frac{1}{4} \max \{ E(5), 6 \} = \frac{3}{4} E(5) + \frac{1}{4} 6 = \frac{87}{16} \\ \tilde{E}(4.5) &= \frac{1}{4} \max \{ E(4.5), \tilde{E}(5.5) \} + \frac{3}{4} \max \{ E(4.5), 4.5 \} = \frac{1}{4} \tilde{E}(5.5) + \frac{3}{4} E(4.5) = \frac{163}{32} \\ \tilde{E}(4) &= \frac{1}{4} \max \{ E(4), \tilde{E}(5) \} + \frac{3}{4} \max \{ E(4), 4 \} = \frac{1}{4} \tilde{E}(5) + \frac{3}{4} E(4) = \frac{147}{32} \\ \tilde{E}(3.5) &= \frac{1}{4} \max \{ E(3.5), \tilde{E}(4.5) \} + \frac{1}{2} \max \{ E(3.5), 3.5 \} + \frac{1}{4} \max \{ E(3.5), 6.5 \} \\ &\quad\quad = \frac{1}{4} \tilde{E}(4.5) + \frac{1}{2} E(3.5) + \frac{1}{4} 6.5 = \frac{83}{16} \\ \tilde{E}(3) &= \frac{1}{4} \max \{ E(3), \tilde{E}(4) \} + \frac{1}{4} \max \{ E(3), 3 \} + \frac{1}{4} \max \{ E(3), 6 \} + \frac{1}{4} \max \{ E(3), 6.5 \} \\ &\quad\quad = \frac{1}{4} E(3) + \frac{1}{4} E(3) + \frac{1}{4} 6 + \frac{1}{4} 6.5 = \frac{1411}{256}\\ \tilde{E}(2) &= \frac{1}{4} \max \{ E(2), \tilde{E}(3) \} + \frac{1}{4} \max\{ E(2), \tilde{E}(5) \} + \frac{1}{4} \max \{ E(2), \tilde{E}(5.5) \} + \frac{1}{4} \max \{ E(2), 6.5 \} \\ &\quad\quad = \frac{1}{4} E(2) + \frac{1}{4} E(2) + \frac{1}{4} \tilde{E}(5) + \frac{1}{4} 6.5 = \frac{3029}{512}\\ \tilde{E}(1) &= \frac{1}{4} \max \{ E(1), \tilde{E}(2) \} + \frac{1}{4} \max \{ E(1), \tilde{E}(4) \} + \frac{1}{4} \max \{ E(1), \tilde{E}(4.5) \} + \frac{1}{4} \max \{ E(1), \tilde{E}(5.5) \} \\ &\quad\quad = \frac{1}{4} \tilde{E}(2) + \frac{1}{4} E(1) + \frac{1}{4} E(1) + \frac{1}{4} \tilde{E}(5.5) = \frac{5657}{1024} \end{align*}

This leaves us with one more step to show that the total expected score on accrued between $5$:$55$ pm and $7$ pm going at a constant $10$ minute per mile pace with one single mulligan is \begin{align*} \tilde{E}(0) &= \frac{1}{4} \max \{ E(0, \tilde{E}(1) \} + \frac{1}{4} \max \{ E(0), \tilde{E}(3) \} + \frac{1}{4} \max \{ E(0), \tilde{E}(3.5) \} + \frac{1}{4} \max \{ E(0), \tilde{E}(4.5) \} \\ &\quad\quad = \frac{1}{4} \tilde{E}(1) + \frac{1}{4} \tilde{E}(3) + \frac{1}{4} \tilde{E}(3.5) + \frac{1}{4} \tilde{E}(4.5)\\ &\quad\quad = \frac{21921}{4096} = 5.351806640625 \end{align*}

Sundown Trail Race

You’re participating in a trail run that ends at sundown at $7$ p.m. The run consists of four loops: $1$ mile, $3$ miles, $3.5$ miles, and $4.5$ miles. After completing any given loop, you are randomly assigned another loop to run—this next loop could be the same as the previous one you just ran, or it could be one of the other three. Being assigned your next loop doesn’t take a meaningful amount of time; assume all your time is spent running.

Your “score” in the race is the total distance you run among all completed loops. If you’re still out on a loop at $7$ p.m., any completed distance on that loop does not count toward your score!

It is now $5$:$55$ p.m. and you have just completed a loop. So far, you’ve been running $10$-minute miles the whole way. You’ll maintain that pace until $7$ p.m. On average, what score can you expect to earn between $5$:$55$ p.m. and $7$ p.m.?

OK, let's agree on how to parametrize this. There are $65$ minutes left in the race and you are running at a clean $10$ minutes per mile, so let's just divide everything by $10$ minute per mile and deal with things entirely in miles or score space. In this space, the problem looks like this: Your score is currently $0$, you will be assigned a random score increment $\delta S$ whichi if uniformly distributed over the set $\Delta S = \{1 , 3, 3.5, 4.5 \}.$ If $S + \delta S \leq 6.5,$ then your new score is $S+\delta S.$ Otherwise, if $S + \delta S \gt 6.5,$ then your final score will be $S.$ For clarity, we see that the possible final scores are $\mathfrak{S} = \{ 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5\}.$

With the transformation complete, we can either go through the combinatorial enumeration of all possible paths to get to a final score of, say, $S=3.5$. In that particular case, we see that in order to end with a score of $3.5$ you must first be assigned $3.5$ in your first loop and then be assigned either $3.5$ or $4.5$ in your second lap. This would then have a total probability of $\frac{1}{4} \times \frac{1}{2} = \frac{1}{8}.$ This can definitely be done for each of the other elements in $\mathfrak{S},$ but for the Extra Credit answer we will want to take advantage of modeling this as an absorbing Markov chain .... so let's do that here too.

The total number of states in this Markov Chain is $17$, there are nine (9) transient states $\mathfrak{T} = \{0, 1, 2, 3, 3.5, 4, 4.5, 5, 5.5\}$ and then the eight final, absorbing states in $\mathfrak{S}.$ Note that there two possible states where the current score is, say $3.5$, one in $\mathfrak{T},$ which represents a state that could still have some $\delta S \lt 3.5$ added to it and the race continuing and the final one where the race is over in $\mathfrak{S}.$ If at any time we have to differentiate between the transient and absorbing states that have the same numerical values, we will use $T$ and $A$ superscripts, e.g, $3.5^T \in \mathfrak{T}$ and $3.5^A \in \mathfrak{S}.$ If no superscript is provided, then let's safely assume that we are talking about the final, absorbing state.

OK, now let's get the canonical form of the transition matrix $P = \begin{pmatrix} Q & R \\ 0 & I_8 \end{pmatrix},$ where $Q$ is the $9 \times 9$ matrix representing the transition probabilities entirely within the transient states $\mathfrak{T}$ and $R$ is the $9 \times 8$ matrix representing the transition probabilities that start at transient states in $\mathfrak{T}$ and end in absorbing states $\mathfrak{S}.$ In particular, we have \begin{align*} Q &= \begin{pmatrix} 0 & \frac{1}{4} & 0 & \frac{1}{4} & \frac{1}{4} & 0 & \frac{1}{4} & 0 & 0 \\ 0 & 0 & \frac{1}{4} & 0 & 0 & \frac{1}{4} & \frac{1}{4} & 0 & \frac{1}{4} \\ 0 & 0 & 0 & \frac{1}{4} & 0 & 0 & 0 & \frac{1}{4} & \frac{1}{4} \\ 0 & 0 & 0 & 0 & 0 & \frac{1}{4} & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & \frac{1}{4} & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{1}{4} & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{1}{4} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \end{pmatrix} \\ R & = \begin{pmatrix} 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{1}{4} \\ \frac{1}{4} & 0 & 0 & 0 & 0 & 0 & \frac{1}{4} & \frac{1}{4} \\ 0 & \frac{1}{2} & 0 & 0 & 0 & 0 & 0 & \frac{1}{4} \\ 0 & 0 & \frac{3}{4} & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & \frac{3}{4} & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & \frac{3}{4} & 0 & \frac{1}{4} & 0 \\ 0 & 0 & 0 & 0 & 0 & \frac{3}{4} & 0 & \frac{1}{4} \end{pmatrix} \end{align*} Based on the matrix $Q,$ we can compute the fundamental matrix $$N = (I_9 - Q)^{-1} = \begin{pmatrix} 1 & \frac{1}{4} & \frac{1}{16} & \frac{17}{64} & \frac{1}{16} & \frac{33}{256} & \frac{3}{8} & \frac{49}{1024} & \frac{11}{64} \\ 0 & 1 & \frac{1}{4} & \frac{1}{16} & 0 & \frac{17}{64} & \frac{1}{16} & \frac{33}{256} & \frac{3}{8} \\ 0 & 0 & 1 & \frac{1}{4} & 0 & \frac{1}{16} & 0 & \frac{17}{64} & \frac{1}{16} \\ 0 & 0 & 0 & 1 & 0 & \frac{1}{4} & 0 & \frac{1}{16} & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & \frac{1}{4} & 0 & \frac{1}{16} \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & \frac{1}{4} & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & \frac{1}{4} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{pmatrix}.$$

Using the fundamental matrix, we can get the absorption probabilities as $$B = NR = \begin{pmatrix} \frac{17}{256} & \frac{1}{8} & \frac{49}{512} & \frac{9}{32} & \frac{147}{4096} & \frac{33}{256} & \frac{321}{4096} & \frac{3}{16} \\ \frac{1}{64} & 0 & \frac{51}{256} & \frac{3}{16} & \frac{99}{1024} & \frac{9}{32} & \frac{49}{1024} & \frac{11}{64} \\ \frac{1}{16} & 0 & \frac{3}{64} & 0 & \frac{51}{256} & \frac{3}{16} & \frac{33}{256} & \frac{3}{8} \\ \frac{1}{4} & 0 & \frac{3}{16} & 0 & \frac{3}{64} & 0 & \frac{17}{64} & \frac{1}{4} \\ 0 & \frac{1}{2} & 0 & \frac{3}{16} & 0 & \frac{3}{64} & 0 & \frac{17}{64} \\ 0 & 0 & \frac{3}{4} & 0 & \frac{3}{16} & 0 & \frac{1}{16} & 0 \\ 0 & 0 & 0 & \frac{3}{4} & 0 & \frac{3}{16} & 0 & \frac{1}{16} \\ 0 & 0 & 0 & 0 & \frac{3}{4} & 0 & \frac{1}{4} & 0 \\ 0 & 0 & 0 & 0 & 0 & \frac{3}{4} & 0 & \frac{1}{4} \end{pmatrix},$$ where $B(t,s)$ is the probability of starting at transient state $t$ and eventually absorbing into the state $s \in \mathfrak{S}.$ For the purpose of the Classic problem, we are most interested in using the first row of $B,$ that is $B_{0,s},$ which is the probability of starting with score of $0$ and ending at score $s \in \mathfrak{S}$. More specifically, the expected score of running at a constant $10$ minute miles from $5$:$55$ pm until $7$ pm is \begin{align*}E(0) = \mathbb{E}[S \mid S_0 = 0] &= \sum_{s \in \mathfrak{S}} s B(0,s)\\ &= 3 \cdot \frac{17}{256} + 3.5 \cdot \frac{1}{8} + 4 \cdot \frac{49}{512} + 4.5 \cdot \frac{9}{32} + 5 \cdot \frac{147}{4096} \\ &\quad\quad\quad+ 5.5 \cdot \frac{33}{256} + 6 \cdot \frac{321}{4096} + 6.5 \cdot \frac{3}{16} \\ &= \frac{19933}{4096} = 4.866455078125.\end{align*}

Monday, August 18, 2025

Probable Free Money

You have the same $\$55$ worth of vouchers from the casino in the same denominations. But this time, you’re not interested in guaranteed winnings. Instead, you set your betting strategy so that you will have at least a $50$ percent chance of winning $W$ dollars or more.

What is the maximum possible value of W? In other words, what is the greatest amount of money you can have at least a 50 percent chance of winning from the outset, with an appropriate strategy? And what is that betting strategy?

Ok, well to explore this space, let's first explore the distribution of optimal strategy from the Classic answer. If we assume that we first bet one on each side then almost surely we end up with $2$ remaining $\$10$ vouchers and the $\$25$ voucher remaining, but with $W = 10.$ At this point the bet is $\$20$ on heads and $\$25$ on tails, so with probability $50\%$ you end up with $2$ $\$10$ vouchers and $W=30$. At this point in this strategy you would bet one $\$10$ voucher on heads and the other on tails, to reach the state of a single $\$10$ voucher and $W=40,$ again with a total probability of $50\%$. At this point you would bet your single $\$10$ voucher over and over again until you lose, which means you can attain $W=40+10n$ with probability $$p_n = \mathbb{P}\{W = 40+10n\} = \frac{1}{2^{n+2}}.$$

On the other hand, there is another possibility when you bet the $2$ $\$10$ vouchers against the single $\$25$ voucher, which is that, with probability $50\%$ you end up with on a single $\$25$ voucher and $W=35.$ In this case, you would just choose to wager your single $\$25$ voucher over and over again until you lose. So we have $W = 35+25n$ with probability $$q_n = \mathbb{P} \{W = 35+25n\} = \frac{1}{2^{n+2}}.$$ Putting these altogether we get the full distribution $$\mathbb{P} \{ W = w \} = \begin{cases} \frac{1}{4^{n+1}}, &\text{if $w=35+50n;$}\\ \frac{1}{2\cdot 4^{n+1}} + \frac{2}{32^{n+1}} = \frac{4\cdot 8^n +2}{32^{n+1}}, &\text{if $w = 60+50n$;} \\ \frac{1}{4 \cdot 2^n}, &\text{if $w = 40+10n$ and $n \mod 5 \not\equiv 2$;}\\ 0, \text{otherwise.}\end{cases}$$ In this case, we see that $$W^* = \max \{ w \in \mathbb{N} \mid \mathbb{P} \{ W \geq w \} = \frac{1}{2} \} = 50.$$ Additionally, we confirm that since $\mathbb{P} \{W \geq 35\} = 1,$ as we surmised in the classic answer.

However, as expected, we can do way ......... better. For instance, even if you bet all of your vouchers on heads each time you have a $50\%$ probability of getting at least $\$55,$ since in that greedy strategy your probability distribution if $$\hat{\mathbb{P}} \{ W = w \} = \begin{cases} \frac{1}{2^n}, &\text{ $w = 55n$;} \\ 0, &\text{otherwise.}\end{cases}$$

However, let's combine the greediness of throwing everything on one side and hoping for the best, with the optimal strategy to ensure a high of a minimum strategy as possible. In this case, you bet all $\$55$ on heads, let's say, in the first round. If you lose, well, that sucks. But if you win then you will be at the state $(3,1,55)$ with probability $50\%.$ Again, since we are looking to maximize the the value of $\max \{ w \in \mathbb{N} \mid \mathbb{P}^* \{ W \geq w \} \geq \frac{1}{2} \}$ and we already spent $50\%$ of the probability mass on the first wager, we see that our problem has now transformed into finding the maximum guaranteed winnings based on starting at the state $(3,1,55),$ since guaranteed winning from this point would still have a greater than or equal to $50\%$ overall probability from $(3,1,0).$ Thankfully, we've already solved this problem in the Classic Fiddler, and see that the greatest amount of money you can have at least a $50$ percent chance of winning from the outset is $$V(3,1,55) = 55+35 = \$90,$$ which employs the strategy of first betting everything on one side, say heads, and then if you win the first bet, then employing the strategy from the Classic Fiddler.

Sunday, August 17, 2025

Guaranteed Free Money

A casino offers you $\$55$ worth of “free play vouchers.” You specifically receive three $\$10$ vouchers and one $\$25$ voucher.

You can play any or all vouchers on either side of an even-money game (think red vs. black in roulette, without those pesky green pockets) as many times as you want (or can). You keep the vouchers wagered on any winning bet and get a corresponding cash amount equal to the vouchers for the win. But you lose the vouchers wagered on any losing bet, with no cash award. Vouchers cannot be split into smaller amounts.

What is the guaranteed minimum amount of money you can surely win, no matter how bad your luck? And what betting strategy always gets you at least that amount?

Let $S = (S_1, S_2, W)$ be the state of the system where you currently have $S_1$ $\$10$ vouchers, $S_2$ $\$25$ vouchers and $W$ winnings in cash. Further define $V(S) = V(S_1,S_2,W)$ to be the guaranteed minimum amount of money you can surely win if you start with state $S = (S_1,S_2,W).$

We can define $V(1,0,W) = V(0,1,W) = W,$ since regardless of whether you only have one voucher left, since you cannot split the vouchers, the fair game could go against your bet and you end up with no more money than you started.

Let's now consider $V(1,1,W).$ If you were to bet one $\$10$ voucher on say heads and one $\$25$ voucher on tails, then with a $50\%$ probability you would win $\$10$ and move to the state $S^\prime = (1,0,W+10)$ and with $50\%$ probability you would win $\$25$ and move to state $\tilde{S} = (0,1,W+25)$. Since $V$ measures the guaranteed minimum winnings we have $$\tilde{V}(1,1,W) = \min \{ V(1,0,W+10), V(0,1,W+25) \} = \min \{ W + 10, W + 25 \} = W+10.$$ If we were to pick another strategy, say only wager one $\$10$ voucher on heads, then we would get $$\bar{V}(1,1,W) = \min \{ V(1,1,W+10), V(0,1,W) \} = W,$$ which is sub-optimal with respect to the strategy of betting say $\$10$ on H and $\$25% on tails. So we see that that optimal strategy gives $$V(1,1,W) = W+10.$$

For $V(2,0,W),$ the optimal guaranteed strategy is to bet one voucher on heads and another on tails, since this gives $\tilde{V}(2,0,W) = V(1,0,W+10) = W+10,$ which is better than if you only wager on one side and get $\hat{V}(2,0,W) = W.$ So we get $$V(2,0,W) = \max \{ \tilde{V}(2,0,W), \hat{V}(2,0,W) \} = W+10.$$ Similarly, we get that $$V(3,0,W) = W+20,$$ by successively wagering one voucher on heads and another on tails, twice.

For $V(2,1,W)$, an optimal guaranteed strategy is to bet, say, two $\$10$ vouchers on heads and the $\$25$ voucher on tails. This gives $$\tilde{V}(2,1,W) = \min \{ V(2,0,W+20), V(0,1,W+25) \} = \min \{ W+30, W+25 \}= W+25.$$ This is better than first betting one $\$10$ on heads and another on tails, and then $$\bar{V}(2,1,W) = V(1,1,W+10) = W+20.$$ Both of these are better than betting only one $\$10$ voucher on heads and the $\$25$ voucher on tails which gives $$\hat{V}(2,1,W) = \min \{ V(2,0,W+10), V(1,1,W+25) \} = \min \{ W +20, W+25 \} = W + 20.$$ So we have $$V(2,1,W) = \max \{ \tilde{V}(2,1,W), \hat{V}(2,1,W), \bar{V}(2,1,W) \} = W+25.$$

Finally, for $V(3,1,W),$ we have an optimal guaranteed strategy to bet one $\$10$ on heads and another on tails, and get $$\tilde{V}(3,1,W) = V(2,1,W+10) = W+35.$$ Other strategies involve betting two $\$10$ vouchers on heads and the $\$25$ voucher on tails, which equivalently gives $$\bar{V}(3,1,W) = \min \{ V(3,0,W+20), V(1,1,W+25) \} = W+35.$$ Sub-optimal strategies includes bets on only one side, or betting only on $\$10$ voucher on heads and the $\$25$ voucher on tails, which given $$\hat{V}(3,1,W) = \min \{ V(3,0,W+10), V(2,1,W+25)\} = W+30.$$ So we have $$V(3,1,W) = \max \{ \tilde{V}(3,1,W), \bar{V}(3,1,W), \hat{V}(3,1,W) \} = W+35.$$ Therefore, the guaranteed minimum amount of money you can surely win is $V(3,1,0) = \$35,$ which you can get by first betting one $\$10$ voucher on each side of the game, then in the second round betting the two remaining $\$10$ vouchers on one side of the game and the $\$25$ voucher on the other.

Monday, August 11, 2025

Coldplay Canoodling - Extra Credit

Now, everyone at the concert spends at least some time canoodling. In particular, each member of a couple wants to spend some fraction of the time canoodling, where this fraction is randomly and uniformly selected between $0$ and $1$. This value is chosen independently for the two members of each couple, and the actual time spent canoodling is the product of these values. For example, if you want to canoodle during half the concert and your partner wants to canoodle during a third of the concert, you will actually canoodle during a sixth of the concert.

Meanwhile, the camera operators love to show canoodling couples. So instead of randomly picking couples to show on the jumbotron, they randomly pick from among the currently canoodling couples. (The time shown on the jumbotron is very short, so a couple’s probability of being selected is proportional to how much time they spend canoodling.)

Looking around the concert, you notice that the kinds of couples who most frequently appear on the jumbotron aren’t constantly canoodling, since there are very few such couples. Indeed, the couples who most frequently appear on the jumbotron spend a particular fraction $C$ of the concert canoodling. What is the value of $C$?

In this Extra Credit problem, we want to find the mode of the following distribution $$f_S(C) = \mathbb{P} \{ \text{shown canoodling}, \text{canoodling ratio} = C\} = k C \mathbb{P} \{ \text{canoodling ratio} = C \},$$ where the final equation comes from the assertin that a couple's probability of being selected is proportional to how much time they spend canoodling.

Let $X, Y \sim U(0,1)$ represent the canoodling propensity of the two members of the couple, then \begin{align*} \mathbb{P} \{ \text{canoodling ratio} = C \} &= \mathbb{P} \{ X \cdot Y = C \} \\ &= \frac{d}{dC} \mathbb{P} \{ X \cdot Y \leq C \} \\ &= \frac{d}{dC} \left( \int_0^1 \int_0^{\min \{ 1, C / x \}} \,dy \, dx \right) \\ &= \frac{d}{dC} \left( \int_0^1 \min \{ 1, \frac{C}{x} \} \,dx \right) \\ &= \frac{d}{dC} \left( \int_0^C 1\,dx + \int_C^1 \frac{C}{x} dx \right) \\ &= \frac{d}{dC} \left( C - C\ln C \right) \\ &= - \ln C.\end{align*} We already have $f_S(C) = - k C \ln C,$ and though it is irrelevant for answering the question, out of an abundance of rigor (??), let's find $k.$ From the law of total probability we get $$1 = \int_0^1 f_S(C) \,dC = k \int_0^1 (- C \ln C) \,dC = \left[ -\frac{C^2}{2} \ln C \right]_{C=0}^{C=1} + \int_0^1 \frac{C^2}{2} \,\frac{dC}{C} = \frac{k}{4},$$ so $k = 4.$

So the distribution is $f_S(C) = -4 C \ln C$ and we want to find the mode of this distribution. Since $$f^\prime_S(C) = -4 \ln C -4 = -4(1 + \ln C)$$ has only one zero in $[0,1]$ and $f_S(0) = f_S(1) = 0,$ we see that the most frequently appearing canoodling ratios on the Jumbotron is $$C^* = \frac{1}{e} \approx 0.367879441171\dots,$$ which gives $$f_S(C) \leq f_S(C^*) = \frac{4}{e}, \,\forall C \in [0,1].$$

Coldplay Canoodling

All the many attendees at a particular Coldplay concert are couples. As the CEO of Astrometrics, Inc., you are in attendance with your romantic partner, who is definitely not the head of HR at Astrometrics, Inc. During the concert, the two of you spend half the time canoodling.

The camera operators love to show people on the jumbotron during the concert, but time is limited and there are many attendees. As a result, the camera operators show just $1$ percent of couples during the concert. Couples are chosen randomly, but never repeat at any given concert.

You and your partner are shy when it comes to public displays of affection. While you don’t mind being shown on the jumbotron, you don’t want to be shown canoodling on the jumbotron. How many Coldplay shows can the two of you expect to attend without having more than a $50$ percent chance of ever being shown canoodling on the jumbotron?

For the classic problem, we first want to find what the probability of not being shown on the screen canoodling during any individual concert would be. Let's say that $p_s = 1\%$ is the probability of being shown on screen during a show and $p_c=50\%$ is the probability of canoodling at any moment during a show. So the probability of not being shown while canoodling at any individual show is $P=1-p_cp_s=99.5\%.$

The probability of not being shown canoodling in any of $N$ consecutive shows is $P^N,$ so the maximum number of shows that can be attended without there being a greater than $50\%$ chance of being shown is \begin{align*}N^* &= \max \{n \in \mathbb{N} \mid P^n \geq \frac{1}{2}\}\\ &= \max \{ n \in \mathbb{N} \mid n \ln P \geq - \ln 2\}\\ &= \left\lfloor -\frac{\ln 2}{\ln P}\right\rfloor = 138\end{align*} Coldplay shows.

Monday, July 28, 2025

Tour de Fiddler 2025 - Extra Credit

Instead of one opponent, now you have two—meaning three riders in total. As luck would have it, the managers for both other riders proclaimed that they’d sprint for the finish as long as their legs were feeling 50 percent or better. Note that your opponents’ feelings are independent of each other.

As the three of you near the finish, your own team manager radios you the following message: “If your legs feel <garbled> percent or better, sprint for the finish!”

You can’t make out what the garbled part of the message is, and you’re too tired to radio back for confirmation. Instead, you somehow muster the energy to randomly, uniformly pick a number between 0 and 100 to fill in the blank from your manager’s message, thereby determining your racing strategy—optimization be damned!

Right before you choose your random strategy and test your legs, what are your chances of winning the stage against both opponents?

Similar to the classic answer, we want to let your legs be $X \sim U(0,1),$ and your two opponents be $Y, Z \sim^{\text{i.i.d.}} U(0,1).$ Let your strategy be $U_a$ such that you will sprint if and only if $X \geq a.$ Here you again will win with $100\%$ probability if you are the only one sprinting. You will never win if you are not sprinting and at least one of opponents is sprinting. Here if no one is sprinting then your win probability drops to $\frac{1}{3}$ since you each have equal probability of winning. It gets a little more complicated here if multiple people are sprinting. Obviously, if only one opponent is sprinting, then your win probability is equivalent to case where both you and your single opponent from the Classic question are sprinting, that is, $\frac{1}{2} \left(p(a) - \frac{1}{2} - \frac{a}{4}\right).$ Leaving only the more complicated problem of what happens when all of the racers are sprinting. So to summarize we have \begin{align*}\tilde{p}(a) &= \mathbb{P} \{ X \geq a, \max\{Y,Z\} \lt \frac{1}{2} \} + 0 \mathbb{P} \{ X \lt a, \max \{Y,Z\} \geq \frac{1}{2} \} \\ &\quad\quad\quad +\frac{1}{3} \mathbb{P} \{ X \lt a, \max \{Y,Z\} \lt \frac{1}{2} \} + 2 \mathbb{P} \{ X \lt a, Y \geq \frac{1}{2}, X \geq Y, Z \lt \frac{1}{2} \} \\ &\quad\quad\quad\quad +\mathbb{P} \{ X \geq a, \min \{Y, Z \} \geq \frac{1}{2}, X \geq \max\{Y, Z\} \} \\ &= \frac{1-a}{4} + 0 + \frac{a}{12} + \frac{1}{8} - \frac{1}{2}\left( \max\{a-\frac{1}{2},0\}\right)^2 + \int_a^1 \left( \int_{\frac{1}{2}}^{\max\{\frac{1}{2},x\}} \,dy \right) \left( \int_{\frac{1}{2}}^{\max\{\frac{1}{2},x\}} \,dz \right) \,dx \\ &= \frac{3}{8} - \frac{a}{6} - \frac{1}{2} \left(\max \{a-\frac{1}{2},0\}\right)^2 + \int_a^1 \left(\max{x-\frac{1}{2},0} \right)^2 \,dx \\ &= \frac{5}{12} - \frac{a}{6} - \frac{1}{2} \left( \max \{ a - \frac{1}{2}, 0 \} \right)^2 + \frac{1}{24} - \frac{1}{3} \left( \max\{a - \frac{1}{2}, 0\}\right)^3 \\ &= \begin{cases} \frac{5}{12} - \frac{a}{6}, &\text{if $0 \leq a \leq \frac{1}{2}$;}\\ \frac{1}{3} + \frac{a}{12} - \frac{a^3}{3}, &\text{if $\frac{1}{2} \lt a \leq 1$.} \end{cases}\end{align*}

Therefore, the probability of winning just before choosing the value of $a$ for your strategy is \begin{align*}\Pi = \int_0^a \tilde{p}(a) \,da &= \int_0^{\frac{1}{2}} \left(\frac{5}{12} - \frac{a}{6}\right) \,da + \int_{\frac{1}{2}}^1 \left(\frac{1}{3} + \frac{a}{12} - \frac{a^3}{3}\right) \,da \\ &= \left[ \frac{5a}{12} - \frac{a^2}{12} \right]_{a=0}^{a= \frac{1}{2}} + \left[ \frac{a}{3} + \frac{a^2}{24} - \frac{a^4}{12} \right]^{a=1}_{a = \frac{1}{2}} \\ &= \left( \frac{5}{24} - \frac{1}{48} \right) - 0 + \left( \frac{1}{3} + \frac{1}{24} - \frac{1}{12} \right) - \left( \frac{1}{6} + \frac{1}{96} - \frac{1}{192} \right) \\ &= \frac{3}{16} + \frac{7}{24} - \frac{33}{192} = \frac{36 + 56 - 33}{192} = \frac{59}{192} = 0.3072916666\dots \end{align*}

Tour de Fiddler 2025

This time around, you and a competitor are approaching the finish of a grueling stage of the Tour de Fiddler. One of you will win the stage, the other will come in second. As you approach the finish, each of you will test the feeling of your legs, which will be somewhere between 0 percent (“I can barely go on!”) and 100 percent (“I can do this all day!”). For the purposes of this puzzle, these values are chosen randomly, uniformly, and independently.

Immediately after feeling your legs, you and your opponent each have a decision to make. Do you maintain your current pace, or do you sprint to the finish? Among those who sprint for the finish, whoever’s legs are feeling the best will win the stage. But if no one sprints for the finish, everyone has an equal chance of winning the stage. In the Tour de Fiddler, you must each decide independently whether to sprint for the finish based on your legs—you don’t have time to react to your opponent’s decision.

Normally, teams at the Tour de Fiddler keep their strategy and tactics close to the vest. But earlier today, your opponent’s manager declared on international television that if your opponent’s legs were feeling 50 percent or better, they’d sprint for the finish.

As you are about to test your legs for the final sprint and see how they feel, what are your chances of winning the stage, assuming an optimal strategy?

Let's explore possible strategies that mirror our opponent. Let $U_a$ represent the strategy that if when you check your legs and sprint whenever our legs are over the level $a \in [0,1].$ Let's assume that your legs are represented by $X \sim U(0,1)$ and your opponent's legs are represented by $Y \sim U(0,1)$ and that $X$ and $Y$ are independent. Note that your win probability is $100\%$ if you sprint but your opponent does not, $0\%$ if you do not sprint but your opponent does, and $50\%$ if neither of you sprint. The only rather complicated calculation is when you both sprint. If you have chosen the strategy $U_a,$ then your win probability is given by \begin{align*}p(a) &= \mathbb{P} \{ X \geq a, Y \lt \frac{1}{2} \} + 0 \mathbb{P} \{ X \lt a, Y \geq \frac{1}{2} \} \\ &\quad\quad\quad\quad +\frac{1}{2} \mathbb{P} \{ X \lt a, Y \lt \frac{1}{2} \} + \mathbb{P} \{ X \geq a, Y \geq \frac{1}{2}, X \geq Y \}\\ &= \frac{1-a}{2} + 0 + \frac{a}{4} + \int_a^1 \int_{\frac{1}{2}}^{\max\{x,\frac{1}{2}\}} \,dy \,dx \\ &= \frac{1}{2} - \frac{a}{4} + \int_a^1 \max \{x - \frac{1}{2}, 0\} \,dx \\ &= \frac{1}{2} - \frac{a}{4} + \int_{\max\{a-\frac{1}{2},0\}}^{\frac{1}{2}} t\,dt \\ &= \frac{1}{2} - \frac{a}{4} + \frac{1}{8} - \frac{1}{2} \left( \max \{ a - \frac{1}{2}, 0 \} \right)^2 \\ &= \begin{cases} \frac{5}{8} - \frac{a}{4}, &\text{if $0 \leq a \leq \frac{1}{2}$;}\\ \frac{1}{2} + \frac{a}{4} - \frac{a^2}{2}, &\text{if $\frac{1}{2} \lt a \leq 1$.}\end{cases}\end{align*} Therefore, the optimal strategy (choice of $a \in [0,1]$) will given the maximal value of $p(a)$, which since $p$ is uniformly decreasing, occurs when $a^* = 0,$ and gives an optimal win probability of $$p^* = \max_{a \in [0,1]} p(a) = p(0) = \frac{5}{8}.$$

Monday, July 21, 2025

Was this what life was like before cell phones? Extra Credit

Instead of three total friends, now suppose there are four total friends (yourself included). As before, you all arrive at random times during the hour and each stay for 15 minutes. On average, what would you expect the maximum number of friends meeting up to be?

OK, well now your other friend Wenceslas, whose arrival time is modeled by $W \sim U(0,1),$ joins in on the "plan" to randomly meet up at the mall. In this case, we can still calculate the maximum number of friends based on $W, X, Y, Z$ to be $$\tilde{N} = \tilde{N}(W,X,Y,Z) = \max_{t \in [0,3/4]} \# \left\{ s \in \{W,X,Y,Z\} \mid t \leq s \leq t + \frac{1}{4} \right\}.$$

Here I will resort to just coding up the function $\tilde{N}$ and throwing a Monte Carlo simulator at the problem. In particular, let's define the following two functions, since we might as well also code up and confirm our earlier function $N$, while we're at it.

import numpy as np
def max_num_friends3(x,y,z):
    sort = np.sort(np.array([x,y,z]))
    d1 = sort[1]-sort[0]
    d2 = sort[2]-sort[1]
    if d1+d2 <= 0.25:
        return 3
    elif min(d1,d2) <= 0.25:
        return 2
    else:
        return 1
    
def max_num_friends4(w,x,y,z):
    sort = np.sort(np.array([w,x,y,z]))
    d1 = sort[1]-sort[0]
    d2 = sort[2]-sort[1]
    d3 = sort[3]-sort[2]
    if d1+d2+d3 <= 0.25:
        return 4
    elif (d1+d2 <=0.25) or (d2+d3 <= 0.25):
        return 3
    elif min(d1,d2,d3) <= 0.25:
        return 2
    else:
        return 1

The following Monte Carlo setup was run, generating $S=100000$ simulations for $\tilde{N}$ and $4S$ simulations for $N$ (since we can take 4 selections of three from among $W, X, Y,$ and $Z$).

sims = 100000
t = []
f = []
x = np.random.uniform(size=(sims,))
y = np.random.uniform(size=(sims,))
z = np.random.uniform(size=(sims,))
u = np.random.uniform(size=(sims,))
for i in range(sims):
    mn4 = max_num_friends4(x[i], y[i], z[i], u[i])
    f.append(mn4)
    mn3 = max_num_friends3(x[i], y[i], z[i])
    t.append(mn3)
    mn3 = max_num_friends3(u[i], y[i], z[i])
    t.append(mn3)
    mn3 = max_num_friends3(x[i], u[i], z[i])
    t.append(mn3)
    mn3 = max_num_friends3(x[i], y[i], u[i])
    t.append(mn3)

The sample average of $f$ was $m_f = 2.4752$ with sample standard deviation of $s_f = 0.59770,$ meaning that the SEM is $0.00189.$ Therefore, when there are a total of four friends randomly showing up at the mall, the 95% confidence interval on the expected maximum number of friends meeting up at one time is $2.4752 \pm 1.96 \cdot 0.00189 = [2.4715, 2.4789].$

For comparison, when there are three friends randomly showing up at the mall, the 95% confidence interval on the expected maximum number of friends meeting up at one time is $[2.029059, 2.032336],$ which contains the theoretical answer of $\mathbb{E}[N] = 65/32 = 2.03125.$

Sunday, July 20, 2025

Was this what life was like before cell phones? I don't remember anymore

You and two friends have arranged to meet at a popular downtown mall between 3 p.m. and 4 p.m. one afternoon. However, you neglected to specify a time within that one-hour window. Therefore, the three of you will be arriving at randomly selected times between 3 p.m. and 4 p.m. Once each of you arrives at the mall, you will be there for exactly 15 minutes. When the 15 minutes are up, you leave.

At some point (or points) during the hour, there will be a maximum number of friends at the mall. This maximum could be one (sad!), two, or three. On average, what would you expect this maximum number of friends to be?

Let's abstract a bit and assume that your buddy Xena, you, and second buddy Zevulon each arrive at random times $X$, $Y$, $Z$ which are i.i.d. $U(0,1).$ The maximum number of friends at any one time between 3 and 4 p.m. is $$N = N(X,Y,Z) = \begin{cases} 3, &\text{if $\max \{ |X-Y|, |X-Z|, |Y-Z| \} \leq \frac{1}{4}$;}\\ 1, &\text{if $\min \{ |X-Y|, |X-Z|, |Y-Z| \} \gt \frac{1}{4}$;}\\ 2, &\text{otherwise.}\end{cases}$$ One method for solving this problem would be to just throw some Monte Carlo simulations at this distribution, to get $\mathbb{E}[N]$; however, let's see if we can't find an analytical answer first.

Let's define $E(x,y) = \mathbb{E} [ N(X,Y,Z) \mid X=x, Y=y ].$ If we understand $E(x,y),$ then we see that $$\mathbb{E}[N] = \int_0^1 \int_0^1 E(x,y) \, dx \, dy.$$ From the symmetry of $N$ we have $$\mathbb{E}[N] = 2 \int_0^1 \int_0^x E(x,y) \, dy\, dx.$$ Now let's study the following cases:

  • $A = \{ (x,y) \in [0,1]^2 \mid 0 \leq x \leq 1, \max\{0,x-\frac{1}{4}\} \leq y \leq x \};$
  • $B = \{ (x,y) \in [0,1]^2 \mid \frac{1}{4} \leq x \leq 1, \max\{0, x - \frac{1}{2} \} \leq y \leq x - \frac{1}{4} \};$
  • $C = \{ (x,y) \in [0,1]^2 \mid \frac{1}{2} \leq x \leq 1, 0 \leq y \leq x - \frac{1}{2}\}.$

In case A, we have that $|x-y| \leq \frac{1}{4}$ already, so at the very least we have $N \geq 2$ regardless of the value of $Z \sim U(0,1)$. Furthermore, whenever $\max{0,x-\frac{1}{4}} \leq Z \leq \min \{ 1, y + \frac{1}{4} \}$ we have $N=3,$ so we must have \begin{align*}E_A(x,y) &= \mathbb{P} \{ N \geq 1 \} + \mathbb{P} \{ N \geq 2\} + \mathbb{P} \{ N \geq 3 \} \\ &= 2 + \min \{ 1, y + \frac{1}{4} \} - \max \{ 0, x - \frac{1}{4} \}.\end{align*} So let \begin{align*}I_A &= \iint_A E_A(x,y) \,dx \,dy \\ &= \int_0^1 \int_{\max \{ 0, x - \frac{1}{4} \}}^x \left( 2 + \min \{ 1, y + \frac{1}{4} \} - \max \{0, x - \frac{1}{4} \} \right) \,dy \,dx\\ &= \frac{33}{64}\end{align*}

In case B, we cannot have $N = 3,$ but depending on the value of $Z \sim U(0,1)$ we can have either $N=1$ or $N=2.$ Furthermore, we see that for $(x,y) \in B$ we have $x -\frac{1}{4} \lt y + \frac{1}{4}$ so we have $N = 2$ whenever $\max\{0, y - \frac{1}{4}\} \leq Z \leq \min \{ 1, x + \frac{1}{4} \},$ so we must have \begin{align*}E_B(x,y) &= \mathbb{P} \{ N \geq 1 \} + \mathbb{P} \{ N \geq 2\} + \mathbb{P} \{ N \geq 3 \} \\ &= 1 + \min \{ 1, x + \frac{1}{4} \} - \max \{ 0, y - \frac{1}{4} \}.\end{align*} So let \begin{align*}I_B &= \iint_B E_B(x,y) \,dx \,dy \\ &= \int_{\frac{1}{4}}^1 \int_{\max \{ 0, x - \frac{1}{2} \}}^{x-\frac{1}{4}} \left( 1 + \min \{ 1, x + \frac{1}{4} \} - \max \{0, y - \frac{1}{4} \} \right) \,dy \,dx\\ &= \frac{53}{192}\end{align*}

In case C, we cannot have $N = 3,$ but depending on the value of $Z \sim U(0,1)$ we can have either $N=1$ or $N=2.$ Furthermore, we see that for $(x,y) \in B$ we have $x -\frac{1}{4} \gt y + \frac{1}{4}$ so we have $N = 2$ whenever $$\max\{0, y - \frac{1}{4}\} \leq Z \leq y + \frac{1}{4},$$ which has probability $\min \{ \frac{1}{2}, y + \frac{1}{4} \}$, or $$x - \frac{1}{4} \leq Z \leq \min \{1, x+ \frac{1}{4}\},$$ which has probability $\min \{ \frac{1}{2}, \frac{5}{4} - x \},$ so we must have \begin{align*}E_C(x,y) &= \mathbb{P} \{ N \geq 1 \} + \mathbb{P} \{ N \geq 2\} + \mathbb{P} \{ N \geq 3 \} \\ &= 1 + \min \{ \frac{1}{2}, y + \frac{1}{4} \} + \min \{ \frac{1}{2}, \frac{5}{4}-x \}.\end{align*} So let \begin{align*}I_C &= \iint_C E_C(x,y) \,dx \,dy \\ &= \int_{\frac{1}{2}}^1 \int_{0}^{x-\frac{1}{2}} \left( 1 + \min \{ \frac{1}{2}, y + \frac{1}{4} \} + \min \{\frac{1}{2}, \frac{5}{4} -x \} \right) \,dy \,dx\\ &= \frac{43}{192}\end{align*}

So we have that the expected nmaximum number of friends is \begin{align*}\mathbb{E}[N] &= 2 \left( I_A + I_B + I_C \right)\\ &= 2 \left( \frac{33}{64} + \frac{53}{192} + \frac{43}{192} \right)\\ &= \frac{65}{32} = 2.03125\end{align*}

Sunday, July 13, 2025

Efficient bowling

If you knock down 100 pins over the course of a game, you are guaranteed to have a score that’s at least 100. But what’s the minimum total number of pins you need to knock down such that you can attain a score of at least 100?

Indeed, you can in fact obtain a score of just 100 by knocking down exactly 100 pins, for instance, by getting a total of 9 pins in each of the first 9 frames, for a score of 81, then doing ever so slightly better and bowling a 9, 1, and 9 in the 10th frame. Note that in the last frame you don't really end up getting any "bonus" points than the number of pins that you knock down (you knocked down a total of 19 pins and your score went up by 19 points).

On the other hand, consecutive strikes gives you the most amount of bonus points, so let's look at how much points you end up with by hitting $n \leq 10$ strikes in a row and then getting all gutterballs ($0$'s) for the rest of the game. With the trailing gutterballs the last strike is score as just 10 points. The second-to-last strike (if applicable) gets only 10 points of bonus from the last strike and then a gutterball, so it's score is 20 points. Any strike before the second to last one receives a full 30 points since it is followed by two trailing strikes. So the score of $n$ consecutive strikes followed by gutterballs is \begin{align*}X_n &= 10 + 20 \min \{ 1, \max \{ n- 1, 0 \} \} + 30 \max \{ n-2, 0 \} \\ &= \begin{cases} 10, &\text{if $n=1$}\\ 30(n-1), &\text{if $n = 2, 3, \dots, 10.$}\end{cases}\end{align*} At this point we can stop for the purpose of the Classic Fiddler, but just for completeness, if we have 11 strikes in a row followed by a gutterball, we have $X_{11} = 290,$ and a perfect 12 strikes yields $X_{12} = 300.$ So we see that we can certainly get more than 100 by getting 5 consecutive strikes, but probably need 4 consecutive strikes plus some other trailing pins to most efficiently get to 100.

Let's assume that our first 4 frames were strikes, and let's assume that we are being efficient and want to take frames 6 through 10 off by devising ever more childish ways of gutterballing or foot faulting or other bowling alley hijinx. In this case the outcome of our total score depends on the values of our two balls in frame 5, say $b_1$ and $b_2.$ In particular, the final score for frame 3 will be $20+b_1,$ while the final score for frame 4 will be $10+b_1+b_2,$ and the score for frame 5 will be $b_1+b_2,$ so the overal final score of your entire round is $$S(b_1,b_2) = 60 + (20+b_1) + (10+b_1+b_2) + (b_1+b_2) = 90 + 3b_1 + 2b_2,$$ since the first two frames will have already been scored at their maximal values of 30, each. Here we want to then solve the integer linear program \begin{align*}\min \,\, & b_1+b_2 \\ \text{s.t.} \,\, & 3b_1 + 2b_2 = 10 \\ & b_1, b_2 \in \{0,1,2,3,4,5,6,7,8,9\}.\end{align*} There are really only two possible feasible integer solutions to choose from $b_1 = b_2 = 2$ and $b_1 = 0$, $b_2 = 5,$ so it is easy to determine that in fact $\hat{b}_1=\hat{b}_2=2$ is the optimal solution so that the minimum number of pins you need to knock down to attain a score of 100 is 44 pins.