Skip to main content

gini

Introduced in: v26.8.0 Calculates the Gini coefficient of a column of finite, non-negative numeric values, a measure of inequality in a distribution. The result ranges from 0 (perfect equality: all values are the same) to a maximum approaching 1 as n grows (perfect inequality: one value holds everything and the rest are zero). For a finite sample of n values the maximum is (n - 1) / n. All passed values are collected in their input type and then sorted before a numerically stable final calculation. The coefficient is computed from normalized adjacent pairwise differences and returned as Float64, so it is rounded to Float64 precision. Therefore, the function consumes O(n) memory, where n is the number of values passed. NaN values are skipped, while infinite values are rejected. Syntax
Arguments
  • expr — Expression resulting in finite, non-negative numeric values. (U)Int* or Float* or Decimal
Returned value The Gini coefficient, or NaN if there are fewer than 2 values or the sum of the values is 0. Float64 Examples Equal values
Query
Response
Skewed distribution
Query
Response
Last modified on August 12, 2026