Let's say I have 20 people who rated a service, the average rating for them was 4/5. If a new person did the rating for 3/5, what's the new average of rating?

Note the answer doesn't have to be exact, I am using the calculation for rating component, so I am going to round the result as I will have only integers.


Assuming that the true average rating (i.e. without any rounding) was exactly 4, then the total rating for all 20 people is $4 \times 20 = 80$. So the total rating after adding the 21st rating in is $80 + 3 = 83$, so the average rating across 21 people is $83/21 \approx 3.95$. If you don't store either an accurate value for the average, or the total of all ratings, you're going to have trouble adjusting the rating as new ones come in since rounding will tend to push everything back to the previous value.

EDIT for example:

Let's suppose you already have 100 ratings, with a total of 374, so the average is 3.74. Then if the 101st user gives a rating of ...

1, the new average will be $375/101 = 3.71$
2, the new average will be $376/101 = 3.72$
3, the new average will be $377/101 = 3.73$ 4, the new average will be $378/101 = 3.74$ 5, the new average will be $379/101 = 3.75$

If you just store that value rounded to the nearest whole number, you'll say all of those are 4. Then as new ratings come in, you'll probably keep rounding the result to 4 for as long as you like - even if a million people all give a rating of 1, if you update after every rating you'll never see the value shift. Storing to 2 decimal places means that the same problem will happen once you reach a few thousand ratings.

  • $\begingroup$ Thank you. No I don't store the value for each user. the user is going to rate, and the new average will be based on the existing average + the new rate. Does your equation mean that EACH user voted as 4? How will it be pushed to the previous value, can you elaborate? $\endgroup$ – Jacky Dec 7 '16 at 2:56
  • $\begingroup$ Let's say the first user voted as 3/5, the second user voted as 2/5, the third user voted as 5/5, how do you calculate the average? $\endgroup$ – Jacky Dec 7 '16 at 2:59
  • $\begingroup$ What if I store my average as 3.34. Will this be better? and how? $\endgroup$ – Jacky Dec 7 '16 at 3:04
  • $\begingroup$ You don't need to store each individual's rate. However, you should store the sum of all ratings, or the average of all ratings, with a decent amount of accuracy. So yes, storing it as 3.34 will be better, because then it won't be until you have a few thousand ratings will you find that new ratings are unable to shift the average. I'll add a little info to give some better context for why that is the case. $\endgroup$ – ConMan Dec 7 '16 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.