Monday, February 26, 2024

I come to bury the Niners, not to praise them

Football is complicated, so let’s assume a simplified scoring model. Every time your team is on offense, suppose there’s a 1-in-3 chance they score a touchdown (which we’ll say is worth a total of 7 points, as we won’t bother with 2-point conversions here), a 1-in-3 chance they score a field goal (worth 3 points), and a 1-in-3 chance they don’t score any points (i.e., they punt or turn the ball over on downs). After any of these three things happens, your team will then be on defense and the other team will have the same scoring probabilities.

Now, here’s how overtime will work: Your team is on offense first. No matter how many points your team does or does not score, the other team then gets a chance at offense. If the game is still tied beyond this point, the teams will continue alternating between offense and defense. Whichever team scores next wins immediately. Again, your team is on offense first. What is your team’s probability of winning?

In this first model, each team has a probability $p_0$ of scoring no points, $p_3$ of scoring 3 points, and $p_7$ of scoring 7 points, with $p_0 + p_3 + p_7 = 1.$ Though, I suppose, you don't hope to get there, let's first analyze what happens if you end up getting to sudden death.

The probability of you winning in sudden death in your first possession of sudden death is $p_3 + p_7 = 1-p_0.$ Of course the only way that you could get to a second possession in sudden death is to first score nothing (with probability $p_0$) and have you opponent also score nothing (with probability $p_0$), and then to score with probability $1-p_0$. That is, the probability of scoring in sudden death on your second possession is $p_0^2 (1-p_0).$ Similarly, we can reason that the probability of winning on your $k$th possession in sudden death must by $(k-1)$ rounds of both teams not scoring, then you scoring in the $k$th possession, for a probability of $p_0^{2(k-1)}(1-p_0).$ Adding this all up, the probability of you winning in sudden death conditional on making it to sudden death is $$p_{SD} = \mathbb{P} \{ W \mid SD \} = \sum_{k=1}^\infty p_0^{2(k-1)} (1-p_0) = \frac{1-p_0}{1-p_0^2} = \frac{1}{1+p_0}.$$

If your first drive ends in scoring $7$, then there are two outcomes based on your opponent's outcomes, either (a) your opponent scores less than $7$, with probability $p_0 + p_3$, and you win; or (b) you enter sudden death, with probability $p_7$. So the probability of winning conditional on scoring a TD in your first drive is $$\Pi_7 = \mathbb{P} \{ W \mid 7 \} = p_0 + p_3 + p_7 p_{SD} = p_0 + p_3 + \frac{p_7}{1+p_0}.$$

If your first drive ends in scoring $3$, then there are three outcomes based on your opponent's outcomes, either (a) your opponent scores zero, with probability $p_0$, and you win; or (b) you enter sudden death, with probability $p_3$; or (c) your opponent scores 7, with probability $p_7,$ and you lose. So the probability of you winning conditional on scoring a FG in your first drive is $$\Pi_3 = \mathbb{P} \{ W \mid 3 \} = p_0 + p_3 p_{SD} = p_0 + \frac{p_3}{1 + p_0}.$$

If you don't score in your first drive, then you either (a) lose, with probability $p_3 + p_7$; or (b) enter into sudden death, with probability $p_0$. So the probability of you winning conditional on not scoring in your first drive is $$\Pi_0 = \mathbb{P} \{ W \mid 0 \} = p_0 p_{SD} = \frac{p_0}{1+p_0}.$$

Putting these all together, you have a total probability of winning if you go first of $$\Pi (p_0, p_3, p_7) = p_0 \Pi_0 + p_3 \Pi_3 + p_7 \Pi_7 = p_0p_3 + p_0p_7 + p_3p_7 + \frac{p_0^2 + p_3^2 + p_7^2}{1 + p_0}.$$ In this case, if, as in our toy model, we have $p_0 = p_3 = p_7 = \frac{1}{3}$, then the probability of winning if you go first is $$\Pi = \Pi(\frac{1}{3}, \frac{1}{3}, \frac{1}{3}) = \frac{1}{3^2} + \frac{1}{3^2} + \frac{1}{3^2} + \frac{\frac{1}{3^2} + \frac{1}{3^2} + \frac{1}{3^2}}{1 + \frac{1}{3}} = \frac{1}{3} + \frac{1}{4} = \frac{7}{12}.$$

Let's add this complexity to the model: When either team is on offense, they now have a choice. They can still opt for a strategy that results in 7 points, 3 points, or 0 points, each with a 1-in-3 chance. Alternatively, they can opt for a more aggressive strategy that results in 7 points or 0 points, each with a 1-in-2 chance.

