Created
March 1, 2017 00:14
-
-
Save nax3t/66c7273780240a868a642413474ba10c to your computer and use it in GitHub Desktop.
Reddit Ranking Algorithm in JavaScript
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
function _confidence(ups, downs) { | |
var n = ups + downs; | |
if(n === 0) { | |
return 0; | |
} | |
var z = 1.281551565545; | |
var p = parseFloat(ups) / n; | |
var left = p + 1 / (2 * n) * z * z; | |
var right = z * Math.sqrt(p * (1 - p) / n + z * z / (4 * n * n)); | |
var under = 1 + 1 / n * z * z; | |
return (left - right) / under; | |
} | |
function confidence(ups, downs) { | |
if(ups + downs === 0) { | |
return 0; | |
} else { | |
return _confidence(ups, downs); | |
} | |
} |
Hey! tks for sharing
I am quite new, but couldn't find Date as parameter. doesn't it affect the results?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great work, thank you :)
why do you think the original code Amir posted had this split of functions?
thanks!!