-
Notifications
You must be signed in to change notification settings - Fork 1
Description
We want to make sure that the best daily content shows up on top anytime someone checks in. The links with the best score will show up on top. This means we have to assign a computed score to each link item that is posted.
So how do we score the best links?
- The latest links - sorted by time posted
- The most upvoted links - sorted by number of votes accumulated
In effect we can say that links decay over time - they have a certain freshness to them. Adding votes adds to their score but only incrementally.
Worth adding this excerpt:
Effects of gravity (G) and time (T)
Gravity and time have a significant impact on the score of an item. Generally these things hold true:
- the score decreases as T increases, meaning that older items will get lower and lower scores
- the score decreases much faster for older items if gravity is increased
For reference I am also adding the ranking algorithm at the heart of Hacker News:
In Python
def calculate_score(votes, item_hour_age, gravity=1.8):
return (votes - 1) / pow((item_hour_age+2), gravity)In PHP
function calculate_score($votes, $item_hour_age, $gravity=1.8) {
return ($votes - 1) / pow(($item_hour_age+2), $gravity);
}From the excerpt again:
Score = (P-1) / (T+2)^G
where,
P = points of an item (and -1 is to negate submitters vote)
T = time since submission (in hours)
G = Gravity, defaults to 1.8 in news.arc
more on the HN algo here: https://medium.com/hacking-and-gonzo/how-reddit-ranking-algorithms-work-ef111e33d0d9