10

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?

Raphael
  • 73,212
  • 30
  • 182
  • 400
Logan Besecker
  • 203
  • 1
  • 4

1 Answers1

8

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:

  • $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.

Dave Clarke
  • 20,345
  • 4
  • 70
  • 114