views:

204

answers:

2

How could I calculate a normalized value of karma (value between 0 and 1), from the karma of users in my system?

The normalized value should reflect the value of the user's karma relative to all other users.

I think I would probably have to include the average and standard deviations of all karma's somehow, but I can't seem to come up with the right formula.

Any help?

+2  A: 

you would want to calculate the percentile that each user belongs to. in mysql, you can do it like this:

http://forums.mysql.com/read.php?20,105223,105278#msg-105278

rank / total

where rank is the number of users with lower karma.

jspcal
+7  A: 
 min_karma = min(karmas)
 max_karma = max(karmas)
 normalized = (karma - min_karma) / (max_karma - min_karma)

This has the property that the user(s) with karma = min_karma get a normalised karma of 0, and users with karma = max_karma get 1. Others are linearly distributed in between. You will have to handle separately the special case that all users have the same karma.

If you want a non-linear distribution you could use a logarithmic function:

 normalized = (log(karma) - log(min_karma)) / (log(max_karma) - log(min_karma))

It is important in this case that the karma can never fall below 1, as this could skew the results.

Mark Byers
I'm not sure if this is the way to go. Consider a situation where 100 users have a low karma distributed around 10, and only 1 user has a high karma of 100. I would expect the normalized values to take into account the fact that only 1 user has a high karma, and therefore give users with for example 15 karma a better than linear advantage. Does that make sense?
EdanB
Also, there is no max karma, as karma gets added for certain actions that can be done indefinately (such as getting high ratings for a review you posted)
EdanB
You could take the logarithm of the score if you want a non-linear distribution.
Mark Byers
@EdanB: The max_karma refers to the *current* max, which changes as people get more karma.
Mark Byers
I've updated my post with these clarifications.
Mark Byers
This is an awesome solution!
jspcal