ForHosting KIT · Developer Utilities

Theil index calculator

The Theil index calculator measures how unevenly income is distributed across a population using a method derived from information entropy.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Enter a positive income for every equally weighted person, household, region, or other unit, and the calculator returns the Theil T index together with the count, total income, and mean income used in the calculation. A result of zero represents perfect equality, while larger values indicate greater concentration. The deterministic calculation is suitable for individual analysis, reproducible reports, data pipelines, and automated comparisons.

What the Theil index tells you

The Theil index condenses the distribution of income into one non-negative inequality measure. When every observation has exactly the same income, each income-to-mean ratio equals one, every logarithmic contribution is zero, and the final index is zero. As income becomes concentrated among fewer observations, the index rises. Unlike a currency total or an average, the result has no unit, which makes it useful for comparing distributions expressed in different currencies or scales when their populations are defined consistently. The measure is sensitive to changes across the entire distribution, including the upper tail. However, it does not identify which particular households are poor or rich, and two visibly different distributions can produce the same index. Interpret it alongside counts, means, quantiles, and domain context. This calculator reports the Theil T form, sometimes called the mean log deviation weighted by relative income, rather than the separate Theil L measure. Stating that convention matters whenever results are published or compared with another source.

How the calculation works

For n incomes, the calculator first finds their arithmetic mean. It then divides every income by that mean, takes the natural logarithm of the ratio, multiplies the ratio by its logarithm, adds all contributions, and divides the sum by n. In symbols, Theil T is the average of (income divided by mean income) times the natural logarithm of that ratio. Natural logarithms are essential; using base-ten or base-two logarithms changes the numerical scale. Every input must be a finite number strictly greater than zero. This requirement avoids undefined logarithms and follows the capability’s explicit contract, so zero, negative, missing, infinite, and non-numeric values return an input error instead of being silently discarded. Each array entry has equal population weight. If an income record represents several people, expand it into individual observations or transform the data with appropriate frequency weights before using this unweighted calculator. The returned total and mean let you verify that the submitted population was interpreted as intended.

Comparing groups and interpreting results

Use the same population definition, accounting period, income concept, and treatment of taxes or transfers for every comparison. Mixing monthly household income with annual personal income produces a numerical answer but not a meaningful comparison. The Theil family is especially useful because overall inequality can be decomposed into within-group and between-group components, but that decomposition requires group populations and totals and is not performed by this single-array calculator. You can still calculate a separate index for each consistently defined group to explore patterns, provided you do not mistake those independent results for an additive decomposition. There is no universal threshold that makes a Theil value good or bad; interpretation depends on the society, market, sample design, and policy question. Also check whether a small number of extreme observations dominate the result, whether inflation adjustments are consistent, and whether the sample is representative. For automation, validate upstream data before submission and preserve the exact input array with the output so analysts can reproduce the result later.

Compare income distributions over time

Measure inequality for consistently defined annual income records and track whether concentration rises or falls between reporting periods.

Audit regional inequality

Calculate separate Theil T values for regions that use the same income definition, population unit, currency basis, and observation period.

Add a reproducible metric to a pipeline

Compute a deterministic inequality statistic from validated positive values and retain the returned count, total, and mean for auditing.

What does a Theil index of zero mean?

It means every submitted observation has the same income, so the distribution is perfectly equal within the supplied population.

Can an income be zero or negative?

No. Every value must be finite and strictly positive. Zero and negative values produce an invalid-input error because the logarithmic formula is not defined under this contract.

Which version of the Theil index is calculated?

The calculator returns Theil T: the average of each income-to-mean ratio multiplied by the natural logarithm of that ratio. It does not return Theil L.

Does changing the currency change the result?

Multiplying every income by the same positive conversion factor leaves the index unchanged, apart from ordinary floating-point precision.

Are the income observations weighted?

Each array element has equal weight. Records that represent different population counts must be expanded or appropriately transformed before calculation.

What does the API calculation cost?

The API price is $0.002 per request. The same deterministic calculation can also run free 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/theil-index

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/theil-index \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"incomes":[10,20,30,40]}'
{
  "incomes": [
    10,
    20,
    30,
    40
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.theil_index",
  "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 →