com.yahoo.egads.data
Class WeightedValue
- java.lang.Object
-
- com.yahoo.egads.data.WeightedValue
-
- All Implemented Interfaces:
- java.lang.Comparable<WeightedValue>
public class WeightedValue extends java.lang.Object implements java.lang.Comparable<WeightedValue>
Class for holding a weighted value that can then be aggregated when stored in a list using various functions.
-
-
Constructor Summary
Constructors Constructor and Description WeightedValue(double value, int weight)Default ctor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static doubleaggregate(java.util.List<WeightedValue> values, java.lang.String agg)Aggregates the values in the list using the given agg function.intcompareTo(WeightedValue other)static voiddrop(java.util.List<WeightedValue> accumulator, int count, boolean highest)Drops as many of the highest or lowest values as possible, leaving at least one value in the list.doublegetValue()intgetWeight()
-
-
-
Constructor Detail
-
WeightedValue
public WeightedValue(double value, int weight)Default ctor.- Parameters:
value- The value of the data point.weight- A weight for the data point.
-
-
Method Detail
-
compareTo
public int compareTo(WeightedValue other)
- Specified by:
compareToin interfacejava.lang.Comparable<WeightedValue>
-
drop
public static void drop(java.util.List<WeightedValue> accumulator, int count, boolean highest)
Drops as many of the highest or lowest values as possible, leaving at least one value in the list.- Parameters:
accumulator- A non-null accumulator list.count- A count of 1 or more.highest- Drop higher values == true or drop lower values == false.
-
getValue
public double getValue()
- Returns:
- The data point value.
-
getWeight
public int getWeight()
- Returns:
- The weight for the data point.
-
aggregate
public static double aggregate(java.util.List<WeightedValue> values, java.lang.String agg)
Aggregates the values in the list using the given agg function. For all functions, NaNs are skipped so if an entire list is NaN'd or the list is empty, the results will be a NaN.- Parameters:
values- A non-null list of values to aggregate.agg- A non-null or empty aggregator function to use.- Returns:
- An aggregated value or NaN.
- Throws:
java.lang.IllegalArgumentException- if the values was null, agg was null or empty or we had an unimplemented agg function.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG