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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With