Skip to content

Instantly share code, notes, and snippets.

@nax3t
Created March 1, 2017 00:14
Show Gist options
  • Save nax3t/66c7273780240a868a642413474ba10c to your computer and use it in GitHub Desktop.
Save nax3t/66c7273780240a868a642413474ba10c to your computer and use it in GitHub Desktop.
Reddit Ranking Algorithm in JavaScript
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);
}
}
@procarrera
Copy link

procarrera commented Jun 6, 2020

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