input: 
  from typing import List
  import numpy as np
  
  def gini(x: List[float]) -> float:
      """Calculate the Gini coefficient of a given dataset.
      >>> gini([2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,21])
      0.605
      """
      x = np.array(x)
      x_value_counts = np.bincount(x).astype(float)
      x_cum_sum = np.cumsum(x_value_counts)
      n = len(x)
      lorenz = x_cum_sum / n
      lorenz = np.insert(lorenz, 0, 0)
      width = lorenz[:-1] - lorenz[1:]
      gini_coef = (1 / n) * np.sum(width * (lorenz[1:] + lorenz[:-1]))
  
      return gini_coef
  
  if __name__ == '__main__':
      x = [2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,21]
      gini_coef = gini(x)
      print(gini_coef) # should print 0.605
  
output:     x = np.array(x)
      x_value_counts = np.bincount(x).astype(float)
      x_cum_sum = np.cumsum(x_value_counts)
      n = len(x)
      lorenz = x_cum_sum / n
      lorenz = np.insert(lorenz, 0, 0)
      width = lorenz[:-1] - lorenz[1:]
      gini_coef = (1 / n) * np.sum(width * (lorenz[1:] + lorenz[:-1]))
  
      return gini_coef