Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $avg_num_votes = 18; // Average number of votes in all products
- $avg_rating = 3.7; // Average rating for all products
- $this_num_votes = 6; // Number of votes for this product
- $this_rating = 4; // Rating for this product
- $bayesian_rating = ( ($avg_num_votes * $avg_rating) + ($this_num_votes * this_rating) ) / ($avg_num_votes + $this_num_votes);
- echo round($bayesian_rating); // 3
- ((18 * 3.7) + (6 * 4)) / (18 + 6)
- (66.6 + 24) / (24)
- 90.6 / 24
- 3.775
Add Comment
Please, Sign In to add comment