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??