# Does batting order matter in Major League Baseball? A simulation approach

If you’ve ever watched Major League Baseball, one of the feature points of the sport is the batting line-up that each team decides upon before each game. Traditional baseball logic tells us that speedy, reliable hitters like Trea Turner should lead the line-up of batters; slower, power hitting juggernauts like Giancarlo Stanton should make up the middle of the line-up; and the less-than-stellar, oh-god-why-is-this-person-even-trying sluggers like Bartolo Colon should fill in the back of the order. Perhaps you’ve wondered, like myself: How did we arrive at these rules of thumb? Since every batter gets several chances at the plate anyway—and it’s not like we start every inning at the top of the batting order—does batting order even matter?

Many pitchers, like Bartolo Colon, aren’t known to be very good at batting.

In today’s post, I want to take a simulation-based approach to learn whether batting order matters in Major League Baseball. If we hold everything equal, and all of the batters in our batting line-up hit equally well, will our team perform better if we design the batting order in a particular way? If we introduce a star batter to that team, does it matter where he lines up? Or if we introduce a poor batter to that team, does their position in the line-up matter?

In the following sections, I’m going to walk through several data visualizations that summarize the results of 55 million simulated baseball games. These are all simplified baseball simulations, of course, as I don’t have the funding nor development effort of a game studio to replicate a full baseball simulation.

Regardless, I’ve simulated baseball games where 9 batters make successful hits according to a pre-determined Batting Average (BA) and make singles (64% of all hits), doubles (20%), triples (2%), and home runs (14%) according to league averages. When 3 outs are made in an inning by the defense, the bases are cleared and the next inning picks up in the batting order where the previous inning left off. All the while during each 9-inning simulation, I track batting statistics and total runs scored by the team, which I visualize below. If you’d like to take a look at the simulation underlying these visualizations—or better yet, if you’d like to improve the simulation by contributing some code—you can find the Python simulation code on my GitHub repository here.

### Does it matter where the good batter lines up?

If we have 8 average batters and 1 exceptionally good batter, does it matter where the good batter lines up? Say we have Nelson Cruz lining up with a team of Daniel Descalso clones, where in the batting order would you place Cruz?

In this simulation, I created a line-up of 8 clone batters and 1 exceptionally good batter that stands in as the “Designated Hitter” (DH) hitting a 0.35 BA. The 8 clone batters are assigned a range of batting performance on the y-axis, ranging from extremely poor (0.1 BA) to exceptionally good hitting (0.35 BA). In the following chart, we look at the relative number of runs scored by the team according to the corresponding team BA and the DH’s batting position. On the x-axis, we see the effect of moving the DH to different positions in the line-up. 1.0 (white) means that the team achieves an average number of runs, below 1.0 (orange) means that the team achieves fewer runs, and above 1.0 (purple) means that the team achieves more runs.

Note that these values are normalized separately for every Team BA, so we should only compare between DH batting positions here, and not between Team BAs. As we might expect, teams with a higher BA will always score more runs, so those comparisons are pointless.

The effect of batting order is immediately noticeable: The better the DH hits compared to their team, the more important it is for the DH to line up near the beginning of the batting order.

Interestingly, when the team bats nearly as well as the DH (Team BA=0.3 and higher), batting order doesn’t matter at all. (For the stats nerds: None of the differences across BA=0.35 are statistically significant according to a Wilcoxon rank sum test.) Yet as the disparity in batting ability increases, teams that place the DH at the top of the batting order will score more runs over the season.

### Does it matter where the pitcher lines up?

What if we have the opposite situation where we have an exceptionally poor batter? Say we have Bartolo Colon lining up with that same team of Daniel Descalso clones, where in the batting order would you place Colon? (My favorite answer so far: Make 9 Bartolo Colon clones and watch the hilarity that ensues when they try to make a hit.)

In this simulation, I created a line-up of 8 clone batters and 1 extremely poor batter that stands in as the “Pitcher” hitting a 0.1 BA. The 8 clone batters are assigned a range of batting performance on the y-axis, ranging from extremely poor (0.1 BA) to exceptionally good hitting (0.35 BA). In the following chart, we look at the relative number of runs scored by the team according to the corresponding team BA and the Pitcher’s batting position. On the x-axis, we see the effect of moving the Pitcher to different positions in the line-up. Again, 1.0 (white) means that the team achieves an average number of runs, below 1.0 (orange) means that the team achieves fewer runs, and above 1.0 (purple) means that the team achieves more runs.

Note that these values are normalized separately for every Team BA, so we should only compare between Pitcher batting positions here, and not between Team BAs. As we might expect, teams with a higher BA will always score more runs, so those comparisons are pointless.

Now we see the complete opposite effect of the DH: The worse the Pitcher hits compared to their team, the more important it is for them to hit last in the batting order.

To summarize these two discoveries, I ran one more set of baseball simulations where 8 batters hit with a BA of 0.25, and a “Hitter” has a varying BA (y-axis) and batting position (x-axis). You can read the chart below the same as the previous two charts.

It seems the “lead with your best, finish with your worst” baseball mantra is supported by these simulations. However, it’s important to note the magnitude of the effect here.

In the case of the worst Hitter (BA=0.1), the team that places the poor Hitter last in the batting order will score about 2.7% more runs in a season than the team that leads with the poor Hitter.

Likewise in the case of the best Hitter (BA=0.35), the team that leads with the best Hitter will score about 1.6% more runs in a season than the team that finishes with the best Hitter.

