Created
May 2, 2019 14:05
-
-
Save qWici/b221d26f9e1133c6804d96b77b50f59c to your computer and use it in GitHub Desktop.
wilsonScore
This file contains hidden or 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
// https://www.evanmiller.org/how-not-to-sort-by-average-rating.html | |
const wilsonScore = (up, down) => { | |
if (!up) return 0 | |
const n = up + down | |
const z = 1.64485 // 1.0 = 85%, 1.6 = 95% | |
const phat = up / n | |
return (phat + ((z * z) / (2 * n)) - (z * Math.sqrt(((phat * (1 - phat)) + (z * z / (4 * n))) / n))) / (1 + (z * z / n)) | |
} | |
export default wilsonScore; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment