Monday, March 29, 2021

To Foul or Not to Foul?

Assume that an average team scores exactly $1$ point per offensive possession, a figure that accounts for multiple shots if the team rebounds its own miss (or misses) on a single trip, and that it rebounds $15$ percent of its own missed free throws.

Now suppose you are the coach of a team playing an average opponent that’s in the bonus. The other team has the ball, the game is tight, and you want to minimize the expected number of points your opponent will earn on this particular possession. How low does the ball-handler’s free throw shooting percentage need to be for you to instruct your team to foul that player (when they are not in the act of shooting)?

Let's let $r$ be the average team's rebounding percentage on missed free throws that are in play, and let $p$ be the ball handler's free throw percentage. In the case where you don't foul, the expected points for this possession is $1.$ So all we need to do is set up the expected points if you do foul the ball handler on the floor and figure out for what values of $p$ that expectation is less than $1$.

For the time being I will assume that you have instructed the team that if a free throw is missed then do not foul, so that we can count the expected number of points in the event that the opposing team rebounds a missed free throw as the usual expected points per offensive possession $1.$ If there is a foul, then there are five outcomes:

(i) both free throws are made, which results in $2$ additional points and has probability $p^2$;

(ii) the first free throw is made, the second one is missed and the opposing team rebounds, which results in an expected $2$ additional points and has probability $p(1-p)r$;

(iii) the first free throw is made, the second one is missed and your team rebounds, which results in $1$ additional point and has probability $p(1-p)(1-r)$;

(iv) the first free throw is missed and the opposing team rebounds, which results in an expected $1$ additional point and has probability $(1-p)r$;

and (v) the first free throw is missed and your team rebounds, which results in $0$ points and has probability $(1-p)(1-r).$


Taking the expectation, we get \begin{align*} E(p,r) &= 2p^2 + 2p(1-p)r + p(1-p)(1-r) + (1-p)r + 0(1-p)(1-r)\\ &= (2-2r-(1-r))p^2 + (2r+(1-r) -r)p + r\\ &= (1-r)p^2 + p + r. \end{align*} So, solving the quadratic, we have that it is better to foul the ball handler (assuming no subsequent fouls if the opposing team rebounds) whenever $E(p,r) \leq 1,$ or $$0 \leq p \leq \frac{-1 + \sqrt{1 + 4(1-r)^2}}{2(1-r)}.$$ When $r = 0.15$ for an average team, you should instruct your team to foul the ball handlers with free throw percentages less than or equal to $\frac{-1 + \sqrt{1 + 4 \cdot 0.85^2}}{2 \cdot 0.85} = 0.5719.$

Monday, March 22, 2021

Squaring the Circle with Charles Barkley

N.B. This post title is likely to be an even wider stretch in terms of obscure references than usual, but it is meant to evoke the recent CapitalOne ad with Charles Barkley driving Samuel L. Jackson and Spike Lee to "In-the-Annapolis" for the NCAA tournament.

The two larger squares are congruent, and the smaller square makes a 45 degree angle with one of the larger squares. Both larger squares touch the circle at one corner, while the smaller square touches the circle at two corners.

How many times greater is the area of one of the larger squares than the area of the smaller square?

Without loss of generality, let's assume that the circle has radius $1$ and is centered at the origin of the $xy$-plane. Let $x$ be the side length of the larger square and let $y$ be the side length of the smaller square. Since the two larger squares are each incident on the circle at a single point, the shared edge of the two larger squares must sit along the $y$-axis and we know that for instance the upper right corner of the uppermost larger square is at $(\sqrt{1-x^2}, x).$

Assuming the dashed line implies that the uppermost corner of the smaller square lies on the extended line between the two upper corners of upper larger square. Thus, it must lie at the point $(-\sqrt{1-x^2}, x)$. Since the isoceles right triangle bounded by the dashed line, the upper larger square and the smaller square has hypotenuse of length $y$, the length of the dashed line must be $y / \sqrt{2},$ so we have the following relation: $$x + \frac{y}{\sqrt{2}} = 2\sqrt{1-x^2}.$$