In both cases, the increased runs scored are statistically significant (according to a Wilcoxon rank sum test, p<1e-5), but the effects of batting order are fairly small. Regardless, in any competitive sport you need to take advantage of any benefit that you can gain over your competition—and a dozen or so extra runs can mean a few more wins that year—which is why so much effort goes into designing batting orders in Major League Baseball.

### Why does batting order matter?

In the above sections, hopefully I’ve convinced you that batting order matters when you have an exceptionally good or poor batter on your team. Yet perhaps the biggest question of all remains: Why does batting order matter? Every batter has the same opportunity to make their contributions at the plate, and in the case of my simulations, everyone except 1 batter hits with exactly the same BA. What’s going on?

To answer that question, we return to the first set of simulations where I simulated a team of equally-performing batters. This time, we’re working with a full line-up of Daniel Descalso clones: All reliable contributors hitting a 0.25 BA, but none of them standing out on the team. If we kept all of the clones at the same position for 1 million games and batting order didn’t matter, no clone should perform better than the other clones, right?

Wrong.

The simple answer is that not every batter in the line-up has the same opportunity to contribute, even in the case where all 9 batters hit with exactly the same BA.

Barring special circumstances, all batters are more-or-less guaranteed 3 At Bats per game, even in the case where no batter makes a successful hit. However, as soon as one of the batters makes a successful hit, the first batter in the line-up is guaranteed a 4th At Bat. Same thing for the second batter in the line-up when the next hit is made, and so on.

These small differences in At Bat opportunities add up to the point that Daniel Descalso clone #1 will have roughly 142 more At Bats than Daniel Descalso clone #9 over the course of the season—nearly 1 additional At Bat per game in a season! The findings in the earlier sections should all make sense now: If we have an exceptionally good batter, we want them to bat as much as possible. Likewise, if we have an exceptionally poor batter, we want them to bat as little as possible.

If At Bat opportunities were the whole answer to the batting order question, then what about middle batters? If all we care about is giving our best batters the most At Bat opportunities, why bother with placing heavy home run hitters at the 4th and 5th positions? Of course, At Bat opportunities aren’t the whole answer; it also matters how many teammates are on base when the batter comes up to the plate.

If we analyze the same 1 million games from the above section, we’ll make an interesting finding: Daniel Descalso clone #4 will see, on average, more of his teammates on base when he goes up to bat than any other Daniel Descalso clone. As a direct consequence, Daniel Descalso clone #4 will also contribute more RBI per game:

This advantage to Daniel Descalso clone #4 is primarily conferred from the 1st inning, where he’s highly likely to have a teammate on base if he goes to bat in the 1st inning. Daniel Descalso clone #5 and beyond will have a similar guarantee, but it becomes increasingly unlikely to make it beyond the 4th batter in the 1st inning. After the 1st inning, there are no such guarantees in the batting order.

Thus, it benefits the team to put a batter in the 4th position that is most likely to score a RBI in the 1st inning—even if their teammate is on 1st base. In other words: a power hitter that can hit home runs. Although the effect may again seem small, Daniel Descalso clone #4 will contribute 8 more RBI than Daniel Descalso clone #9 over the course of the season, even in these simulations where all 9 clones are batting with the exact same BA. As such, the 4th position is another area that can be planned around to maximize a team’s run-producing potential, and any competitive team should take advantage of that fact.

There’s an additional layer of strategy beyond what I’ve simulated here. In the real world, not all players bat equally well, and teams will fill the first 3 batting positions with high BA batters that can get on base. This strategy only amplifies the RBI-producing potential of the 4th batter, and tends to produce more chains of successful hits that set up the 4th batter with players on base. For now, I’ll leave those simulations for a future article.

### Bonus: Grand Slams

While analyzing the 1 million games from the previous section, I also wanted to take a look at Grand Slam probability. For a batter to hit a Grand Slam, their teammates must fill the bases and leave at least 1 out remaining, and the batter must hit a home run. It should be no surprise that Grand Slams are incredibly rare in baseball, and make for exciting and game-altering plays. For example, David Ortiz’s Grand Slam in the 8th inning of game 2 of the 2013 ALCS brought the Red Sox back into the game from a 5-1 deficit, and made it possible for the Red Sox to clutch victory from the jaws of nearly guaranteed defeat.

Interestingly, if we take a look at the batting statistics from the Daniel Descalso clone simulations, we find that Daniel Descalso clone #6 will walk up to more Bases Loaded situations than his teammates:

And following from that, Daniel Descalso clone #6 will hit more Grand Slams than his teammates:

Over time, Daniel Descalso clone #6 is roughly 40% more likely to hit a Grand Slam than his teammates that hit with the exact same BA. Grand Slams are so rare that it’s likely not worthwhile to design a batting order around this finding, but I found it surprising that even Grand Slam probability is affected by batting order.

So there you have it: Batting order definitely matters in Major League Baseball, and even basic simulations confirm conventional baseball wisdom. There’s a lot more that we can learn from these baseball simulations, but I’d like to hear your thoughts first.

I hope you enjoyed reading this article as much as I enjoyed working on it. If you’d like to run your own baseball simulations, you can find my Python code on GitHub here. If you have any comments or questions about the simulations, add them to the comments below.

Dr. Randy Olson is an AI Scientist at Absci using data science and deep learning to make medicines better and make better medicines.

Tagged with: , , , ,