Enter the data points into the calculator to determine the Gini Index (Gini coefficient for inequality). The data will be sorted automatically, and the number of data points (n) can be inferred from your list. Note: this page is about the inequality Gini coefficient (0 = perfect equality, 1 = maximum inequality), not the decision-tree “Gini impurity.”

Gini Index Calculator

Raw Data
Weighted
Income Shares

Enter raw data to calculate the Gini Index (n is optional; it will be inferred from the data).


Related Calculators

Gini Index Formula

The following formula is used to calculate the Gini Index (Gini coefficient) from non-negative data sorted in ascending order.

GI = 1 + 1/n - (2 / (n * Σ_(i=1)^(n) y_i)) * Σ_(i=1)^(n) (n + 1 - i) * y_i

Variables:

  • GI is the Gini Index
  • n is the number of data points
  • y_i is the i-th data point in ascending order

To calculate the Gini Index, first sort the data points in ascending order. Then compute the sum of all data points, Σ_(i=1)^(n) y_i. Next, compute the weighted sum Σ_(i=1)^(n) (n + 1 - i) * y_i. Finally, substitute these into GI = 1 + 1/n - (2 / (n * Σ y_i)) * Σ (n + 1 - i) * y_i. For non-negative data, GI ranges from 0 (perfect equality) to 1 (maximum inequality).

How to Calculate Gini Index?

The following steps outline how to calculate the Gini Index.


  1. First, determine the number of data points (n).
  2. Next, arrange the data points in ascending order.
  3. Next, calculate the sum of all the data points (Σ_(i=1)^(n) y_i).
  4. Next, calculate the sum of (n + 1 - i) * y_i for each data point.
  5. Next, calculate GI = 1 + 1/n - (2 / (n * Σ_(i=1)^(n) y_i)) * Σ_(i=1)^(n) (n + 1 - i) * y_i.
  6. Finally, report the Gini Index (GI).
  7. After inserting the variables and calculating the result, check your answer with the calculator above.

Example Problem : 

Use the following variables as an example problem to test your knowledge.

Number of data points (n) = 5

Data points (y_i) in ascending order: 1, 2, 3, 4, 5