Thursday, 7 February 2013

Finding the Best Batting Lineup


I explained in my last post how Monte Carlo simulation could be used to compare one batting order to another. This can be useful if a manager has two batting orders that he wishes to evaluate. However, what if the manager wanted to know what the best batting order would be for his team?

This is a difficult problem. With 14 players on the roster, there are

14*13*12*11*10*9*8*7*6 = 726,485,760

different batting orders that can be made up. So finding the particular batting order that is the best would appear to be very difficult.

On the other hand, if we ignore the order in which the players bat, there are only 

(14*13*12*11*10) / (5*4*3*2*1) = 2,002

ways to choose 9 players from a 14 player roster. This appears to be a manageable problem.

I wrote a program to find these 2,002 lineups and analyze them using my Monte Carlo simulation.

I used the offensive data from 2012 from 14 players.
 
For the 2,002 sets of 9 players, I ran 100 seasons of 20 games to find all of the sets that had an average of 6.0 runs or more per game. I found 29 sets.

Then I conducted a runoff of these 29 sets using the program I discussed in the last post to compare two lineups. This time, I ran 500 trials of 500 seasons of 20 games. I compared the set 1 to the set 2 to determine which had the higher average runs per game. If set 1 had a higher average number of runs than set 2, I repeated the process with set 1 to set 3. Otherwise, I repeated the process with set 2 and set 3. I did not simply run 500*500*20 = 5,000,000 individual games and calculate the average runs per game for each set. By doing a runoff and running trials, I was able to determine the number of trials in which the difference between the two sets was statistically sginificant.

I found the winner of the runoff was the following set of 9 players.

Player    
1           
2           
3           
6           
7           
10        
11         
12         
14         

With this set of 9 players in the lineup, the next problem is to determine the best batting order. I will discuss how I did this in my next post.

No comments:

Post a Comment