Given that the smaller square has side length $y,$ the other point of the smaller square that is incident on the circle must be at $(-\sqrt{1-x^2} - \frac{y}{\sqrt{2}}, x - \frac{y}{\sqrt{2}}).$ Since this point is incident on the circle, we must additionally have $$\left(-\sqrt{1-x^2} - \frac{y}{\sqrt{2}}\right)^2 + \left(x - \frac{y}{\sqrt{2}}\right)^2 = 1.$$ Solving for $y / \sqrt{2}$ in the first equation and plugging into the second we see \begin{align*} 1 &= (x-3\sqrt{1-x^2})^2 + 4(x - \sqrt{1-x^2})^2\\ &= x^2 - 6x\sqrt{1-x^2} + 9(1-x^2) + 4(1 - 2x\sqrt{1-x^2} + (1-x^2))\\ &= 13 - 14x\sqrt{1-x^2} -8x^2, \end{align*} or equivalently $$49x^2(1-x^2) = 36 - 48x^2 + 16x^4 \,\,\Rightarrow\,\, 0 = 36 - 97x^2 + 65x^4.$$ Solving the quadratic equation we get $$x^2 = \frac{97 \pm \sqrt{97^2 - 4 \cdot 65 \cdot 36}}{2 \cdot 65} = \frac{97 \pm 7}{130}.$$ Ignoring nonsensical negative values, we get that $x_\pm = \sqrt{ \frac{97 \pm 7}{130} },$ which implies that $$y_\pm = \sqrt{2} \left( 2 \sqrt{1 - \frac{97 \pm 7}{130}} - \sqrt{ \frac{97 \pm 7}{130}} \right) = \frac{1}{\sqrt{65}} \left( \sqrt{132 \mp 28} - \sqrt{97 \pm 7} \right).$$ So in particular, when $x = x_+ = \sqrt{\frac{104}{130}} = \frac{2}{\sqrt{5}}$ implies a value of $$y = y_+ = \frac{\sqrt{104} - \sqrt{104}}{\sqrt{65}} = 0,$$ which doesn't seem to be the answer we were looking for. However, when $x = x_- = \sqrt{\frac{90}{130}} = \frac{3}{\sqrt{13}},$ we have $$y = y_- = \frac{\sqrt{160} - \sqrt{90}}{\sqrt{65}} = \frac{4\sqrt{10} - 3\sqrt{10}}{\sqrt{65}} = \frac{\sqrt{2}}{\sqrt{13}},$$ which makes one of the larger squares $(x / y)^2 = 4.5$ times larger than the smaller sqaure.

Schroedinger's crying baby, revisited

Once again, you are working in an adjacent room when your partner walks out and hands you the baby monitor. You completely lose track of where in the day this happens. You continue working for another $30$ minutes, and this time you do not hear the baby cry. What is the probability that the next time your baby cries they will be hungry?

Now your baby allows you to get at least $30$ minutes of work in, so we know that either: (a) the parental handoff was in the first half hour of one of the $4$ playtimes, in which case the baby's next cry will be for sleep; or, (b) the parental handoff was in the first $1.5$ hours of the one of the $4$ naptimes, in which case the baby's next cry will be for food. This gives a $3:1$ ratio of cry for hunger versus cry for sleep, so the probability that the next time your baby cries will be for hunger is $75\%$.

In this mode, if you work $t$ hours (for some $t \lt 1$) without hearing the baby cry, then the handoff could have happened in the first $2-t$ hours of one of the naptimes, or in the $1-t$ hours of one of the playtimes. If you are able to work for $t \in (1,2)$ hours then again you have $100\%$ clarity that your baby's next cry will be from hunger. So the probability that the next time your baby cries for hunger given that you've already worked $t$ hours without crying is $$p(t) = \frac{2-t}{2 - t + \max\{0,1-t\}},$$ for $t \in [0,2].$

Monday, March 15, 2021

Schroedinger's crying baby

Suppose you have an infant who naps peacefully for two hours at a time and then wakes up, crying, due to hunger. After eating quickly, the infant plays alone for another hour, and then cries due to tiredness. This cycle repeats several times over the course of a $12$-hour day. (Your rock star baby sleeps peacefully $12$ hours through the night.)

You’re working in an adjacent room when your partner walks out and hands you the baby monitor. You’ve completely lost track where in the day this happens. You continue working for another $30$ minutes, then you hear the baby cry. What’s the probability that your baby is hungry?

Let's assume that by the $12$-hour "day", we mean that there are $4$ consecutive rounds of: (i) waking up from sleep due to hunger, instantaneously eating, then playing for one hour and then (ii) instantaneously falling asleep (what's your secret?) and sleeping for $2$ hours. The only wrinkly is that I suppose after that fourth nap, the baby just wakes up from hunger, instantaneously eats and then magically sleeps $12$ hours until the next "day".

Given that you were only able to sneak in an additional half an hour of work after the baby monitor handoff and that both the sleep and play periods are greater than half an hour in length, there is nothing distinguishing cries for hunger after sleep from cried for sleep after play.

Assuming that one could "lose track where in the day this happens" within the first half hour of the day, which is totally feasible given the new baby, there are an equal number of times when the baby cries for hunger versus cries for sleep. Therefore, the probability that the baby is crying due to hunger after napping is $50\%$.

Of note, this $50\% - 50\%$ answer would remain the same for any amount of work $t \lt 1$ hour, but if you are able sneak in some amount of work $1 \lt t \lt 2$ hours then you know with perfect clarity that the baby is crying. Further, if $t \gt 2$ hours then you know that you have somehow been working all night or that you have missed at least one cry and have a very unhappy baby and/or spouse. I'm not totally sure what to do with the boundaries when $t=1$ or $t=2$: Can your spouse hand you the baby monitor while simultaneously feeding the instantaneously eating baby or putting the instantaneously sleeping baby down for its nap? The potential quantum superpositions literally (milk) bottle the mind!

