Skip to content

Inning simulator to help calculate "runs created" (RC) using a player's season stats. The simulator "plays" a complete inning in order to compute the number of runs.

License

Notifications You must be signed in to change notification settings

dpasse/baseball_simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Baseball Simulator

built using simulation parameters from Mathletics
see Mathletics Event Probabilities for the complete tree of event probabilities

How many runs would a team of Ichiro's from 2004 create?

from bball import InningSimulator, \
                  MonteCarloInningEngine, \
                  BatterStats

from bball.setups import MathleticsSimpleEventGenerator


player = BatterStats.create('ichiro', {
    'AB': 704, ## Appearance
    'SH': 2, ## Sac Bunts
    'SF': 3, ## Sac Flys
    'K': 63,
    'BB': 49,
    'HBP': 4,
    '1B': 225,
    '2B': 24,
    '3B': 5,
    'HR': 8
})

simulator = InningSimulator(
    MathleticsSimpleEventGenerator().create(batter)
)

ichiro_runs = MonteCarloInningEngine(simulator).run()

print(ichiro_runs * avg_innings_per_game, 'runs per game')

~ 6.575791999999999 runs per game

About

Inning simulator to help calculate "runs created" (RC) using a player's season stats. The simulator "plays" a complete inning in order to compute the number of runs.

Topics

Resources

License

Stars

Watchers

Forks