#Colors.
C = ['#440154FF',
'#3B528BFF',
'#21908DFF',
'#5EC962FF',
'#FDE725FF']
def swingProb(N):
"""
Probability.
Parameters:
N : Number of game wins to win series.
Returns:
outcomes : (w, l)
W - probability of wins starting with 'W'.
L - probability of losses starting with 'W'
"""
W = 0
L = 0
#Wins starting with W.
#Insert 0 to N-1 Ls into N Ws.
for l in range(N) :
p = mF(N-2 + l) / (mF(N-2) * mF(l) * (2 ** (N+l-1)))
W += p
#Losses starting with W.
for w in range(N-1) :
p = mF(N-1 + w) / (mF(w) * mF(N-1) * (2 ** (w+N+1-1)))
L += p
S = mC(2*(N-1), (N-1)) / 2**(2*N-2)
return(W, L, S)
def ECPlot() :
sns.set()
#Plot.
fig = plt.figure(figsize = (12, 7))
ax = fig.add_subplot(xlim = (2, 200), ylim = (0, 75))
#Title.
ax.set_title("How Much Does Game 1 Matter?", fontsize = 24)
#x-axis.
ax.set_xlabel("Number of Wins Needed", fontsize = 18)
#y-axis.
ax.set_ylabel("Probability", fontsize = 18)
ax.yaxis.set_major_formatter(PF())
ax.tick_params(axis = 'both', labelsize = 16)
#Data
N = range(2, 200)
W = []
L = []
S = []
for n in N :
D = swingProb(n)
W.append(D[0]*100)
L.append(D[1]*100)
S.append(D[2]*100)
ax.plot(N, W, lw = 3, c = C[0], alpha = 0.4, label = "Series Win if Game 1 is a Win")
ax.plot(N, L, lw = 3, c = C[3], alpha = 0.4, label = "Series Win if Game 1 is a Loss")
ax.plot(N, S, lw = 5, c = C[1], label = "Swing Probability")
ax.legend(fontsize = '18', loc = 'upper right', bbox_to_anchor = (1, 0.5))
fig.savefig('2025.10.31EC.png', bbox_inches = "tight");