Your team remains on offense first. Assuming both teams play to maximize their own chances of Super Bowl victory, now what is your team’s probability of winning?

So let's introduce $\tilde{p}_7,$ which is the probability of a TD under the aggressive offensive strategy, and $\tilde{p}_0 = 1 - \tilde{p}_7,$ which is the probability of not scoring under the aggressive offensive strategy. Let's first confirm that the probability of winning conditional on getting to sudden death in the more complicated model, $\tilde{p}_{SD},$ remains the same as before ( that is $\tilde{p}_{SD} = p_{SD})$), if and only if $p_3 + p_7 \geq \tilde{p}_7.$ If the parameters are such that rather $\tilde{p}_7 \gt p_3 + p_7,$ then we have $\tilde{p}_{SD} = \frac{1}{1+\tilde{p}_0},$ that is, $$\tilde{p}_{SD} = \frac{1}{1 + \min \{ p_0, \tilde{p}_0 \} }.$$

So let's now go through the various cases. If you score a TD in your first drive, then your opponent will win with probability $\tilde{p}_7 ( 1 - \tilde{p}_{SD} )$ and lose with probability $\tilde{p}_0 + \tilde{p}_7\tilde{p}_{SD}$ when he pursues the aggressive strategy. If he goes with the standard strategy, he will win with probability $p_7 (1 - \tilde{p}_{SD})$ and lose with probability $p_0 + p_3 + p_7 \tilde{p}_{SD}.$ So since your opponent will chose his own maximal winning probability that is equivalent to your minimal winning probability, so your probability of winning if you score a TD in your first drive if $$\tilde{\Pi}_7 = \min \{ \tilde{p}_0 + \tilde{p}_7 \tilde{p}_{SD}, p_0 + p_3 + p_7 \tilde{p}_{SD} \} = \frac{1 + \min\{\tilde{p}_0, 1-p_7\} \min \{p_0, \tilde{p}_0\}}{1 + \min \{ p_0, \tilde{p}_0 \}}.$$

If you score a FG in your first drive, then your opponent will have a $\tilde{p}_7$ chance of winning and $\tilde{p}_0$ chance of losing in the aggressive strategy. On the other hand, if using the standard strategy, your opponent will have a $p_7 + p_3 ( 1 - \tilde{p}_{SD} )$ probability of winning and a $p_0 + p_3 \tilde{p}_{SD}$ chance of losing. Thus, if you score a FG in your first drive, your probability of winning is $$\tilde{\Pi}_3 = \min \{\tilde{p}_0, p_0 + p_3\tilde{p}_{SD}\} = \min \left\{ \tilde{p}_0, \frac{1 - p_7 + p_0 \min \{p_0, \tilde{p}_0\}}{1 + \min \{p_0, \tilde{p}_0\}} \right\}.$$

If you do not score in your first drive, then your opponent will have a $p_3 + p_7 + p_0 (1 - \tilde{p}_{SD})$ probability of winning in a $p_0 \tilde{p}_{SD}$ probability of losing in the standard offense strategy. On the other hand, your opponent will have a $\tilde{p}_7 + \tilde{p}_0 (1 - \tilde{p}_{SD}) = 1 - \tilde{p}_0 \tilde{p}_{SD}$ probability of winning and $\tilde{p}_0 \tilde{p}_{SD}$ probability of losing in the aggressive strategy. So, if you don't score in your first drive your win probability is $$\tilde{\Pi}_0 = \min \{ p_0 \tilde{p}_{SD}, \tilde{p}_0 \tilde{p}_{SD} \} = \min \{p_0, \tilde{p}_0\} \tilde{p}_{SD} = \frac{\min \{p_0, \tilde{p}_0\}}{1 + \min \{ p_0, \tilde{p}_0 \} }.$$

