Skip to content

Instantly share code, notes, and snippets.

View JeffSackmann's full-sized avatar

Jeff Sackmann JeffSackmann

View GitHub Profile
@JeffSackmann
JeffSackmann / tennisTiebreakProbability.py
Created January 12, 2011 21:02
calculate the probability that the current server wins a p-point tiebreak, given server's probability of winning serve and return points, and the current score.
## calculate the probability that the current server wins a best-of-p tiebreak.
## some results shown here:
## http://summerofjeff.wordpress.com/2010/12/04/7-point-tiebreak-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
return r
@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