HN Rank
The following chart shows live ranks of top ten Hacker News stories according to this formula.
const GRAVITY = 1.8;
const TIMEBASE = 2;
const NO_URL_FACTOR = 0.4;
const NON_STORY_FACTOR = 0.8;
function calculateRank(
score: number,
scoreTime: Date,
storyTime: Date,
type: string,
storyHasUrl: boolean,
commentCount: number,
): number {
let baseScore = score - 1; // points
if (baseScore > 0) {
baseScore = Math.pow(baseScore, 0.8);
}
const age = differenceInMinutes(scoreTime, storyTime) / 60;
const adjustedAge = age + TIMEBASE;
let rank = baseScore / Math.pow(adjustedAge, GRAVITY);
if (type === "story" || type === "poll") {
if (!storyHasUrl) {
rank *= NO_URL_FACTOR;
}
rank *= calculateControFactor(score, commentCount);
} else {
rank *= NON_STORY_FACTOR;
}
// Note: Can't implement the following due to lack of data:
// - gag-factor
// - lightweight-factor
return rank;
}
function calculateControFactor(score: number, commentCount: number): number {
if (commentCount > 20) {
return Math.min(1, Math.pow(score / commentCount, 2));
}
return 1;
}
(The ranks don't follow the formula exactly, since not all data is publicly available.)
Last update: