i am working on a restaurant app that user can rate a restaurant in logic for example the rating equation for 10 people is as followed: user can rate from 1 to 5 9 had rated 5 1 had rated 1 the equation is ((9*5)+(1*1))/10(sum of people)=46/10=4.6 the answer is 4.6 which is unfair because 1 person low rate make the result to go down to 4.6 in my opinion the result should be 4.9 i searched and found something called Algorithmic bias i didn't understand it well , zomato app company found a solution for this cases like to be fair in low rating and fake ratings
so can anyone help me with a fair equation or algorithm
One possible solution is to square the number of people that voted for a particular rating. Compute the weighted average by multiplying each rating by the square. Then divide by the sum of the squares, and round down. That will tend to keep the rating near to the value that most people chose.
For example when the ratings are
5 stars from 9 people
1 star from 1 person
then the calculation is
(5*(9*9) + 1*(1*1)) / ((9*9) + (1*1)) = 4.9
If you have a distribution like
5 stars from 4 people
4 stars from 8 people
3 start from 11 people
2 stars from 6 people
1 star from 3 people
then the calculation is
(5*16 + 4*64 + 3*121 + 2*36 + 1*9) / (16+64+121+36+9) = 3.1
You can also try different formulas for weighting. For example, instead of using n * n
, you could use n * sqrt(n)
.