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 indexdouble
compute(java.util.List<java.lang.Double> values, boolean sort, long numItems, double sumValues)
Computes the value of the Gini Indexdouble
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 Indexprivate double
computeSorted(java.util.List<java.lang.Double> values)
Computes the Gini coefficient for a sorted list of valuesprivate double
computeUnsorted(java.util.List<java.lang.Double> values)
Computes the Gini coefficient for an unsorted list of values
-
Constructor Details
-
GiniIndex
public GiniIndex()
-
-
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 valuessort
- Indicates if the list of values has to be sorted (true) or it is already sorted (false)numItems
- Total number of itemssumValues
- 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 valuessort
- Indicates if the list of values has to be sorted (true) or it is already sorted (false)numItems
- Total number of itemssumValues
- Sum of the list of values- Returns:
- The value of the Gini Index
-