So the total probability of winning is $$\tilde{\Pi} = \tilde{\Pi}(p_0, p_3, p_7, \tilde{p}_0, \tilde{p}_7) = \max \{ \tilde{p}_7 \tilde{\Pi}_7 + \tilde{p}_0 \tilde{\Pi}_7, p_7 \tilde{\Pi}_7 + p_3 \tilde{\Pi}_3 + p_0 \tilde{\Pi}_0 \}.$$ Given our parameters where $p_0 = p_3 = p_7 = \frac{1}{3}$ and $\tilde{p}_0 = \tilde{p}_7 = \frac{1}{2},$ the probability of winning when you go first in the updated model is \begin{align*} \tilde{\Pi}_0 &= \frac{ \min\{ \frac{1}{3}, \frac{1}{2} \} }{ 1 + \min \{ \frac{1}{3}, \frac{1}{2} \} } &= \frac{1}{4} \\ \tilde{\Pi}_3 &= \min \left\{ \frac{1}{2}, \frac{ 1- \frac{1}{3} + \frac{1}{3} \min \{ \frac{1}{3}, \frac{1}{2} \} }{ 1 + \min \{ \frac{1}{3}, \frac{1}{2} \} } \right\} &= \frac{1}{2} \\ \tilde{\Pi}_7 &= \frac{ 1 + \frac{1}{2} \min \{ \frac{1}{3}, \frac{1}{2} \} }{1 + \min \{ \frac{1}{3}, \frac{1}{2} \} } &= \frac{7}{8}\end{align*} In this case, the probability $$\tilde{\Pi} = \max \{ \frac{1}{2} \frac{7}{8} + \frac{1}{2} \frac{1}{4}, \frac{1}{3} \frac{7}{8} + \frac{1}{3} \frac{1}{2} + \frac{1}{3} \frac{1}{4} \} = \max \{ \frac{9}{16}, \frac{13}{24} \} = \frac{9}{16}.$$

Altogether this was not the dunking on the Niners and their decision that I hoped it would be, but luckily, whether the decision was correct or not, the Niners lost. That, in the end, is all that really matters!!!

Monday, February 5, 2024

Many, many, many to one function

For any positive, base-$10$ integer $N$, define $f(N)$ as the number of times you have to add up its digits until you get a one-digit number. For example, $f(23) = 1$ because $2+3 = 5$, a one-digit number. Meanwhile, $f(888) = 2,$ since $8+8+8 = 24,$ a two-digit number, and then adding up those digits gives you $2+4 = 6,$ a one-digit number. Find the smallest whole number $N$ such that $f(N) = 4.$

Clearly $\min f^{-1}(\{1\}) = 10,$ so we must figure out what the smallest integer whose base-$10$ digits sum to $10.$ In this case, we can guess and peck, and arrive at $19$. It becomes slightly harder to figure out the smallest integer whose base-$10$ digits sum to $19.$ Certainly there are no two digit numbers that sum to 19, since the maximum sum of base-$10$ digits of any two digit number is $18$. So let's look for three digit numbers $N = 100a + 10b + c$ where $a + b + c = 19,$ $a \in \{1, 2, \dots, 9\}$ and $b, c \in \{0, 1, \dots, 9\}.$ Obviously the minimal number involves $a = 1,$ where then $b=c=9.$

So we have $f(199) = 3.$ However, we want to now figure out what is the smallest integer whose base-$10$ digits sum to $199,$ since this will give us $\min f^{-1}(\{4\}).$ Since any $22$ digit number will sum to no more than $198,$ we should look for a $23$ digit number. In particular, if the first digit is a $1$ and it is followed by twenty-two $9$'s, then we would get $199$ as the sum of the digits. So, $N = 19,999,999,999,999,999,999,999$ is the smallest integer with $f(N) = 4.$

Let's enumerate the first $10,000$ values of the function $f.$ We can see that $f(N) = 0$ for $N \in \{1, 2, \dots, 9\}.$ As we saw before, $f(N) = 1$ for $N = 10, 11, dots, 18$ and then $f(19) = 2.$ Similarly, $f(N) = 1$ for $N = 20, \dots, 27$ and then $f(N) = 2$ for $N = 28$ and $N=29.$ Since, the maximum sum of the digits for of any integer $N \leq 10,000$ is $36,$ if all we wanted to do is determine which numbers in the first $10,000$ have value $f(N) = 3,$ we therefore only need to worry about numbers $N$ whose digits sum to either $19,$ $28$ or $29.$

We have already seen that, e.g., $199$ satisfies $f(199) = 3.$ By cleverly adding $90$ and $99,$ both of which preserve the total sum of digits provided that the $1000$'s digit remains unchanged, that there are $44$ other three digit numbers $N$ with $f(N) = 3,$ namely $289,$ $298,$ $379,$ $388,$ $398,$ $469,$ $478,$ $487,$ $496,$ $559,$ $568,$ $577,$ $586,$ $595,$ $649,$ $658,$ $667,$ $676,$ $685,$ $694,$ $739,$ $748,$ $757,$ $766,$ $775,$ $784,$ $793,$ $829,$ $838,$ $847,$ $856,$ $865,$ $874,$ $883,$ $892,$ $919,$ $928,$ $937,$ $946,$ $955,$ $964,$ $973,$ $982,$ and $991.$ We can continue adding other cleverly conjured addends (e.g., $900$) that preserve the sum of digits, or just let some even smarter computer run through all of the numbers for us. In the end, we get a total of $945$ integers $N$ with $1\leq N \leq 10,000$ and $f(N)=3$.