As we go out shopping for gifts this holiday season, given the state of the economy, a lot of people will be thinking about how to get the best value from their gift budget. A lot more people than usual, in fact, because as you'll hear on TV or read online from time to time, the income gap in this country is exceptionally large.
It's probably common knowledge that a large income gap means roughly a large difference between the richest and poorest income levels. But that's not a very precise statement by itself. Suppose you have two tiny countries of six people each, and their incomes are distributed like this:
The difference between richest and poorest is the same in both countries, but the other values are significantly higher in Lolistan. We need to calculate something that takes into account everyone's income, not just the extremes.
OK, how about the standard deviation? That's the usual way to characterize how widely a bunch of numbers are distributed.
Huh. They're the same. While you can't argue with the math, it does suggest that the interpretation may not be right: Omnomnomia just intuitively seems to have a larger income gap than Lolistan, so perhaps standard deviation isn't the right metric to measure that.
Fortunately, probability theory provides an answer. The Gini coefficient is a precise mathematical way to quantify the inequality of a distribution. It allows you to place any given distribution on a spectrum from many copies of the same value () to one nonzero value and the rest zero (). For a discrete set of values (like incomes), you can calculate it using the formula
where is the value and is its rank in decreasing order. The largest has a rank of , the second largest as , and so on.
|Rank||Income (Omnomnomia)||Income (Lolistan)|
Finally, this number shows a distinct difference between the two countries! As expected, Omnomnomia's income gap, as measured by the Gini coefficient, is larger.
I like this calculation because there are a couple of pretty intuitive (I think) ways to understand it that explain why it's a good measure of inequality. First, the Gini coefficient is half of the relative mean difference, which in turn is just the average difference between two values. So overall, the larger the differences between values in a set of numbers, the larger its Gini coefficient will be.
Another way to interpret the coefficient, which makes more sense for continuous distributions, is to think of it as the area under the Lorenz curve, as a fraction of the maximum possible area it could have.
The Lorenz curve is the plot of the function which tells you how much of the value the bottom so-many percent of the population has in total — for example, if you hear a statistic on the news saying the bottom 20% of people in America earn only 1% of the income, that means the value of the Lorenz curve at is . If everyone has the same income, like in a perfect socialist society, then the bottom x% of the population will always have x% of the income, which would give the maximum possible area under the Lorenz curve.
Bonus: enjoy this Python function which calculates the Gini coefficient of a NumPy
def gini_coeff(x): # requires all values in x to be zero or positive numbers, # otherwise results are undefined n = len(x) s = x.sum() r = argsort(argsort(-x)) # calculates zero-based ranks return 1 - (2.0 * (r*x).sum() + s)/(n*s)