Sunday, July 18, 2021

Shootout at the UP Corral

Italy defeated England in a heartbreaking (for England) European Championship that came down to a penalty shootout. In a shootout, teams alternate taking shots over the course of five rounds. If, at any point, a team is guaranteed to have outscored its opponent after five rounds, the shootout ends prematurely, even if each side has not yet taken five shots. If teams are tied after five rounds, they continue one round at a time until one team scores and another misses. If each player has a 70 percent chance of making any given penalty shot, then how many total shots will be taken on average?

Let $p = 0.7$ be the probability of each individual penalty shot going in. The setup of the penalty shootout lends itself to simulation, so in a moment I will fire up the old Jupyter notebook and get busy simulating since $2^{10} = 1024$ possible outcomes for the just the first $5$ rounds and I don't want to sort it all out by hand, but I will tackle part of it analytically.

Let's assume that the first $10$ penalties have ended in a tie and we are going into sudden death rounds. In this case, there will always be a multiple of $2$ shots since the first team to shoot cannot conclusively win after its shot alone. Since the shootout can only end once a round where one team scores and the other doesn't, we see that $$\mathbb{P} \{ N = 10+2k \mid N > 10 \} = 2p(1-p) (1 - 2p(1-p))^{k-1}.$$ So in particular, we have $$\mathbb{E} [ N \mid N > 10 ] = \sum_{k=1}^\infty (10 + 2k) 2p(1-p) (1 - 2p(1-p))^{k-1} = 10 + \frac{1}{p(1-p)}.$$ We can use this to simulate only the first 5 rounds of the shootout and for every simulation where the score at the end of 10 kicks is tied, we can put in the expected number of kicks in this case.

I drew a $2 \times 5$ array of Bernoulli random variables with probability $p$ and used the $1$'s as goals and $0$'s as misses. For each draw, we can determine how many kicks were needed to win the shootout (substituting the expected number of $10 + \frac{1}{p(1-p)}$ if the first 10 shots end in a tie). The average number of shots in the penalty shootout (using 100,000 simulations) is $13.02$ shots. See the Python snippet below:

SoccerIsDumbWhyNotJustKeepPlaying
In [1]:
import numpy as np
import pandas as pd
from scipy.stats import bernoulli

def num_kicks(u, max_kicks=5):
    i = 0
    stop = False
    while not stop:
        if u[i,0] > u[i,1] + (5-i):
            num_kicks = 2 * i + 1
            stop = True
        elif u[i,1] > u[i,0] + (4-i):
            num_kicks = 2 * (i + 1)
            stop = True
        elif i==max_kicks-1:
            num_kicks = 2*max_kicks+1
            stop = True
        else:
            i += 1
    return num_kicks

def calculate_mean_kicks(p, max_kicks=5, num_sims=100000):
    u = bernoulli.rvs(p, size=(max_kicks,2,num_sims))
    kicks = { k:0 for k in range(1,2 * max_kicks+2)}
    for s in range(num_sims):
        tmp = np.cumsum(u[:,:,s], axis=0)
        kicks[num_kicks(tmp,max_kicks=max_kicks)] += 1

    mean = 0
    for k, v in kicks.items():
        if k < 2 * max_kicks:
            mean += k * v
        else:
            ## The conditional expected number of kicks given that the first 10 are tied is 
            ## given by \sum_{k=1}^\infty (2*max_kicks+2*k) 2*p*(1-p)*(1-2*p*(1-p))^k = 2*max_kicks + 1/(p*(1-p))
            mean += (10 + 1/(p*(1-p))) * v
    mean /= num_sims
    print('The expected number of kicks in a penalty shootout with p={} goal probability is N={}'.format(p, mean))
    return mean

calculate_mean_kicks(0.7)
The expected number of kicks in a penalty shootout with p=0.7 goal probability is N=13.018944285714287
Out[1]:
13.018944285714287

1 comment:

  1. It seems like my num_kicks function was not quite up to snuff and distorted the distribution. For instance it only picked up half of the simulations which ended after 6 kicks (pushing the other half into the 7 kick bucket). Oh well, perhaps I will refine and repost for completeness.

    ReplyDelete