Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating normalized karma

Tags:

algorithm

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?

like image 515
EdanB Avatar asked Dec 29 '22 06:12

EdanB


2 Answers

 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.

like image 91
Mark Byers Avatar answered Jan 24 '23 14:01

Mark Byers


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.

like image 35
jspcal Avatar answered Jan 24 '23 13:01

jspcal