public class StatisticsUtils
extends java.lang.Object
Constructor and Description |
---|
StatisticsUtils() |
Modifier and Type | Method and Description |
---|---|
static double |
getAverage(java.util.Collection<? extends java.lang.Number> list)
Calculates the average from a collection of numeric values.
|
static <T extends java.lang.Number & java.lang.Comparable<T>> |
getMax(java.util.Collection<T> list)
Examine list of numbers to find the instance which has the highest value.
|
static <T extends java.lang.Number & java.lang.Comparable<T>> |
getMin(java.util.Collection<T> list)
Examine list of numbers to find the instance which has the lowest value.
|
static <T extends java.lang.Number> |
getPercentiles(java.util.Collection<? extends T> values,
double... percentiles)
Gets percentile values from a collection of numeric values.
|
public static double getAverage(java.util.Collection<? extends java.lang.Number> list)
list
- List of numbers to average againstpublic static <T extends java.lang.Number & java.lang.Comparable<T>> T getMax(java.util.Collection<T> list)
compareTo
, the provided list must be generic to the specific type of
Number
contained, and not the generic Number
itself.T
- The type of number contained within the listlist
- List to examine for high valueComparable.compareTo(Object)
java.lang.IllegalArgumentException
- if the list is emptypublic static <T extends java.lang.Number & java.lang.Comparable<T>> T getMin(java.util.Collection<T> list)
compareTo
, the provided list must be generic to the specific type of
Number
contained, and not the generic Number
itself.T
- The type of number contained within the listlist
- List to examine for high valueComparable.compareTo(Object)
java.lang.IllegalArgumentException
- if the list is emptypublic static <T extends java.lang.Number> java.util.Map<java.lang.Double,T> getPercentiles(java.util.Collection<? extends T> values, double... percentiles)
The returned map's keys correspond exactly to the percentiles provided. Iterating over the returned map will iterate in order of the requested percentiles as well.
T
- Specific number type contained in the collectionvalues
- A non-empty collection of numbers to examine for percentilespercentiles
- Percentiles requested, any decimal values between 0 and 100 (inclusive)