{
  "id": "gini-coefficient",
  "version": "8e472f5bdb1c",
  "status": "published",
  "name": "Gini Coefficient Calculator",
  "question": "What is the Gini coefficient?",
  "summary": "Computes the Gini coefficient (and Gini index) of a list of incomes or of income shares from the Lorenz curve, from 0 for perfect equality to 1 for perfect inequality.",
  "category": "statistics",
  "subcategory": "descriptive",
  "url": "https://www.acalculator.org/statistics/gini-coefficient-calculator",
  "markdown": "https://www.acalculator.org/statistics/gini-coefficient-calculator.md",
  "kind": "function",
  "method": "Sort the n values from smallest, x₁ ≤ … ≤ xₙ. G = 2 Σ i·xᵢ ÷ (n Σ xᵢ) − (n + 1) ÷ n, which equals Σᵢ Σⱼ |xᵢ − xⱼ| ÷ (2 n² x̄) and the Lorenz-curve area ratio; corrected G = G × n ÷ (n − 1).",
  "assumptions": [
    "Each value is one person or household, or one equal-size group (quintile shares count as five equal groups).",
    "The Lorenz curve joins the points by straight lines, so grouped shares give the Gini between the groups only.",
    "Values must be 0 or more and not all 0."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "x": {
        "title": "Incomes or shares",
        "description": "One income per person or household, or the income shares of equal-size groups (such as quintiles), separated by commas or spaces.",
        "type": "array",
        "items": {
          "type": "number"
        }
      }
    }
  },
  "outputs": {
    "gini": {
      "label": "Gini coefficient",
      "description": "The Lorenz-curve area ratio, from 0 (everyone has the same) to (n − 1) ÷ n (one has everything).",
      "format": "number"
    },
    "index": {
      "label": "Gini index (0 to 100)",
      "description": "The Gini coefficient times 100.",
      "format": "number"
    },
    "corrected": {
      "label": "Sample Gini, n ÷ (n − 1) correction",
      "description": "The Gini coefficient times n ÷ (n − 1), which reaches 1 when one value holds everything.",
      "format": "number"
    },
    "mean": {
      "label": "Mean",
      "description": "The average of the values.",
      "format": "number"
    },
    "count": {
      "label": "Count",
      "description": "How many values were typed.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "x": [
        20000,
        35000,
        50000,
        75000,
        120000
      ]
    },
    "outputs": {
      "gini": 0.32,
      "index": 32,
      "corrected": 0.4,
      "mean": 60000,
      "count": 5
    },
    "text": "The Gini coefficient is 0.32 (Gini index 32)."
  },
  "examples": [
    {
      "given": {
        "x": [
          1,
          2,
          3,
          4,
          5
        ]
      },
      "expect": {
        "gini": 0.26666666666666666,
        "corrected": 0.3333333333333333,
        "mean": 3,
        "count": 5
      },
      "source": "US Census Bureau, Gini Index (Lorenz-curve definition, 0 to 1); hand calculation in content.mdx: Σ|xᵢ − xⱼ| = 40, 40 ÷ (2 × 25 × 3) = 0.2667; https://www.census.gov/topics/income-poverty/income-inequality/about/metrics/gini-index.html"
    },
    {
      "given": {
        "x": [
          0,
          0,
          0,
          100
        ]
      },
      "expect": {
        "gini": 0.75,
        "corrected": 1,
        "index": 75
      },
      "source": "US Census Bureau, Gini Index (1 is perfect inequality, one recipient has all the income); hand calculation in content.mdx: (n − 1) ÷ n = 3 ÷ 4; https://www.census.gov/topics/income-poverty/income-inequality/about/metrics/gini-index.html"
    },
    {
      "given": {
        "x": [
          20,
          20,
          20,
          20,
          20
        ]
      },
      "expect": {
        "gini": 0,
        "corrected": 0
      },
      "source": "US Census Bureau, Gini Index (0 is perfect equality, everyone has an equal share); https://www.census.gov/topics/income-poverty/income-inequality/about/metrics/gini-index.html"
    },
    {
      "given": {
        "x": [
          20000,
          35000,
          50000,
          75000,
          120000
        ]
      },
      "expect": {
        "gini": 0.32,
        "mean": 60000
      },
      "source": "US Census Bureau, Gini Index (Lorenz-curve definition); hand calculation in content.mdx: 2 × 1,140,000 ÷ (5 × 300,000) − 6 ÷ 5 = 0.32; https://www.census.gov/topics/income-poverty/income-inequality/about/metrics/gini-index.html"
    }
  ],
  "sources": [
    "US Census Bureau. Gini Index (income inequality metrics: definition, Lorenz curve, range 0 to 1), retrieved 2026-10-18. https://www.census.gov/topics/income-poverty/income-inequality/about/metrics/gini-index.html",
    "Central Intelligence Agency. The World Factbook: Gini Index coefficient, distribution of family income (definition as the ratio of the area between the Lorenz curve and the 45-degree line to the whole triangle), retrieved 2026-10-18. https://www.cia.gov/the-world-factbook/about/archives/2023/field/gini-index-coefficient-distribution-of-family-income",
    "Eurostat. Glossary: Gini coefficient (0 is perfect equality, 100 is full inequality), retrieved 2026-10-18. https://ec.europa.eu/eurostat/statistics-explained/index.php?title=Glossary:Gini_coefficient"
  ],
  "related": [
    "standard-deviation",
    "mean-median-mode",
    "gdp",
    "percentile"
  ],
  "changelog": []
}
