Bayesian average PHP question

150 Views Asked by At

I'm implementing this bayesian average in one of my sites:

$avg_num_reviews = 18;

// average number of reviews from all company's (collect all the reviews written the last 12 months and devide them by the amount of company's active on our platform)

$avg_rating = 3.7;

// average rating of all company's (calculate a new average based on reviews that are written in the last 12 months for each company, add them together and divide them by the ammount of company's active on our platform)

$this_num_reviews = 6; 

// The number of reviews written for the specific company for the last 12 months

$this_rating = 4;

// The average rating of the specific company  based on reviews written the last 12 months

$bayesian_rating = ( ($avg_num_reviews * $avg_rating) + ($this_num_reviews * this_rating) ) / ($avg_num_reviews + $this_num_reviews);

// The formula calculating the bayesian average

The question

If I do it like this, read the comments. When I calculate the $avg_num_reviews and the $avg_rating should I also add the company's with 0 (zero) reviews to make this bayesian average fair? Or just the company's that have reviews?

I'm trying to make a fair sorting and ranking system, just as explained here: https://fulmicoton.com/posts/bayesian_rating/

I anyone can assist me that would be great

1

There are 1 best solutions below

1
On

When I calculate the $avg_num_reviews and the $avg_rating should I also add the company's with 0 (zero) reviews to make this bayesian average fair?

It makes no difference. The avg_rating is computed by summing all the individual reviews, and dividing by the total number of such reviews. The companies with zero reviews do not sum anything, in the numerator or in the denominator.