Module: WRate
- Defined in:
- lib/w_rate.rb,
lib/w_rate/version.rb
Constant Summary collapse
- VERSION =
"0.1.2"
Instance Method Summary collapse
-
#rate(sum_rating, votes_count, votes_range = [1, 5], switch_number) ⇒ Object
Your code goes here…
Instance Method Details
#rate(sum_rating, votes_count, votes_range = [1, 5], switch_number) ⇒ Object
Your code goes here…
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/w_rate.rb', line 5 def rate(, votes_count, votes_range = [1, 5], switch_number) z = 1.6 v_min = votes_range.min v_width = (votes_range.max - v_min).to_f phat = ( - votes_count.to_f * v_min) / v_width / votes_count.to_f if votes_count < switch_number =(phat+(z*z)/(2*votes_count)+z*Math.sqrt((phat*(1-phat)+(z*z)/(4*votes_count))/votes_count))/(1+(z*z)/votes_count) else = (phat+(z*z)/(2*votes_count)-z*Math.sqrt((phat*(1-phat)+(z*z)/(4*votes_count))/votes_count))/(1+(z*z)/votes_count) end return * v_width + v_min end |