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
// Node.js implementation of Evan Miller's algorithm for ranking stuff based on upvotes: | |
// http://www.evanmiller.org/how-not-to-sort-by-average-rating.html | |
const stats = require('simple-statistics') | |
const lower_bound = (upvotes, n = 0, confidence = 0.95) => { | |
if (n === 0) return 0 | |
// for performance purposes you might consider memoize the calcuation for z | |
const z = stats.probit(1-(1-confidence)/2) |