Skip to content

Instantly share code, notes, and snippets.

@joepie91
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joepie91/7c0dab92f64e192d2691 to your computer and use it in GitHub Desktop.
Save joepie91/7c0dab92f64e192d2691 to your computer and use it in GitHub Desktop.
AnonNews scoring algo
frontpageScore = (upvotes, minutes) ->
maxMinutes = (48 * 60);
maxMultiplier = Math.pow(1.001, maxMinutes);
if minutes > maxMinutes
minutes = maxMinutes
factor = 1 - (Math.pow(1.001, minutes) / maxMultiplier)
return factor * upvotes
# The command-line argument is the amount of upvotes. The output is the minute-count followed
# by the frontpage score for the given amount of upvotes at that point in time. The 'decay rate'
# speeds up over time, allowing very popular older things to eventually 'fall behind' newer but
# somewhat less popular things, at an accelerating pace. The cut-off (configured in the function)
# is at 48 hours, after which submissions are sorted by date.
sven@linux-rfa7:~/projects/anonnews3> coffee test-score.coffee 2000
0 1887.5687976109093
50 1881.8072794840434
100 1875.7505133261966
150 1869.3833692014948
200 1862.6899418430346
250 1855.6535109211761
300 1848.256499275788
350 1840.4804290081142
400 1832.305875322573
450 1823.7124180031872
500 1814.6785904034343
550 1805.1818258220878
600 1795.1984011310979
650 1784.703377514693
700 1773.6705381716674
750 1762.0723228252289
800 1749.8797588768198
850 1737.0623890319248
900 1723.5881952170737
950 1709.4235185979876
1000 1694.532975499064
1050 1678.8793690141736
1100 1662.423596087966
1150 1645.1245498355702
1200 1626.9390168566897
1250 1607.82156928757
1300 1587.7244513211906
1350 1566.597459912203
1400 1544.3878193686114
1450 1521.0400495169276
1500 1496.4958271114692
1550 1470.6938401416023
1600 1443.569634672981
1650 1415.0554538401943
1700 1385.0800685886177
1750 1353.5685997426574
1800 1320.4423309559131
1850 1285.6185120760033
1900 1249.0101524328554
1950 1210.5258035340828
2000 1170.069330624633
2050 1127.5396725400378
2100 1082.8305892533901
2150 1035.8303964854072
2200 986.4216867146284
2250 934.481035890829
2300 879.8786951190125
2350 822.4782665437999
2400 762.1363626245676
2450 698.7022479502012
2500 632.0174626987006
2550 561.9154268010391
2600 488.2210238204683
2650 410.75016350777906
2700 329.30932193979135
2750 243.6950580923074
2800 153.69350563993532
2850 59.07983871327471
2900 0
2950 0
3000 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment