Created
November 6, 2011 21:44
-
-
Save nremond/1343554 to your computer and use it in GitHub Desktop.
Compute wilson score
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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