So far, the series has been discussing how to give a "certain period" of rank, such as "the hottest article of the last 24 hours."
However, many occasions require "all time" rankings, such as "the most user-rated products."
At this point, the time factor will not need to be considered. In the last two of this series, how to give rankings without considering the time factor.
A common error algorithm is:
Score = Pro Vote-negative vote
It is assumed that there are two items, item A is 60 in favour, 40 against, and item B is 550 in favour and 450 against. Excuse me, who should be in the front row? According to the formula above, B will be in the front because its score (550-450 = 100) is higher than a (60-40 = 20). But in fact, B has a positive rating of only 55% (550/1000), and A is 60% (60/100), so the correct result should be a row ahead.
Urban Dictionary is an example of this error algorithm.
Another common error algorithm is
Score = PRO/Total number of votes
If the "total number of votes" is very large, this algorithm is actually right. The problem is that if the "total number of votes" is small, there will be an error. Suppose A has 2 votes in favour, 0 votes against, and B has 100 votes in favour and 1 against. This algorithm will make a row in front of B. This is obviously wrong.
Amazon is an example of this error algorithm.
So, what's the correct algorithm?
Let's start with the following settings:
(1) Each user's vote is an independent event.
(2) Users have only two choices, either vote in favour or vote against it.
(3) If the total number of votes is N, in which the pro vote is K, then the pro-vote ratio of P equals k/n.
If you are familiar with statistics, you may have seen it, which is a statistical distribution called "two-item distribution" (binomial distribution). This is important, and it needs to be used immediately below.
Our idea is that the larger the P, the higher the proportion of the project, the more should be ranked in the front. However, the credibility of P depends on how many people vote, and if the sample is too small, p cannot be trusted. Fortunately, we already know that P is the probability of an event in the "two-item distribution", so we can calculate the confidence interval of p. The so-called "confidence interval", that is, in a certain probability, p will fall in that interval. For example, a product's rate of praise is 80%, but this value is not necessarily trustworthy. According to statistics, we can only say that there is a 95% certainty that the ratings are between 75% and 85%, that is, the confidence interval is [75%, 85%].
In this way, the ranking algorithm is more clear:
The first step is to calculate the "rating rate" for each item (that is, the percentage of votes).
The second step is to calculate the confidence interval of each "rating rate" (in 95% probability).
The third step, according to the lower limit value of confidence interval, ranking. The larger the value, the higher the rank.
The principle is that the width of the confidence interval is related to the number of samples. For example, a has 8 votes in favour, 2 against, 80 in favour and 20 against. Of these two projects, the proportion of votes is 80%, but B's confidence interval (assuming [75%, 85%]) is much narrower than the confidence interval of a (assuming [70%, 90%]), so the lower bound of B's confidence interval (75%) is larger than a (70%), so B should be in front of a.
The essence of confidence interval is to carry out the correction of the credibility to make up for the effect of small sample size. If the sample more, it is more credible, do not need a large correction, so confidence interval will be relatively narrow, the lower bound value will be larger; if the sample is less, it is not necessarily credible, must be a large correction, so confidence interval will be relatively wide, the lower bound value will be relatively small.