It's Pi Day, Pi Day, Gotta get down on Pi Day!

This Sunday, March 14, is Pi Day! To celebrate, you are planning to bake a pie. You have a sheet of crust laid out in front of you. After baking, your pie crust will be a cylinder of uniform thickness (or rather, thinness) with delicious filling inside.

To maximize the volume of your pie, what fraction of your crust should you use to make the circular base (i.e., the bottom) of the pie?

Assume that you have a thin sheet of area $A$ that is malleable and reformable, such that we can form the crust around any particular circular cylinder with surface area less than or equal to $A.$ In order to avoid any Monty Python-esque Bridge of Death ambiguity issues with the air speed of unladen one-crusted or two-crusted pies, we shall get the answer for each by defining the surface are of a $k$-crusted cylindrical pie as $$S_k(r,h) = 2\pi r h + k \pi r^2,$$ for $k = 1, 2.$ Then the solution will be $\frac{\pi (r^*_k)^2}{A},$ where $(r^*_k, h^*_k)$ is a solution to \begin{align*} \max_{r, h} \,\, & \pi r^2 h\\ \text{s.t.} \,\, & S_k(r,h) \leq A\\ & r, h \geq 0 \end{align*}

We can reduce this problem by noting that the surface area inequality will be active at any solution and then eliminating on of the variables. For instance, let $h_k = h_k(r)$ be defined such that $S_k(r,h_k(r)) = A,$ that is $$h_k = \frac{A - k \pi r^2}{2\pi r}.$$ Then, since the volume reduces to $V_k(r) = \pi r^2 h_k(r) = \frac{1}{2} r (A - k \pi r^2) = \frac{A}{2} r - \frac{k}{2} \pi r^3,$ the optimization problem becomes $\max \{ V_k(r) \mid r \geq 0 \},$ which we can solve using elementary calculus methods: $$\frac{d}{dr} V_k(r^*_k) = \frac{A}{2} - \frac{3k}{2} \pi (r^*_k)^2 = 0 \,\, \Rightarrow r^*_k = \sqrt{\frac{A}{3k\pi}}.$$

Therefore, the circular base of the maximal $k$-crusted cylindrical pies should be $\frac{1}{3k}$ of the overall area of the pie crust sheet.

Sunday, March 7, 2021

A feat even Mike Trout can't manage ...

Suppose a baseball player has four at-bats per game (not including walks), so their batting average is the number of hits they got divided by four times the number of games they played. For many games, it’s possible to have a corresponding batting average that, when rounded to three digits, equals the number of games divided by 1,000. For example, if a player typically gets one hit per game in their at-bats, then they could very well have a .250 average over 250 games.


Again assuming $4$ AB per game, what is the greatest number of games for which it is not possible to have a matching rounded batting average?


My initial flippant reaction was $\infty,$ since it is obviously impossible to get a batting average over $1.000$ and so one cannot have a batting average over the past $n$ games equal to $n/1000$ for any $n \geq 1001.$ However, after a quick consultation with Riddlermeister Zach Wissner-Gross, it was deemed that the "greatest number of games ($\leq 1000$)" was roughly implied.


So with actual work to be done then, let's define the problem. For any number of games $N \leq 1000,$ we would need to check whether there is an integer $m \leq 4N$ such that $$\left\lfloor \frac{250m}{N} \right\rceil = N,$$ where $\lfloor x \rceil$ is the $x$ rounded to nearest integer. If we ignore the rounding, we would expect that that integer $m$ should be approximately $m \approx \frac{N^2}{250},$ so we should really only need to check whether $\left\lfloor \frac{N^2}{250} \right\rfloor$ and $\left\lceil \frac{N^2}{250} \right\rceil$ work. For larger values of $N,$ there may be additional values of $m$ that might work (e.g., any number of hits $m$ with $3991 \leq m \leq 3994$ will suffice for the obscene average of $0.999$ over the past $999$ games), but certainly if there is some integer $m$ solution than one of those two will work. Without any real care for optimizing, we can use a simple Python list comprehension to obtain that there are 128 such values of $N (\leq 1000)$ that cannot produce a matching rounded batting average and that the largest one is $N=239$.

MikeTrout
In [1]:
import numpy as np
nonround_ba = [n for n in range(1, 1001) if min([np.abs(np.round(np.floor(n*n/250)/(4*n),3) - n/1000),\
                                              np.abs(np.round(np.ceil(n*n/250)/(4*n),3) - n/1000),]) > 0]
print('''There are %d values of N that cannot produce a rounded batting average assuming 4 AB per game, 
the largest of which is %d''' % (len(nonround_ba), max(nonround_ba)))
There are 128 values of N that cannot produce a rounded batting average assuming 4 AB per game, 
the largest of which is 239