What is the Gini coefficient?
Type a list of incomes, one per person or household, or the income shares of equal-size groups such as quintiles. The Gini coefficient calculator sorts them, builds the Lorenz curve, and gives the Gini coefficient from 0 (perfect equality) toward 1 (one has everything).
- Gini coefficient
- 0.32
The Gini coefficient is 0.32 (Gini index 32).
- Gini index (0 to 100)
- 32
- Sample Gini, n ÷ (n − 1) correction
- 0.4
- Mean
- 60,000
- Count
- 5
Gini coefficient: 0.32. The Gini coefficient is 0.32 (Gini index 32).
How to calculate
Computes the Gini coefficient (and Gini index) of a list of incomes or of income shares from the Lorenz curve, from 0 for perfect equality to 1 for perfect inequality.
Example with the default inputs (Incomes or shares [20,000, 35,000, 50,000, 75,000, 120,000]): The Gini coefficient is 0.32 (Gini index 32).
Method: Sort the n values from smallest, x₁ ≤ … ≤ xₙ. G = 2 Σ i·xᵢ ÷ (n Σ xᵢ) − (n + 1) ÷ n, which equals Σᵢ Σⱼ |xᵢ − xⱼ| ÷ (2 n² x̄) and the Lorenz-curve area ratio; corrected G = G × n ÷ (n − 1).
- Each value is one person or household, or one equal-size group (quintile shares count as five equal groups).
- The Lorenz curve joins the points by straight lines, so grouped shares give the Gini between the groups only.
- Values must be 0 or more and not all 0.
Worked examples
Each example is checked against the calculator on every build.
- Incomes or shares 1, 2, 3, 4, 5 gives Gini coefficient 0.266667, Sample Gini, n ÷ (n − 1) correction 0.333333, Mean 3, Count 5.Source: US Census Bureau, Gini Index (Lorenz-curve definition, 0 to 1); https://www.census.gov/topics/income-poverty/income-inequality/about/metrics/gini-index.html
- Incomes or shares 0, 0, 0, 100 gives Gini coefficient 0.75, Sample Gini, n ÷ (n − 1) correction 1, Gini index (0 to 100) 75.Source: US Census Bureau, Gini Index (1 is perfect inequality, one recipient has all the income); https://www.census.gov/topics/income-poverty/income-inequality/about/metrics/gini-index.html
- Incomes or shares 20, 20, 20, 20, 20 gives Gini coefficient 0, Sample Gini, n ÷ (n − 1) correction 0.Source: US Census Bureau, Gini Index (0 is perfect equality, everyone has an equal share); https://www.census.gov/topics/income-poverty/income-inequality/about/metrics/gini-index.html
- Incomes or shares 20,000, 35,000, 50,000, 75,000, 120,000 gives Gini coefficient 0.32, Mean 60,000.Source: US Census Bureau, Gini Index (Lorenz-curve definition); https://www.census.gov/topics/income-poverty/income-inequality/about/metrics/gini-index.html
How it works
The Census Bureau and the CIA World Factbook define the Gini coefficient from the Lorenz curve: the area between the line of perfect equality and the Lorenz curve, divided by the whole area under that line (½). This page computes that area exactly for the typed values.
- Sort the n values from smallest to largest: x₁ ≤ x₂ ≤ … ≤ xₙ. Let T = x₁ + … + xₙ.
- The Lorenz curve joins the points (k ÷ n, Lₖ) with straight lines, where L₀ = 0 and Lₖ = (x₁ + … + xₖ) ÷ T.
- The area under it is a sum of trapezoids: B = Σₖ (1 ÷ n) × (Lₖ₋₁ + Lₖ) ÷ 2, for k = 1 to n.
- Gini coefficient G = (½ − B) ÷ ½ = 1 − 2B. Working the sum out gives the form the page uses: G = 2 × (1·x₁ + 2·x₂ + … + n·xₙ) ÷ (n × T) − (n + 1) ÷ n. This equals the mean absolute difference form, G = Σᵢ Σⱼ |xᵢ − xⱼ| ÷ (2 n² x̄), over all ordered pairs i, j (x̄ = T ÷ n).
- Gini index = G × 100.
- Corrected (sample) Gini = G × n ÷ (n − 1).
- Mean = T ÷ n; count = n.
Rules. Type 2 to 10,000 values, each 0 or more, not all 0. A negative value gives no answer. Group shares (such as quintiles) are typed like incomes: each is one equal-size group, and the shares need not add to 100.
Rounding. Every value is an exact fraction of the typed decimals, rounded once for display: G and the corrected G to 4 decimals, the index to 2 decimals.
Worked examples by hand
Incomes 1, 2, 3, 4, 5. T = 15, n = 5. Σ i·xᵢ = 1 + 4 + 9 + 16 + 25 = 55. G = 2 × 55 ÷ (5 × 15) − 6 ÷ 5 = 110 ÷ 75 − 1.2 = 0.2667. Check with pairs: the absolute differences over all ordered pairs add to 40, and 40 ÷ (2 × 25 × 3) = 0.2667. Corrected: 0.26667 × 5 ÷ 4 = 0.3333. Mean 3.
One holds everything. 0, 0, 0, 100. Σ i·xᵢ = 4 × 100 = 400; T = 100. G = 2 × 400 ÷ (4 × 100) − 5 ÷ 4 = 2 − 1.25 = 0.7500 (index 75.00). Corrected: 0.75 × 4 ÷ 3 = 1.0000.
Equal quintile shares. 20, 20, 20, 20, 20. Σ i·xᵢ = 20 × 15 = 300; T = 100. G = 600 ÷ 500 − 1.2 = 0.
Five household incomes (page default). 20,000, 35,000, 50,000, 75,000, 120,000. T = 300,000. Σ i·xᵢ = 20,000 + 70,000 + 150,000 + 300,000 + 600,000 = 1,140,000. G = 2 × 1,140,000 ÷ (5 × 300,000) − 1.2 = 1.52 − 1.2 = 0.3200. Mean 60,000.
Other questions people ask
How do I calculate the Gini coefficient?
Sort the n incomes from smallest to largest, x₁ to xₙ. Then G = 2 × (1·x₁ + 2·x₂ + … + n·xₙ) ÷ (n × total) − (n + 1) ÷ n. For 1, 2, 3, 4, 5: 2 × 55 ÷ (5 × 15) − 6 ÷ 5 = 1.4667 − 1.2 = 0.2667.
What does a Gini coefficient of 0 or 1 mean?
The US Census Bureau describes 0 as perfect equality, where everyone gets an equal share, and 1 as perfect inequality, where one recipient gets all the income. With a finite list of n values, one value holding everything gives (n − 1) ÷ n, which the corrected value scales to 1.
What is the difference between the Gini coefficient and the Gini index?
They are the same measure on different scales. The coefficient runs from 0 to 1; the index is the coefficient times 100, as Eurostat and the CIA World Factbook report it.
Can I use quintile shares?
Yes. Type the five shares (they need not add up to 100). Each counts as one equal-size group, and the page joins the Lorenz-curve points with straight lines. That misses inequality inside each group, so it gives a lower Gini than the full list of incomes would.
What is the Lorenz curve?
A chart of the cumulative share of people, poorest first, against the cumulative share of income they receive. With equal incomes it is the 45-degree line. The Gini coefficient is the area between the line and the curve, divided by the whole area under the line.
Why is there a corrected (sample) Gini?
With n values the plain Gini can reach only (n − 1) ÷ n. Multiplying by n ÷ (n − 1) makes the most unequal list give exactly 1, which suits small samples. With many values the two are almost the same.