You are on page 1of 1

Chapter 12.

Stochastic Programs, Probability, and Statistics

def playSeries(numGames, teamProb):

"""Assumes numGames an odd integer,
teamProb a float between 0 and 1
Returns True if better team wins series"""
numWon = 0
for game in range(numGames):
if random.random() <= teamProb:
numWon += 1
return (numWon > numGames//2)
def simSeries(numSeries):
prob = 0.5
fracWon = []
probs = []
while prob <= 1.0:
seriesWon = 0.0
for i in range(numSeries):
if playSeries(7, prob):
seriesWon += 1
prob += 0.01
pylab.plot(probs, fracWon, linewidth = 5)
pylab.xlabel('Probability of Winning a Game')
pylab.ylabel('Probability of Winning a Series')
pylab.ylim(0.5, 1.1)
pylab.title(str(numSeries) + ' Seven-Game Series')

Figure 12.13 World Series simulation

When simSeries is used to simulate 400
seven-game series, it produces the plot
on the right. Notice that for the better
team to win 95% of the time (0.95 on the
y-axis), it needs to be more than three
times better than its opponent. That is
to say, the better team needs to win, on
average, more than three out of four
games (0.75 on the x-axis). For
comparison, in 2009, the two teams in
the World Series had regular season
winning percentages of 63.6% (New York
Yankees) and 57.4% (Philadelphia Phillies). This suggests that New York should
win about 52.5% of the games between the two teams. Our plot tells us that
even if they were to play each other in 400 seven-game series, the Yankees would
win less than 60% of the time.
Suppose we assume that these winning percentages are accurate reflections of
the relative strengths of these two teams. How many games long should the