Calculating Gini Coeffecient What's the fastest way (or formulae) of manually calculating Gini Coefficient of equal-sized bin income data?

Example:
No of individuals in group: 4 4 4 4 4
Income of each group:       1 2 3 4 5 
respectively.
All of these answers are true but don't provide an easy solution which doesn't use excel/code. Gini can be fairly easily computed by hand too.

The Gini coefficient fundamentally shows the shaded region above the lorenz curve in order to get a relative gauge of the distance the lorenz curve is from the line of equality. Fundamentally what this shows is the average distance between incomes. with 1 being the highest possible income and 0 being the lowest.

One way to calculate this is to simply calculate the area between the line of equality and the Lorenz curve.


This is clearly pretty difficult to do. Luckily there is an easier method.

Gini is also equal to: (The average variance for all incomes) / (2 * the mean)

The average variance for all incomes can be calculated by constructing a matrix of all incomes and then calculating the distance between each income.

For your example:

  | 1   2   3   4   5
__|___________________
1 | 0   1   2   3   4
2 | 1   0   1   2   3
3 | 2   1   0   1   2
4 | 3   2   1   0   1
5 | 4   3   2   1   0


Then add up all of the distances within the matrix to get the total variance.

0 + 1 + 2 + 3 + 4 + 1 + 0 + 1 + 2 + 3 + 2 + 1 + 0 + 1 + 2 + 3 + 2 + 1 + 0 + 1 + 4 + 3 + 2 + 1 + 0 = 40.

Then divide it by the total number of elements within the matrix to get the average variance.

Average Variance = 40 / 25 = 1.6.

Now divide the average variance by the average income times two.

Mean = (1 + 2 + 3 + 4 + 5)/5 = 15/5 = 3

Mean*2 = 6.

Since the gini is equal to: (The average variance for all incomes) / (2 * the mean):

Gini = 1.6 / 6 =  .2666

Which is what the other users got through more complicated methods.