patternMinor
Looking for a ranking algorithm that favors newer entries
Viewed 0 times
neweralgorithmlookingthatforfavorsrankingentries
Problem
I'm working on a ranking system that will rank entries based on votes that have been cast over a period of time. I'm looking for an algorithm that will calculate a score which is kinda like an average, however I would like it to favor newer scores over older ones. I was thinking of something along the line of:
$$\frac{\mathrm{score}_1 +\ 2\cdot \mathrm{score}_2\ +\ \dots +\ n\cdot \mathrm{score}_n}{1 + 2 + \dots + n}$$
I was wondering if there were other algorithms which are usually used for situations like this and if so, could you please explain them?
$$\frac{\mathrm{score}_1 +\ 2\cdot \mathrm{score}_2\ +\ \dots +\ n\cdot \mathrm{score}_n}{1 + 2 + \dots + n}$$
I was wondering if there were other algorithms which are usually used for situations like this and if so, could you please explain them?
Solution
You could use any function that gives a lower weight to older entries. For example, if data consists of scores, $s_1,\ldots,s_n$, where the index corresponds to the 'time of arrival' of the entry, that is, newer entries have larger indices, then you could use a weight function that increase as $i$ increases. So any 'increasing' function will do. Examples include:
etc.
Then your function will be
$\dfrac{\sum_{i=1}^n s_i\cdot f(i)}{\sum_{i=1}^n f(i)}$.
Actually, it makes more sense to give the newest entry the lowest index and make the weight function decreasing. This way you can tune it by setting the weighting that you want to give to the first element.
Wikipedia has an entry on weight functions, some examples can be found on the page about weighted means.
- $f(x)=e^x$
- $f(x)=\log x$
- $f(x)=x$
- $f(x)=x^2$
etc.
Then your function will be
$\dfrac{\sum_{i=1}^n s_i\cdot f(i)}{\sum_{i=1}^n f(i)}$.
Actually, it makes more sense to give the newest entry the lowest index and make the weight function decreasing. This way you can tune it by setting the weighting that you want to give to the first element.
Wikipedia has an entry on weight functions, some examples can be found on the page about weighted means.
Context
StackExchange Computer Science Q#1471, answer score: 8
Revisions (0)
No revisions yet.