Search code examples
algorithmmathrating-system

What is this "weighted" rating algorithm?


I'm working on code where a star rating system was implemented, allowing users to rate between 1 & 5 stars. Instead of displaying an item's actual rating it uses this algorithm:

( rating_votes / ( rating_votes+10 ) ) * ( rating_total/rating_votes ) ) + ( 10 / ( rating_votes+10 ) ) * 4

Based on my intuition it seems like the intent of this is to default the rating to "4 stars" and to not drop the rating too quickly when there's under 10 votes.

Does anyone know what the mathematical name of this algorithm is called? Also can it's implementation be simplified and still produce the same output?


Solution

  • I got:

    (rating_votes / ( rating_votes +10 )) * ( rating_total / rating_votes ) + 
    ( 10 / ( rating_votes +10 ) ) *4 
    
    = (rating_total / (rating_votes + 10)) + (40 / (rating_votes + 10))
    
    = (rating_total + 40) / (rating_votes + 10)
    

    ... you seem to have missed an opening bracket but is that what you meant? If so then your intuition is correct — it pretends that 10 people voted '4' before anyone else jumped in.

    Other than integer rounding, depending on your language, simplification should produce the same result.