Skip to content

Instantly share code, notes, and snippets.

@BradonZhang
Last active September 22, 2023 12:34
Show Gist options
  • Save BradonZhang/a3dff887d0c44a744ca34877ed124f10 to your computer and use it in GitHub Desktop.
Save BradonZhang/a3dff887d0c44a744ca34877ed124f10 to your computer and use it in GitHub Desktop.
How Likely is a Lopsided League?

This Week's Fiddler

Because the teams have random, uniform, and independent winning chances, and because they lie on a continuous distribution, there is a strict order of winning percentages for all the teams. Thus, we can treat this as a combinatorics problem, where teams from the same division are treated as indistinguishable.

If we let C represent an Enigma League Central division team and let E represent an Enigma League East division team, we can find the probability that CCCCCEEEEE arises from all possible permutations of said letters, as this is the only configuration where all East teams have higher winning percentages than all Central teams.

As there are a total of $\frac{10!}{5!5!}=252$ possible permutations, the chance is $\frac{1}{252}$, or about 0.3968%.

Answer: 1/252

Extra Credit

When my rumination yields no destination, it's a simulation that is my salvation.

import random
from collections import defaultdict


N = 10**7
total = 0
NUM_DIVS = 6
NUM_TEAMS_PER_DIV = 5


for t in range(N):
    if t > 0 and t % 10**5 == 0:
        print(total, t, total / t)

    seen = defaultdict(lambda: 0)
    for div in random.sample(
        list(range(NUM_DIVS)) * NUM_TEAMS_PER_DIV, NUM_DIVS * NUM_TEAMS_PER_DIV
    ):
        seen[div] += 1
        if seen[div] == NUM_TEAMS_PER_DIV:
            total += len(seen) != NUM_DIVS
            break

print(total, N, total / N)

Answer: 0.0862

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment