Module: Volleyball::InstanceMethods

Defined in:
lib/volleyball.rb

Instance Method Summary collapse

Instance Method Details

#calculate_scoreObject



24
25
26
# File 'lib/volleyball.rb', line 24

def calculate_score
  self.score = (rank * 100).floor.to_f/10
end

#ci_lower_bound(pos, n, power) ⇒ Object

This is the Wilson Confidence Interval www.evanmiller.org/how-not-to-sort-by-average-rating.html



36
37
38
39
40
41
# File 'lib/volleyball.rb', line 36

def ci_lower_bound(pos, n, power)
  return 0 if n == 0
  z = Statistics2.normaldist(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

#rankObject



28
29
30
31
32
# File 'lib/volleyball.rb', line 28

def rank 
  adjusted_yes_votes = self.yes_votes + self.class.yes_adjustment
  adjusted_total_votes = self.no_votes + adjusted_yes_votes + self.class.no_adjustment
  ci_lower_bound(adjusted_yes_votes, adjusted_total_votes, 0.10) 
end