# Calculate average for 5 star review system based on average and quantity of reviews

I also asked this on math.stackexchange.com but they said should better ask my question in this section.

I have a review system and I stumble over the fact that I want to make a fair ranking and not just the average. The average is allready calculated but when you are sorting on this average the results are not fair.

EXAMPLE:

Company A has an average score of 4.8 based on 5 reviews. Company B has an average score of 4.7 based on 43 reviews.

If you rank on average score Company A is above Company B in ranking but it ain't fair because it is a lot harder to get a 4.7 based on 43 reviews.

I want to create a number that is based on the average review score and the number of reviews that are submitted.

Maybe I am wrong here for asking this question but what is the best formula to create such an average and wich values do I need for creating this?

I am developing in PHP if this should be important for you to know.

I allready found something like this based on the bayesian average, is this Something that I should use?

$$avg_num_votes = 3.852941176470588; // Average number of reviews that are written for all company's on the website$$avg_rating = 4.822222222; // Average rating for all company's that are on the website that have a review
$$this_num_votes = 1; // Number of reviews that are written for this company$$this_rating = 5; // Average rating of this company

$$bayesian_rating = ( ($$avg_num_votes * $$avg_rating) + ($$this_num_votes * $$this_rating) ) / ($$avg_num_votes + $this_num_votes); echo$bayesian_rating;


If anyone could help me out that would be great.

• A weighted average where number of reviews is used to assign weights? Commented Jun 15, 2020 at 14:53
• @BruceET thank you for your response, so you think bayesian average is not the right choise here? Do you have an example how to create a weighted average? Then I will take a look at it Commented Jun 16, 2020 at 6:22
• You'll have to decide, depending on what matches your intuition and objectives. Do the reviews of various companies have equal value for your purposes? Commented Jun 16, 2020 at 6:49
• @BruceET Yes, the reviews of various companies have an equal value for my purposes. Visitors / clients can leave a rating from 1 to 5 for a company and thats it. It is not ranking the reviews but ranking the company's based on a fair average and not a normal average. There is no upvoting in reviews or Something like that. I just need an average so that in the example Company B will rank above Company A when creating a Top 10 or Something like that. I found a lot of different formula's but I don't know wich I should use in my case. Commented Jun 16, 2020 at 6:55