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 = mn

Total

total_val = total

Variables

VariableDescriptionDefault
v1Income/Value 1 (lowest)10
v2Income/Value 220
v3Income/Value 330
v4Income/Value 440
v5Income/Value 5 (highest)100
totalDerived value= v1 + v2 + v3 + v4 + v5calculated
mnDerived value= total / 5calculated
abs_sumDerived 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 |xi - xj| / (2 * n^2 * mean)

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.

v1 = 10v2 = 20v3 = 30v4 = 40v5 = 100
  1. 01Mean = (10+20+30+40+100)/5 = 200/5 = 40
  2. 02Sum of all 25 pairwise |xi - xj| = 440
  3. 03Gini = 440 / (2 * 25 * 40) = 440 / 2000 = 0.22
  4. 04This indicates moderate inequality

Ready to run the numbers?

Open Gini Coefficient Calculator