ForHosting KIT · Developer Utilities

Gini coefficient calculator

The Gini coefficient calculator converts a list of non-negative incomes or values into one widely used measure of inequality.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

A result of zero means every submitted value is equal, while values closer to one indicate that more of the total is concentrated among fewer observations. The calculation is deterministic, accepts unsorted data, and reports the number of observations alongside the coefficient. It is useful for quick comparisons, reproducible reports, and automated statistical workflows without requiring a spreadsheet or custom script.

Interpret the coefficient in context

The Gini coefficient compresses the distribution of a non-negative variable into a number between zero and one. Zero represents complete equality: every observation has exactly the same value. As the coefficient rises, the total becomes more concentrated in a smaller share of observations. That makes the measure convenient for comparing income distributions, customer spending, account balances, workloads, or any other non-negative quantity. However, the coefficient is a summary, not a complete description. Two datasets can have the same result while their shapes, medians, extremes, and population sizes differ substantially. Always record what each value represents, which observations were included, and whether the samples are comparable. A coefficient calculated from household income should not be compared casually with one calculated from individual wealth. The calculator also returns the observation count so that the result can be stored with basic context. Use charts and descriptive statistics when the distribution itself matters, and treat the Gini coefficient as one compact signal rather than a verdict about fairness or policy.

Understand how the calculation works

You may submit the values in any order because the calculator first sorts them from smallest to largest. It then applies the standard weighted-sum form of the Gini formula, which compares each sorted position with the total of all observations. This approach produces the same population Gini coefficient as averaging every pairwise absolute difference, but it avoids constructing every pair and therefore scales much better for long arrays. Equal values produce zero because no observation is separated from another. If every submitted value is zero, the usual formula would divide by a zero total, so this calculator defines the result as zero: the observations are identical and contain no concentration difference. The implementation uses the values exactly as supplied and does not round the returned coefficient. Floating-point representation can therefore show the normal precision characteristics of JavaScript numbers. Negative values are rejected because the promised zero-to-one interpretation depends on a non-negative domain, and non-finite values such as infinity are rejected because they cannot produce a meaningful deterministic statistic.

Prepare data and compare results responsibly

Build the input array from observations measured in the same unit and over the same period. Remove labels, currency symbols, missing-value markers, and subtotal rows before submitting it. Zeros are valid and often meaningful, so do not discard them merely because they lower an average; include them when they represent genuine members of the population with no measured amount. For comparisons across regions, teams, or time periods, apply the same inclusion rules each time. Changes in sampling can move the coefficient even when the underlying distribution has not changed. Also consider whether values should be adjusted for household size, inflation, purchasing power, or exposure before calculation. The endpoint rejects an empty array, negative numbers, non-numeric items, and arrays beyond the published limit, giving automated pipelines a clear failure instead of an ambiguous statistic. The browser version is useful for an immediate check, while the API costs $0.002 per request and suits repeatable jobs. Store the original definition, filters, observation count, and coefficient together so another analyst can reproduce and interpret the comparison later.

Compare income distributions

Measure how concentrated income is across consistently defined populations or reporting periods.

Monitor customer concentration

Summarize whether revenue or account value is spread broadly or concentrated among relatively few customers.

Evaluate workload balance

Compare non-negative task counts across people, machines, or queues with one reproducible inequality measure.

What does a Gini coefficient of zero mean?

It means every submitted observation is equal. The calculator also returns zero when all observations are zero.

Does the array need to be sorted?

No. The calculation sorts a copy of the values internally and does not modify the submitted array.

Can I include zero values?

Yes. Zero is a valid non-negative observation and should be included when it represents a genuine measured value.

Why are negative values rejected?

The standard zero-to-one interpretation used by this calculator assumes non-negative values. Negative observations can make that interpretation invalid.

Is this a sample-corrected Gini coefficient?

No. It returns the standard population coefficient for the submitted array and does not apply a finite-sample correction.

What does the API request cost?

Each API request costs $0.002. The same deterministic calculation can also run in the browser.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/gini-coefficient

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/gini-coefficient \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"values":[10,20,30,40]}'
{
  "values": [
    10,
    20,
    30,
    40
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.gini_coefficient",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_items100000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →