CompoundPage

Gini Coefficient Calculator

One number for how unevenly something is shared out: the Gini coefficient calculator shows the work, and the shares behind it, because two very different distributions can have the same Gini.

Published figures usually come as shares by quintile or decile rather than raw values. Grouped mode reads those.

List mode. Incomes, wealth, sales: any quantity that cannot be negative. Separate with commas, spaces or new lines; 12,000 with a thousands comma works if the values are separated by spaces too.

Grouped mode. Percentages, fractions or head counts; each list is scaled to its own total.

Grouped mode. Same order and same number of entries as the population shares. Percentages or totals both work.

Gini coefficient0.3836

Gini coefficient 0 is perfect equality; 1 is one value holding everything. With 10 values the most this formula can reach is 0.9.
0.3836
Gini index The same figure on a 0-100 scale.
38.4
Mean absolute difference formula Sum of |xi - xj| over all 10 x 10 ordered pairs is 3,836,000; divided by 100 that is a mean difference of 38,360. Two values picked at random differ on average by 76.7% of the mean, and the Gini is half that.
38,360 / (2 x 50,000) = 0.3836
Rank formula Sorted ascending and numbered 1 to n, each value is multiplied by its rank and summed. The same coefficient in one pass, which is how spreadsheets and software compute it.
2 x 3,709,000 / (10 x 500,000) - 11/10
Sample-corrected Gini The plain Gini times n/(n - 1) = 10/9. Use it when these 10 values are a sample from a larger population whose inequality you want to estimate; small samples understate the Gini, and this rescales so one value holding everything reads 1. If the list IS the whole population, use the plain figure.
0.4262
Top 10% share What the highest-ranked tenth of the list holds. Equal shares would be 10%.
29%
Top 20% share
45.4%
Bottom 50% share Equal shares would be 50%.
23.4%
Palma ratio Top 10% share over bottom 40% share (16.4%). It looks only at the tails, which is where the Gini is least sensitive.
1.77 to 1
80/20 ratio Top 20% share over bottom 20% share (6%), also written S80/S20.
7.57 to 1
Count and mean Total 500,000.
10 values, mean 50,000
Lorenz curve: cumulative population against cumulative share held
PoorestValueCumulative share heldEquality line minus curve
10%12,0002.4%7.6%
20%18,0006%14%
30%23,00010.6%19.4%
40%29,00016.4%23.6%
50%35,00023.4%26.6%
60%42,00031.8%28.2%
70%51,00042%28%
80%63,00054.6%25.4%
90%82,00071%19%
100%145,000100%0%
  • The Gini is the area between the Lorenz curve and the line of equality as a share of the triangle under that line. With one step per value it is exactly twice the average of the table's last column: 2 x 19.18% = 0.3836.
  • Two different distributions can share one Gini when their Lorenz curves cross. The top and bottom shares say where the inequality sits.

How the Gini Coefficient Calculator works

The Gini coefficient measures how unevenly a total is shared out. It runs from 0, where everyone holds exactly the same amount, to 1, where one person holds everything and everyone else holds nothing. Multiplied by 100 it is called the Gini index, which is the same number written differently.

There are three formulas in common use and they give the same answer, which is worth knowing because textbooks rarely say so.

The mean absolute difference formula is the definition. Take every pair of values, find the absolute difference between them, and average those differences over all n x n ordered pairs. Divide that by twice the mean. In symbols, G = sum of |xi - xj| / (2 n^2 x mean). It reads as: on average, how far apart are two randomly chosen people, as a share of what the average person has.

The rank formula is the same thing rearranged to need only one pass. Sort the values ascending and number them 1 to n. Then G = 2 x sum of (i x xi) / (n x sum of x) - (n + 1) / n. Each value is weighted by its rank, so large values sitting at high ranks pull the coefficient up.

The Lorenz curve formula is the geometric one. Line everyone up from poorest to richest and plot the cumulative share of the population against the cumulative share of the total they hold. Perfect equality is the diagonal: the poorest 40% hold 40%. Real data sags below it. The Gini is the area between the diagonal and the curve, divided by the whole triangle under the diagonal. Equivalently, it is 1 minus twice the area under the curve. This is the formula you use with grouped data such as quintile shares, adding up trapezoids: G = 1 - sum of (Pk - Pk-1)(Lk + Lk-1).

