Gini Coefficient - Reputation Inequality


Please login or register to vote for this query.

(click on this box to dismiss)

Calculate the Gini Coefficient (Also known as the Gini Index) for inequality. -- THIS IS CURRENTLY AN ERRONEOUS CALCULATION, DON'T RELY ON IT! --

Interpersonal Skills

Q&A for people looking to improve their interpersonal communication skills

-- Gini Coefficient - Reputation Inequality

DECLARE @numUsers int

--SELECT @numUsers = COUNT(*) FROM Users


DECLARE @totalRep float

--SELECT @totalRep = SUM(Users.Reputation) FROM Users

-- Sort all users by reputation, and Sum (UserRep * UserRankInSortedList)
DECLARE @sumRepByRank float

--SELECT @sumRepByRank = SUM(A.ID * A.Rep) 
--      ROW_NUMBER() OVER(ORDER BY Users.Reputation ASC) ID, 
--      Users.Reputation Rep
--      FROM Users 
--      WHERE Users.Reputation > 0) AS A


DECLARE @giniIndex float

--SELECT @giniIndex = 2 * @sumRepByRank / (@totalRep * @numUsers) - (@numUsers - 1)/@numUsers

--SELECT @giniIndex

Enter Parameters

Switch to meta site
loading Hold tight while we fetch your results