Skip to content

Instantly share code, notes, and snippets.

View JeffSackmann's full-sized avatar

Jeff Sackmann JeffSackmann

View GitHub Profile
@JeffSackmann
JeffSackmann / generateBattingMarcels.py
Created January 14, 2011 18:32
Generate a full season's worth of batting Marcel projections from past years' stats
## Generate a full season's worth of batting Marcel projections from past years' stats
from createTuple import createTuple ## gist: 778481
from writeMatrixCSV import writeMatrixCSV ## gist: 778484
def makeBatTable(r):
for stat in ['AB', 'H', 'D', 'T', 'HR', 'SO', 'BB', 'SF', 'HP', 'CI']:
if stat in r: pass
else: r[stat] = 0
if r['AB'] == 0:
@JeffSackmann
JeffSackmann / tennisGameProbability.py
Created January 6, 2011 23:46
calculate the probability of server winning a single game, given p(winning single point) and current point score
## calculate the probability of server winning a single game,
## given p(winning single point) and current point score
## some results and commentary here:
## http://summerofjeff.wordpress.com/2010/12/03/single-game-win-expectancy-tables/
def fact(x):
if x in [0, 1]: return 1
r = 1
for a in range(1, (x+1)): r = r*a