Take the default list: ten incomes totaling 500,000, a mean of 50,000. Multiplying each sorted value by its rank and adding gives 3,709,000, so G = 2 x 3,709,000 / (10 x 500,000) - 11/10 = 1.4836 - 1.1 = 0.3836. The mean-difference route lands on the same 0.3836: the average gap between two of these incomes is 38,360, and that over twice the mean of 50,000 is 0.3836.

Grouped data has a catch that is easy to miss. The trapezoid formula assumes everyone inside a group holds the same amount, which is never true, so the Gini from quintile shares is a lower bound on the Gini of the underlying individuals. Five groups typically understate it by a noticeable amount; deciles understate it less. Comparing a Gini from quintiles with one from individual records is comparing two different measurements.

Small samples have a related problem in the other direction. With n values, the largest Gini the formula can produce is (n - 1)/n, reached when one value holds everything, so ten values can never score more than 0.9. The plain formula is biased downward in small samples, and multiplying by n/(n - 1) is the standard correction. Use it when your values are a sample drawn from a larger population whose inequality you want to estimate. Do not use it when the list is the whole population you care about (all the employees of one firm, all the counties in a state), because then there is nothing to estimate.

What the Gini is not good at is telling you where the inequality is. Moving an amount from a richer person to a poorer one always lowers it, but by an amount proportional to how many people rank between them, not to how rich or poor they are. So the coefficient is most responsive to changes in the crowded middle of a distribution and least responsive to the tails. Two Lorenz curves that cross can have identical Gini coefficients and describe very different societies: one with a squeezed bottom, one with a runaway top. That is why this calculator also reports the top 10% and top 20% shares, the bottom 50% share, the Palma ratio (top 10% over bottom 40%) and the 80/20 ratio. Those say where the gap is; the Gini says how big it is overall.

The Gini is also defined only for quantities that cannot be negative. Net wealth can be, because debts exceed assets for some households, and with negative values the coefficient can exceed 1 and stops meaning what it usually means. This calculator declines to report a Gini on data containing negatives rather than quietly print a number that cannot be read on the usual scale.

Finally, published Gini figures differ for reasons that have nothing to do with inequality: income before or after taxes and transfers, household or per-person, adjusted for household size or not, income or consumption or wealth. Compare figures only when they measure the same thing the same way.

Gini Coefficient Calculator FAQ

What is the Gini formula?

The definition is the mean absolute difference divided by twice the mean: G = sum of |xi - xj| over all pairs / (2 n^2 x mean). The equivalent rank form, with values sorted ascending, is G = 2 x sum of (i x xi) / (n x sum of x) - (n + 1)/n. For grouped data use the Lorenz curve: G = 1 - sum of (Pk - Pk-1)(Lk + Lk-1).

What is the difference between the Gini coefficient and the Gini index?

Only the scale. The coefficient runs from 0 to 1; the index is the same figure multiplied by 100. A coefficient of 0.38 is an index of 38.

Should I use the sample-corrected Gini?

Use the n/(n - 1) correction when your values are a sample and you want to estimate the inequality of the larger population they were drawn from, especially with fewer than a hundred or so values. Do not use it when the list is the complete population you are describing. On large samples the two barely differ.

Can the Gini coefficient be greater than 1?

Not for non-negative data: the maximum is (n - 1)/n, approaching 1 as n grows. With negative values (net wealth including debts, profit and loss), the formula can exceed 1 and loses its usual meaning, which is why this calculator rejects negative values rather than report it.

Why does a Gini from quintile data come out lower?

Because the calculation assumes everyone inside each quintile holds the same amount, which hides all of the inequality within the groups. A Gini from grouped data is a lower bound on the Gini of the individuals underneath it, and the fewer the groups, the bigger the understatement.

Related calculators

Embed this calculator
<div id="compoundpage-gini-coefficient-calculator"></div>
<script src="https://compoundpage.com/embed/gini-coefficient-calculator.js" async></script>

The same calculation as JSON