Skip to content

Instantly share code, notes, and snippets.

View nremond's full-sized avatar

Nicolas Rémond nremond

View GitHub Profile
@nremond
nremond / gist:1343554
Created November 6, 2011 21:44
Compute wilson score
# Compute the comment score
def compute_comment_score(c)
upcount = (c['up'] ? c['up'].length : 0)
downcount = (c['down'] ? c['down'].length : 0)
n = upcount + downcount
return 0 if n==0
#1.6 = 95%,1.0 = 85%
z = 1.6
phat = Float(ups) / n
Math.sqrt(phat+z*z/(2*n)-z*((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)