Skip to content

Instantly share code, notes, and snippets.

@gregglind
Created February 10, 2012 19:53
Show Gist options
  • Save gregglind/1792214 to your computer and use it in GitHub Desktop.
Save gregglind/1792214 to your computer and use it in GitHub Desktop.
confidence / fisher z score
'''
simple up / down 85% confidence score....
http://amix.dk/blog/post/19588?source=google
(among others)
'''
#Rewritten code from /r2/r2/lib/db/_sorts.pyx
from math import sqrt
def confidence(ups, downs):
n = ups + downs
if n == 0:
return 0
z = 1.0 #1.0 = 85%, 1.6 = 95%
phat = float(ups) / n
return sqrt(phat+z*z/(2*n)-z*((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment