def wilson_score(sum_rating, n, votes_range = [0, 1]):
z = 1.64485
v_min = min(votes_range)
v_width = float(max(votes_range) - v_min)
phat = (sum_rating - n * v_min) / v_width / float(n)
rating = (phat+z*z/(2*n)-z*sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
return rating * v_width + v_min