How to Calculate the Gini Coefficient with 3 Variables
Enter any three non-negative values, such as incomes, wealth amounts, output levels, or scores. The calculator applies the standard Gini coefficient formula, shows the main steps, and plots a Lorenz curve so you can visualize inequality immediately.
Gini Calculator
Tip: A Gini coefficient of 0 means perfect equality. A value closer to 1 means greater inequality.
Expert Guide: How to Calculate the Gini Coefficient with 3 Variables
The Gini coefficient is one of the most widely used measures of inequality in economics, finance, public policy, and data analysis. It compresses a distribution into a single number between 0 and 1, where 0 represents perfect equality and values closer to 1 represent stronger concentration or inequality. If you only have three variables, the process becomes much easier to understand because you can calculate every step by hand and still see the full logic behind the metric.
In practical terms, “3 variables” usually means you have three observations of the same thing. For example, you may have income for three households, wealth for three investors, production output for three regions, or test scores for three groups. The Gini coefficient does not care what the values represent as long as they are comparable and non-negative. It simply asks: how unequal is this three-value distribution?
Why the Gini coefficient matters
The reason analysts use the Gini coefficient is that it converts a messy distribution into a clean comparative indicator. Suppose one dataset is 20, 40, and 90 while another is 50, 50, and 50. You can immediately see that the second dataset is equal, but the first is not. The Gini coefficient expresses that intuition mathematically. It is especially useful when comparing countries, states, industries, or business units that have different scales. A distribution with a total of 300 and another with a total of 3,000 can still be compared if their relative inequality is similar.
Key idea: the Gini coefficient measures relative inequality, not absolute size. Three values can all rise over time, but if they rise proportionally, the Gini coefficient can remain unchanged.
The standard formula for three variables
For a finite list of values, the standard formula is:
Where:
- xi and xj are values in your dataset
- n is the number of observations
- mean is the arithmetic average
With exactly three variables, n = 3. That means the denominator becomes 2 × 3² × mean = 18 × mean. The numerator is the sum of all absolute pairwise differences across ordered pairs. Because three values generate a small number of combinations, you can calculate this manually without much difficulty.
Step-by-step example with three values
Let the three values be:
- 20
- 40
- 90
Step 1: Compute the mean.
Total = 20 + 40 + 90 = 150
Mean = 150 / 3 = 50
Step 2: Compute all ordered absolute differences.
You compare each value with each value:
- |20 – 20| = 0
- |20 – 40| = 20
- |20 – 90| = 70
- |40 – 20| = 20
- |40 – 40| = 0
- |40 – 90| = 50
- |90 – 20| = 70
- |90 – 40| = 50
- |90 – 90| = 0
Sum of ordered absolute differences = 0 + 20 + 70 + 20 + 0 + 50 + 70 + 50 + 0 = 280
Step 3: Plug the values into the formula.
G = 280 / (2 × 3² × 50)
G = 280 / 900
G = 0.3111
So the Gini coefficient is approximately 0.311. That indicates moderate inequality across the three values.
How the Lorenz curve fits in
The Lorenz curve is the visual partner of the Gini coefficient. To build it, first sort the values from smallest to largest. Then compute cumulative population shares and cumulative value shares. With three values, the population shares are 0%, 33.3%, 66.7%, and 100%. For the sorted values 20, 40, and 90, the cumulative value shares are:
- 0 / 150 = 0%
- 20 / 150 = 13.3%
- 60 / 150 = 40.0%
- 150 / 150 = 100%
Plotting those points gives a curve below the 45-degree line of equality. The larger the area between the Lorenz curve and the line of equality, the larger the Gini coefficient. In other words, the line chart on this page helps you see the same inequality that the numeric metric summarizes.
How to calculate the Gini coefficient with 3 variables quickly
If you are doing this by hand, use this compact workflow:
- Write down the three non-negative values.
- Find the total and the mean.
- Compute all absolute differences for each ordered pair.
- Add those differences.
- Divide by 2 × 9 × mean, because n² = 9 when n = 3.
If your values are identical, every difference is zero, so the Gini coefficient is zero. If one value dominates heavily while the other two are near zero, the coefficient rises.
Common mistakes to avoid
- Using negative values: the Gini coefficient is usually applied to non-negative variables like income or wealth. Negative values complicate interpretation.
- Forgetting ordered pairs: the formula shown here sums across all ordered comparisons, not just unique pairs.
- Skipping the mean: the denominator must use the average value, not the total.
- Comparing unlike variables: all three numbers should represent the same type of measure.
- Over-interpreting tiny samples: with only three observations, the result is easy to compute but statistically limited.
When a 3-variable Gini coefficient is useful
A three-variable Gini coefficient is excellent for demonstration, teaching, and small-scale comparison. Suppose a teacher wants to explain inequality using three students’ incomes in a case study. Suppose a manager wants to compare the sales concentration of three branches. Suppose a policy analyst wants to illustrate how a distribution changes before and after a transfer. In each case, three observations are enough to show the mechanics clearly.
However, for real-world inequality analysis, larger datasets are better. National Gini coefficients are usually estimated from microdata covering thousands or millions of households. Major public sources such as the U.S. Census Bureau and the Federal Reserve Survey of Consumer Finances use much broader datasets than a three-value example. For methodology background, academic references from institutions such as Stanford University can also help place the Gini coefficient in context.
Comparison table: what different 3-value distributions look like
| Three-value distribution | Total | Mean | Gini coefficient | Interpretation |
|---|---|---|---|---|
| 50, 50, 50 | 150 | 50 | 0.000 | Perfect equality |
| 20, 40, 90 | 150 | 50 | 0.311 | Moderate inequality |
| 10, 20, 120 | 150 | 50 | 0.489 | High inequality |
| 0, 0, 150 | 150 | 50 | 0.667 | Very high concentration |
This table shows how the Gini coefficient responds to concentration. Each row has the same total and the same mean, but the spread changes. As one observation captures more of the total, the coefficient rises. That is why the Gini coefficient is so valuable: it isolates distributional shape from raw scale.
Comparison table: selected real inequality statistics
The next table gives rounded, widely cited recent inequality statistics for selected countries based on household income or consumption measures. Definitions differ by source and survey design, so these values are best treated as broad comparisons rather than perfectly matched estimates.
| Country | Approximate recent Gini | Broad reading | Typical context |
|---|---|---|---|
| Slovenia | 0.24 | Low inequality | More compressed income distribution |
| Germany | 0.31 | Moderate inequality | Middle-range advanced economy benchmark |
| United States | 0.41 | Higher inequality | Broader spread in household income |
| Brazil | 0.53 | High inequality | Income concentration remains substantial |
| South Africa | 0.63 | Very high inequality | One of the highest commonly reported levels |
Alternative way to think about the formula
Some learners find the pairwise-difference formula abstract. Another way to understand it is this: the Gini coefficient asks how different people are from one another on average relative to the average level of the variable itself. If everyone has the same amount, differences are zero. If one person has a lot more than the others, average pairwise distance increases, and so does the Gini coefficient.
Special cases with three variables
- All equal: values like 30, 30, 30 always produce a Gini of 0.
- One zero value: values like 0, 40, 80 produce a positive but not maximal Gini.
- Two zeros and one positive value: values like 0, 0, 150 create a very high Gini for three observations.
- Same total, different spread: the total can stay fixed while the Gini changes sharply.
How to interpret your result responsibly
A Gini coefficient from three variables is not a national inequality estimate or a substitute for a full survey-based measure. It is a compact indicator for a very small sample. That means it is excellent for intuition and comparison, but not strong enough for broad social conclusions on its own. If you are analyzing a serious policy question, pair the Gini coefficient with descriptive statistics, quantiles, medians, and sample size information.
Final takeaway
To calculate the Gini coefficient with 3 variables, you only need three numbers, their mean, and the sum of all ordered absolute differences. The formula is straightforward, the Lorenz curve makes the result visual, and the interpretation is intuitive: the closer the number is to 0, the more equal the distribution; the closer it is to 1, the more unequal it is. Use the calculator above to test your own values, inspect the intermediate steps, and build a deeper understanding of how inequality measures work in small datasets.