Modeling A College Football Season

Modeling A College Football Season

I saw a fun 𝕏\mathbb{X}eet today. Imagine that each of the 134 NCAA FBS teams start out controlling a “territory” around their home stadium. Whenever a team loses a game, they cede their land to the team that beat them. Can you write a program that returns the vector of probabilities that a given territory is owned by any one of the 134 teams at the end of the season? If we generate mock strength projections and schedules It’s pretty easy to express in just a few lines of code.

...
import numpy as np
import numpy.random as rnd

def softmax_win_probability(a, b): # any win prob. model will do...
    return np.exp(a) / (np.exp(a) + np.exp(b))

def new_week(n): # stand-in for reading real schedules from some backend...
    week_mask = np.zeros((n, n))
    games = rnd.permutation(range(n)).reshape(n//2, 2)
    for (i, j) in games:
        week_mask[i, j], week_mask[j, i] = 1, 1
    return week_mask

n_t, n_w = 134, 12
ratings = rnd.exponential(1, size=(1, n_t)) # assign rand exponentially distr. ratings...
W = np.concat([np.ones(1), np.zeros(n_t - 1)]) # assign territory in question to `team_0` w.l.o.g
prob_w = softmax_win_probability(ratings.T, ratings)

for _ in range(n_w):
    week_mask = new_week(n_t) # generate week of match-ups, assign 67 rand pairs...
    O = W @ week_mask
    W = (week_mask * prob_w) @ (W + O)

# That's it - `W` is our probability vector...
# median territory winners have rating ~3.8 (~97th perc. among all ratings)
for i, p_own in sorted(enumerate(W), key=lambda _: _[1], reverse=True):
    print(f"rating: {ratings[0][i]:.4f} \t p(win): {p_own:.4f}")