Search code examples
phpalgorithmvoting

Weighted voting algorithm


I'm looking for information on which voting algorithm will be best for me. I have a basic 'Up/Down' voting system where a user can only vote the product up or down. I would like to make it weighted so that a product that is a year old will not be held to the same standards as one that is brand new.

I'm thinking do an algorithm that takes the amount of votes for each product in the last 30 days. However this creates a draw back. I don't want votes older than 30 days to become meaningless, but maybe not weighted as much as newer ones. Then possibly votes after 90 days are even weighted less than ones older than 30 days.

Is anyone aware of an algorithm that does this already and even more so is able to be calculated easily in PHP?


Solution

  • Google App Engine has a nice example that deals with votes that "decay" over time.

    It's in Python, but it should fit your needs.