seouri (owner)

Revisions

gist: 62807 Download_button fork
public
Public Clone URL: git://gist.github.com/62807.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
# Given the ratings I have, there is a 95% chance that the average rating is at least what?
# Score = Lower bound of Wilson score confidence interval for a Bernoulli parameter
# pos is the number of positive rating, n is the total number of ratings, and power refers to the statistical power: I would pick 0.05.
require 'statistics2'
def ci_lower_bound(pos, n, power)
    if n == 0
        return 0
    end
    z = Statistics2.pnormaldist(1-power/2)
    phat = 1.0*pos/n
    (phat + z*z/(2*n) - z * Math.sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
end