Introduction To Computation and Programming Using Python, Revised - Guttag, John v..192
The document describes a simulation of a best-of-seven series between two teams with different probabilities of winning individual games. The simulation runs multiple series to plot the probability of winning the overall series against the probability of winning a single game. It finds that to have a 95% chance of winning the series, a team needs to have around a 75% chance of winning each game. It then uses the simulation to analyze the 2009 World Series between the Yankees and Phillies based on their regular season winning percentages.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
52 views
Introduction To Computation and Programming Using Python, Revised - Guttag, John v..192
The document describes a simulation of a best-of-seven series between two teams with different probabilities of winning individual games. The simulation runs multiple series to plot the probability of winning the overall series against the probability of winning a single game. It finds that to have a 95% chance of winning the series, a team needs to have around a 75% chance of winning each game. It then uses the simulation to analyze the 2009 World Series between the Yankees and Phillies based on their regular season winning percentages.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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 fracWon.append(seriesWon/numSeries) probs.append(prob) prob += 0.01 pylab.plot(probs, fracWon, linewidth = 5) pylab.xlabel('Probability of Winning a Game') pylab.ylabel('Probability of Winning a Series') pylab.axhline(0.95) pylab.ylim(0.5, 1.1) pylab.title(str(numSeries) + ' Seven-Game Series') simSeries(400)
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