Created
September 21, 2012 15:21
-
-
Save glinscott/3762136 to your computer and use it in GitHub Desktop.
Simple LOS/Elo calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import math | |
def los(n1, n0): | |
pi = [1.0] * (n1 + 3) | |
pi[0] = 0 | |
for j in xrange(n0 + 1, 0, -1): | |
for i in xrange(0, n1 + 1): | |
pi[i + 1] = (pi[i + 1] + pi[i]) * 0.5 | |
return pi[n1 + 1] * 100 | |
def elo(win_ratio): | |
return 400 * math.log10(win_ratio / (1 - win_ratio)) | |
draws = 823 | |
wins = 195 | |
losses = 246 | |
total = float(wins + draws + losses) | |
win_ratio = (wins + (draws / 2)) / total | |
loss_ratio = 1 - win_ratio | |
draw_ratio = draws / total | |
denom99 = 2.58 * math.sqrt((win_ratio * loss_ratio) / (total - 1)) | |
denom95 = 1.96 * math.sqrt((win_ratio * loss_ratio) / (total - 1)) | |
elo_win = elo(win_ratio) | |
print "ELO: %.2f +- 99%%: %.2f 95%%: %.2f" % ( elo_win, elo(win_ratio + denom99) - elo_win, elo(win_ratio + denom95) - elo_win ) | |
print "LOS: %.2f%%" % ( los(wins, losses) ) | |
print "Wins: %d Losses: %d Draws: %d Total: %d" % (wins, losses, draws, int(total)) | |
#print "Win%%: %.2f +- 99%%: %.2f 95%%: %.2f" % ( win_ratio * 100, denom99 * 100, denom95 * 100 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment