Mercurial > hg > rlgallery-misc
view py/stats.py @ 74:900da50ee11c
Merge lighttpd configuration into one include file.
The lighttpd configuration was previously spread across several files
which were intended to overwrite the defaults. They often became
outdated.
Now all customization is in lighttpd/rlgallery.conf, which should be
included at the end of whatever main lighttpd configuration file is in
use. It should require minimal updates for new lighttpd versions or
distribution changes.
author | John "Elwin" Edwards |
---|---|
date | Wed, 28 Dec 2016 13:12:04 -0500 |
parents | c045d4dcf88a |
children |
line wrap: on
line source
#!/usr/bin/python3 import math import psycopg2 import rlgall def makeExpPDF(lbd): def lpdf(x): return lbd * math.exp(-lbd * x) return lpdf def makeExpCDF(lbd): def lcdf(x): return 1 - math.exp(-lbd * x) return lcdf conn = psycopg2.connect("dbname=rlg") cur = conn.cursor() for game in rlgall.gamelist: query = "SELECT score FROM {0};".format(game.uname) cur.execute(query) scores = [ r[0] for r in cur.fetchall() ] count = len(scores) total = sum(scores) lbd = float(count) / total cdf = makeExpCDF(lbd) print("{0}: {1} games, average {2}".format(game.name, count, int(1/lbd))) for i in range(0, 10000, 1000): actual = len([ s for s in scores if i <= s < i + 1000 ]) predicted = (cdf(i + 1000) - cdf(i)) * count print("{0:5}: {1:4} {2:.3}".format(i, actual, predicted)) high = max(scores) print("Max: {0} {1:.3}\n".format(high, 1 - cdf(high))) cur.close() conn.close() exit()