Gini Coefficient Calculator
Compute the Gini coefficient of a non-negative column from the mean absolute difference, not a binned guess.
Gini Coefficient Calculator
Compute the Gini coefficient of a non-negative column from the mean absolute difference, not a binned guess.
What the page prints, and what it refuses
Every figure is printed with the rule or formula that produced it, and any numerical tolerance is stated on the result rather than implied. The page refuses an input the formula does not define and names the value it read; it prints no answer it cannot support.
The calculation runs entirely in this browser tab; nothing is uploaded.
The page computes the Gini coefficient from the definition: half the mean absolute difference between every pair of values, divided by the mean. For 1, 2, 3 and 4 the coefficient is 0.25.
The values must be non-negative, because the coefficient is defined on a distribution of shares. The page prints the mean and the sum alongside, so the normalisation is visible.
The sorted-sum form
The pairwise definition is G = ΣᵢΣⱼ|xᵢ − xⱼ| ÷ (2n²μ). Sorting the values collapses the double sum to G = (2Σ i·x₍ᵢ₎) ÷ (nΣx) − (n + 1)/n, which is what the page evaluates.
The form is exact for the column you paste; it is not a Lorenz-curve fit and it applies no binning. A value of 0 is perfect equality and a value approaching 1 is perfect concentration.
How to use Gini Coefficient Calculator
Paste the non-negative values, one per line or comma-separated, then press Run.
The result prints the coefficient, the count, the mean, the sum and the formula it used.
What to Expect
Best for
- Measuring concentration in a column of incomes or sizes
- Comparing inequality between two groups
- Checking a Gini value by hand
Not ideal for
- Negative values, which are outside this definition
- A Lorenz curve plot, which this page does not draw
- A weighted Gini, which needs population weights
What this tool keeps
- Every value and its order
What may need cleanup
- Nothing: the coefficient is a final number
Common errors
- A negative value is refused with the reason
- An all-zero column is refused as undefined
Example use cases
- Compute the Gini of 1, 2, 3, 4
- Compare two income columns
- Check a published coefficient
Sample input
1, 2, 3, 4
Sample output
Gini = 0.25, mean = 2.5, sum = 10
Who this is for
- Economics students
- Analysts comparing distributions
Frequently asked questions
Why is the Gini of 1, 2, 3, 4 equal to 0.25?
The mean absolute difference is 1.25, the mean is 2.5, and the coefficient is half the first divided by the second: 0.625 ÷ 2.5 = 0.25.
Can the coefficient exceed 1?
For non-negative values it stays below 1, approaching it as one value takes everything. The page's formula preserves that bound rather than clipping.
Why are negative values refused?
The coefficient is defined for a distribution of non-negative shares. A negative value would make the normalisation meaningless, so the page refuses instead of returning a misleading number.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.