public static double calculateGiniCoefficient(List<Double> valueList){
  int numberOfValues=valueList.size();
  double sumOfValues=calculateSum(valueList);
  double arithmeticMean=sumOfValues / numberOfValues;
  double sumOfAbsoluteDifferences=0.;
  for (  double i : valueList) {
    for (    double j : valueList) {
      double absoulteDifference=Math.abs(i - j);
      sumOfAbsoluteDifferences=sumOfAbsoluteDifferences + absoulteDifference;
    }
  }
  double giniCoefficient=sumOfAbsoluteDifferences / (2 * Math.pow(numberOfValues,2) * arithmeticMean);
  return giniCoefficient;
}

public static double calculateGiniCoefficient ( List < Double > valueList ) { int numberOfValues = valueList . size ( ) ; double sumOfValues = calculateSum ( valueList ) ; double arithmeticMean = sumOfValues / numberOfValues ; double sumOfAbsoluteDifferences = 0. ; for ( double i : valueList ) { for ( double j : valueList ) { double absoulteDifference = Math . abs ( i - j ) ; sumOfAbsoluteDifferences = sumOfAbsoluteDifferences + absoulteDifference ; } } double giniCoefficient = sumOfAbsoluteDifferences / ( 2 * Math . pow ( numberOfValues , 2 ) * arithmeticMean ) ; return giniCoefficient ; }
calculates gini coefficient of the values of a given values . the gini coefficient is equals to the half of the relative mean absolute difference ( rmd ) .
