# Equation for Ranking Top Posts

I am trying to write an equation to solve my problem of figuring out which post is most popular. While one would think the one with the highest stars would be, if the stars are equal then the one with 61 votes should rise higher than the one with 5 for example (since more people are downloading that)

Star system is 1-5

I thought of something like numberofvotes*star

Would that work?

The issue comes in that something with less stars should never rank higher, so the number of stars is always the first determining factor.

-
This isn't a question about algebra, so I've retagged it. It's really a statistical question: given users' votes, how can we estimate the "true" popularity of a post? It's somewhat analogous to estimating the "true" strength of a chess player, for example. It's probably a much deeper question than you think! (For instance, there's a website which ranks shows using Bayesian techniques...) – Zhen Lin Feb 24 '11 at 19:41

## 2 Answers

No. But assume that N is a large number larger than the maximum number of votes you ever expect. Then "numberofvotes + N*star" would work.

-
Is there anyway around "hard coding" N? I would hate to put 1000 and then get 1001 on one... I need something expandable. – bradenkeith Feb 24 '11 at 19:44
I don't know of any way. Maybe you provide more information about the system in which you want to implement it. In principle one can sort a list only giving a comparison function. Alternatively you can use some 64bit unsigned integer type and set N to Nmax/4 (where Nmax is the largest integer which you can represent). The formula then reads "numberofvotes + N*(star-1)" – Fabian Feb 24 '11 at 19:48

Your formula will not work if you think 5 five-star votes (5 in your formula) is better than 61 one-star votes (12.2 in your formula)

An alternative might be something like $\frac{20 + \textrm{total number of stars}}{10 + \textrm{number of voters}}$ which might say that an unvoted post is assumed to be equivalent in quality to one with lots of two-star votes. If it then gets lots of five-star votes it will increase, and with lots of one-star votes will decrease. Going back to your example, 5 five-star votes would be roughly the same as a very large number of three-star votes.

You can adjust the 20 and 10 to suit your particular needs.

-