A raw average rating can overvalue an item that has very few votes. A weighted rating blends each item's average with a global mean, with the vote count controlling how strongly the item's own rating is trusted.
WR=v+mvR+v+mmCHere, R is the item's average rating, v is its vote count, m is min_votes, and C is global_mean. Each item is supplied as [average_rating, vote_count]. Return the weighted ratings in the original item order.
Input: items = [[8.5, 1000], [9.2, 50], [7, 5000]], min_votes = 100, global_mean = 7.5
Output: [8.409091, 8.066667, 7.009804]
Explanation: Items with many votes remain close to their own averages, while the 50-vote item is pulled more strongly toward 7.5.
Input: items = [[10, 1]], min_votes = 100, global_mean = 5
Output: [5.049505]
For each item, use vote_count + min_votes as the shared denominator.
Compute the item-rating contribution and global-mean contribution separately, then add them.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
A raw average rating can overvalue an item that has very few votes. A weighted rating blends each item's average with a global mean, with the vote count controlling how strongly the item's own rating is trusted.
WR=v+mvR+v+mmCHere, R is the item's average rating, v is its vote count, m is min_votes, and C is global_mean. Each item is supplied as [average_rating, vote_count]. Return the weighted ratings in the original item order.
Input: items = [[8.5, 1000], [9.2, 50], [7, 5000]], min_votes = 100, global_mean = 7.5
Output: [8.409091, 8.066667, 7.009804]
Explanation: Items with many votes remain close to their own averages, while the 50-vote item is pulled more strongly toward 7.5.
Input: items = [[10, 1]], min_votes = 100, global_mean = 5
Output: [5.049505]
For each item, use vote_count + min_votes as the shared denominator.
Compute the item-rating contribution and global-mean contribution separately, then add them.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number