问题
$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
What is the significance of 3? What is the highest possible rating?
回答1:
you're comparing the ratings for this product against the ratings in all products, so your answer is a rating. If $avg_rating and $this_rating are 3.7 and 4 out of 10, then your answer is out of 10. If it's out of 5, then your answer is out of 5. $bayesian_rating, $avg_rating, and $this_rating are all comparable.
回答2:
Well, working out your math:
((18 * 3.7) + (6 * 4)) / (18 + 6)
(66.6 + 24) / (24)
90.6 / 24
3.775
So it's 3 out of 1...
来源:https://stackoverflow.com/questions/6653215/bayesian-rating