Gini Coefficient Calculator Formula
Understand the math behind the gini coefficient calculator. Each variable explained with a worked example.
Formulas Used
Gini Coefficient
gini = abs_sum / (2 * 25 * mn)Mean Value
mean_val = mnTotal
total_val = totalVariables
| Variable | Description | Default |
|---|---|---|
v1 | Income/Value 1 (lowest) | 10 |
v2 | Income/Value 2 | 20 |
v3 | Income/Value 3 | 30 |
v4 | Income/Value 4 | 40 |
v5 | Income/Value 5 (highest) | 100 |
total | Derived value= v1 + v2 + v3 + v4 + v5 | calculated |
mn | Derived value= total / 5 | calculated |
abs_sum | Derived value= abs(v1-v1) + abs(v1-v2) + abs(v1-v3) + abs(v1-v4) + abs(v1-v5) + abs(v2-v1) + abs(v2-v2) + abs(v2-v3) + abs(v2-v4) + abs(v2-v5) + abs(v3-v1) + abs(v3-v2) + abs(v3-v3) + abs(v3-v4) + abs(v3-v5) + abs(v4-v1) + abs(v4-v2) + abs(v4-v3) + abs(v4-v4) + abs(v4-v5) + abs(v5-v1) + abs(v5-v2) + abs(v5-v3) + abs(v5-v4) + abs(v5-v5) | calculated |
How It Works
How to Calculate the Gini Coefficient
Formula
Gini = Sum of all / (2 * n^2 * mean)xi - xj
The Gini coefficient sums all pairwise absolute differences and normalizes. A value of 0 means perfect equality (everyone has the same). A value approaching 1 means extreme inequality (one person has everything). It is the most widely used measure of income inequality.
Worked Example
Five incomes: 10, 20, 30, 40, 100.
- 01Mean = (10+20+30+40+100)/5 = 200/5 = 40
- 02Sum of all 25 pairwise |xi - xj| = 440
- 03Gini = 440 / (2 * 25 * 40) = 440 / 2000 = 0.22
- 04This indicates moderate inequality
Frequently Asked Questions
What is a typical Gini coefficient for countries?
Scandinavian countries have low inequality (Gini ~0.25-0.30). The US is moderate (~0.39). South Africa has high inequality (~0.63). The World Bank considers above 0.40 as "high inequality".
Can the Gini coefficient exceed 1?
No (for non-negative values). The theoretical maximum is 1 (one person holds all income). In practice, values above 0.6 are rare for countries. For other types of data, the Gini always falls in [0, 1].
What are limitations of the Gini coefficient?
Different distributions can have the same Gini (it does not capture where inequality occurs). It is insensitive to overall wealth level. The Lorenz curve provides more detail, and the Atkinson index allows for different sensitivity to parts of the distribution.
Ready to run the numbers?
Open Gini Coefficient Calculator