views:

71

answers:

2

Hi,

I'm looking at adding a rating system to my site, similar to that seen on Amazon. Basically users can rate the product out of 5 stars.

I've been racking my brains to think of the calculation to get the average customer rating... but I can't think how to do it.

And looking at Amazon's system, I think their caculation may be incorrect. If you take this page for example:

http://www.amazon.co.uk/exec/obidos...2521526-3543861

You can see that the average customer rating should actually be 5 stars as two people have chosen 5 whereas only one has chosen 4.

Any ideas??

+3  A: 

You can calculate the average by taking the sum and dividing it by the number of values. In the case of ratings, it is the sum of all ratings divided by the number of ratings.

In the case you site, with ratings 5, 5 and 4, the average is (5+5+4)/3, which is 4.666..., and I'd guess they round to the nearest half yielding 4.5 out of 5.

meagar
+1  A: 

why not try a jquery plugin?

http://orkans-tmp.22web.net/star_rating/index.html

Aaron Saunders