Skip to content

Instantly share code, notes, and snippets.

@bulv1ne
Last active December 21, 2015 00:19
Show Gist options
  • Save bulv1ne/6219360 to your computer and use it in GitHub Desktop.
Save bulv1ne/6219360 to your computer and use it in GitHub Desktop.
from math import sqrt
def score(phat, n, z=1.0):
#z 1.0 = 85%, 1.6 = 95%
return ((phat + z*z/(2*n) - z * sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n))
def confidence(ups, downs):
n = ups + downs
if n == 0:
return 0
phat = float(ups) / n
return wilson_score(phat, n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment