Skip to content

Instantly share code, notes, and snippets.

@nremond
Created November 6, 2011 21:44
Show Gist options
  • Save nremond/1343554 to your computer and use it in GitHub Desktop.
Save nremond/1343554 to your computer and use it in GitHub Desktop.
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)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment