Class GiniIndex

java.lang.Object
es.uam.eps.ir.relison.utils.indexes.GiniIndex

public class GiniIndex
extends java.lang.Object
Computes the value of the Gini Index of a list of values.

Reference: R. Dorfman. A formula for the Gini coefficient. The Review of Economics and Statistics 61(1), pp. 146-149 (1979)

  • Constructor Summary

    Constructors 
    Constructor Description
    GiniIndex()  
  • Method Summary

    Modifier and Type Method Description
    double compute​(java.util.List<java.lang.Double> values, boolean sort)
    Given a list of values, it computes the value of the Gini index
    double compute​(java.util.List<java.lang.Double> values, boolean sort, long numItems, double sumValues)
    Computes the value of the Gini Index
    double compute​(java.util.stream.Stream<java.lang.Double> values, boolean sort)
    Given a stream of values, it computes the value of the Gini index.
    double compute​(java.util.stream.Stream<java.lang.Double> values, boolean sort, long numItems, double sumValues)
    Computes the value of the Gini Index
    private double computeSorted​(java.util.List<java.lang.Double> values)
    Computes the Gini coefficient for a sorted list of values
    private double computeUnsorted​(java.util.List<java.lang.Double> values)
    Computes the Gini coefficient for an unsorted list of values

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • compute

      public double compute​(java.util.List<java.lang.Double> values, boolean sort)
      Given a list of values, it computes the value of the Gini index
      Parameters:
      values - The list of values.
      sort - Indicates if the list of values has to be sorted.
      Returns:
      The value of the Gini index.
    • compute

      public double compute​(java.util.stream.Stream<java.lang.Double> values, boolean sort)
      Given a stream of values, it computes the value of the Gini index.
      Parameters:
      values - The stream containing all the values.
      sort - Indicates if the list of values has to be sorted or not.
      Returns:
      The value of the Gini index
    • computeUnsorted

      private double computeUnsorted​(java.util.List<java.lang.Double> values)
      Computes the Gini coefficient for an unsorted list of values
      Parameters:
      values - the unsorted list of values
      Returns:
      the value of the Gini coefficient
    • computeSorted

      private double computeSorted​(java.util.List<java.lang.Double> values)
      Computes the Gini coefficient for a sorted list of values
      Parameters:
      values - the sorted list of values
      Returns:
      the value of the Gini coefficient.
    • compute

      public double compute​(java.util.List<java.lang.Double> values, boolean sort, long numItems, double sumValues)
      Computes the value of the Gini Index
      Parameters:
      values - The list of values
      sort - Indicates if the list of values has to be sorted (true) or it is already sorted (false)
      numItems - Total number of items
      sumValues - Sum of the list of values
      Returns:
      The value of the Gini Index
    • compute

      public double compute​(java.util.stream.Stream<java.lang.Double> values, boolean sort, long numItems, double sumValues)
      Computes the value of the Gini Index
      Parameters:
      values - A stream of values
      sort - Indicates if the list of values has to be sorted (true) or it is already sorted (false)
      numItems - Total number of items
      sumValues - Sum of the list of values
      Returns:
      The value of the Gini Index