Sha256: d7bd26d3334b16db2893cceed54381e95442dbe6efd2bf08cffa857f48b82800
Contents?: true
Size: 490 Bytes
Versions: 9
Compression:
Stored size: 490 Bytes
Contents
module FlexibleFeeds class PopularityCalculator attr_accessor :pos, :n def initialize(pos, n) @pos = pos @n = n end def get_popularity return 0 if n == 0 dividend / divisor end private def z 1.96 end def phat 1.0 * pos / n end def dividend phat + z*z/(2*n) - z * sqrt end def sqrt Math.sqrt((phat*(1-phat)+z*z/(4*n))/n) end def divisor 1+z*z/n end end end
Version data entries
9 entries across 9 versions & 1 rubygems