# Optimal baseball lineup

This week’s Fiddler is a problem about how to set the optimal baseball lineup.

Eight of your nine batters are “pure contact” hitters. One-third of the time, each of them gets a single, advancing any runners already on base by exactly one base. (The only way to score is with a single with a runner on 3rd). The other two-thirds of the time, they record an out, and no runners advance to the next base. Your ninth batter is the slugger. One-tenth of the time, he hits a home run. But the remaining nine-tenths of the time, he strikes out. Your goal is to score as many runs as possible, on average, in the first inning. Where in your lineup (first, second, third, etc.) should you place your home run slugger?

Extra Credit: Instead of scoring as many runs as possible in the first inning, you now want to score as many runs as possible over the course of nine innings. What’s more, instead of just having one home run slugger, you now have two sluggers in your lineup. The other seven batters remain pure contact hitters. Where in the lineup should you place your two sluggers to maximize the average number of runs scored over nine innings?

My solution:
[Show Solution]

## 6 thoughts on “Optimal baseball lineup”

1. Ari says:

Are you sure you did not put in p=2/3 instead of 1/3? The problem stated, “One-third of the time, each of them gets a single, advancing any runners already on base by exactly one base.”

I could not come up with an analytic solution but wrote up a Monte Carlo simulation of an inning.
[Code](https://abiswas3.github.io/notes/html_files/2023-08-21-Bazball.html)

The answer seems to be to put the slugger last when the singles happen with probability 2/3 but put the slugger fourth if the singles happen with probability 1/3.

I could be wrong as this code was written on a train back home from Warwick.

1. I think your code is correct. I found the bug in my code (a small off-by-one error which dramatically changed the final result…). I fixed it now, and my analytical results match your numerical results. Thanks!

1. Mark says:

Hi Laurent, can you share your Mathematica code? I would like to understand how to program equations like this.

Thanks!

1. I was about to ask the same thing — I get how to do the Markov stuff in Mathematica somewhat, but I don’t know how to keep track of the number of runs scored without adding it as a separate parameter of V.

Also: thanks for all these writeups, Laurent!

1. I just posted the code — can’t find a way to embed it nicely because of the constraints of my WordPress theme, but I added a link to Mathematica Cloud where you should be able to view it properly!

2. Mark says:

The code is now posted, thanks Laurent!