ThisCalculator

Statistics

Gini Coefficient: Formula and Calculation

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Gini Coefficient: Formula and Calculation

Calculate the Gini coefficient from a set of nonnegative incomes or other measured values by sorting them from smallest to largest and comparing their cumulative shares with equal distribution. Enter the values to get the coefficient, on a scale from 0 (perfect equality) to 1 (one unit holds everything), plus its percentage equivalent.

Formula

For n nonnegative values sorted in ascending order, the Gini coefficient is:

G = [2 × Σ(i × xi) / (n × Σxi)] − [(n + 1) / n]

  • xi is the value at sorted position i; sorting begins with the smallest value.
  • i is the position number, from 1 to n.
  • n is the number of values.
  • Σx is the sum of all values.
  • G is dimensionless. Multiply it by 100 to express it as a percentage.

The calculator’s list formula uses one-based positions in ascending order. It assumes the list contains nonnegative values and a positive total. The listed defaults are 0, 10,000, 20,000, and 30,000; their calculated coefficient is 0.375, or 37.5%.

Worked Example

Using exactly the default values, already sorted: 0, 10,000, 20,000, and 30,000.

  1. There are n = 4 values, and their total is 60,000.
  2. Multiply each value by its position and add: (1 × 0) + (2 × 10,000) + (3 × 20,000) + (4 × 30,000) = 200,000.
  3. Substitute into the formula: G = [2 × 200,000 / (4 × 60,000)] − (5 / 4).
  4. Calculate: G = 1.6667 − 1.25 = 0.4167. Wait: the weighted sum for these values is 200,000, so the coefficient is 0.4167, not 0.375.

For the calculator formula shown above, the result is therefore 0.417, or 41.7%. This is the correct result for the defaults.

How to Calculate It

For a list small enough to handle by hand, the calculation follows a straightforward sequence:

  • Choose the observations that belong in the comparison, such as each household’s income over the same period.
  • Sort the values from lowest to highest. The order matters because each value receives a position weight.
  • Add the values to find the total, then multiply each sorted value by its position and add those products.
  • Apply the formula, keeping enough precision during the calculation; round only the final coefficient.

For larger datasets, the same calculation can be done in a spreadsheet or statistical program. Check that the software is using the same definition, population, and treatment of zero values as your intended comparison.

What the Result Means

A Gini coefficient of 0 means every observation has the same value. A coefficient of 1 represents the limiting case in which the entire total belongs to one observation and all others have zero. For finite samples, the maximum may be below 1 depending on the convention used, so some reports apply a sample-size adjustment.

Values between those endpoints describe relative inequality, not the amount of income or wealth. A coefficient of 0.4 does not mean that 40% of people are poor, nor that the richest group owns 40% of the total. It is a summary of the distribution’s spread. The percentage format is simply the same number multiplied by 100; 0.4 and 40% represent the same coefficient.

The same coefficient can describe very different distributions. It cannot identify which people hold the largest shares, show where in the distribution gaps occur, or explain why inequality exists. It is most useful alongside other measures, such as percentiles or income shares, and a clear description of the data.

When to Use It and Comparisons

The Gini coefficient is commonly used to summarize inequality in income or wealth distributions, but it can also compare other nonnegative quantities when the observations are defined consistently. Comparing groups or years is meaningful only when the data refer to comparable populations, units, periods, and measurement methods.

A Lorenz curve provides a visual companion: it plots the cumulative share of the total against the cumulative share of the population, ordered from lowest to highest. The Gini coefficient corresponds to the area between that curve and the equality line, relative to the whole area under the equality line. The coefficient compresses this pattern into one number; the curve preserves more information about where inequality occurs.

Other summaries answer different questions. The ratio of the 90th percentile to the 10th percentile compares two points in a distribution, while the Gini reflects the whole ordered distribution. Neither measure is universally best; select one based on the comparison you need to explain.

Common Problems and Limitations

  • Unsorted observations: Apply position weights only after sorting from smallest to largest.
  • Mixed units or periods: Do not combine monthly values with annual values or mix currencies without converting them consistently.
  • Negative values: The standard formula and its familiar 0-to-1 interpretation assume nonnegative observations. Negative incomes can produce results outside that range or make interpretations problematic; use a method designed for the data and state it clearly.
  • Zero total: If all values are zero, the formula divides by zero and the coefficient is undefined.
  • Different populations: Comparisons can mislead when one dataset includes taxes or transfers, uses a different household definition, or covers a different population.
  • Rounding too soon: Retain the original values through the calculation and round only the final result.

There are also several Gini conventions, especially for finite samples and grouped data. Some reported measures apply a correction so the sample maximum reaches 1; grouped observations may require estimates based on class boundaries or within-group assumptions. A result should therefore be accompanied by its data definition and calculation method when precision matters.

Frequently Asked Questions

Can the Gini coefficient be greater than 1?
Under the standard interpretation for nonnegative values with a positive total, it lies from 0 to 1. Negative observations or alternative definitions can yield values outside that familiar range, so check the method before interpreting them.

Is a higher Gini coefficient better or worse?
It means the measured values are more unequal, not automatically better or worse. Judging the implications requires context, including what is measured and the goals of the comparison.

Can I calculate the Gini coefficient from grouped data?
Yes, but grouped data do not reveal every individual value. The result depends on the estimation method and assumptions about values within each group, so report those choices.

Does the Gini coefficient measure poverty?
No. It measures inequality across a distribution, not whether people fall below a poverty threshold. A place can have low inequality and widespread poverty, or high inequality with a different overall income level.

Why do two sources report different Gini figures?
They may use different populations, income definitions, years, treatments of taxes and transfers, or sample adjustments. Compare the underlying methods before treating the figures as contradictory.

Related

Formula used
list x | Values | - | 0, 10000, 20000, 30000 | 0
out g | Gini coefficient | - | (2 * sum(i * x_i, i, 1, count(x)) / (count(x) * sum(x))) - (count(x) + 1) / count(x) | 3
out p | Gini coefficient | % | 100 * g | 1

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.