Class WeightedStats
java.lang.Object
microsim.dev.statistics.WeightedStats
Weighted statistics over a collection of data.
Note that results are cached, for example calling
stats.sum();
stats.sum();
stats.mean();
calculates the weighted sum of elements only once and reuses the results in subsequent calls and to compute the mean.
-
Constructor Summary
ConstructorsConstructorDescriptionWeightedStats(List<? extends Number> values, List<? extends Number> weights) Build aWeightedStatsobject for the given lists of values and weights.WeightedStats(WeightedValues<? extends Number> wvals) Build aStatsobject for the given list of weighted values. -
Method Summary
Modifier and TypeMethodDescriptionintcount()The number of values.doublemean()The weighted average of values.doublesum()The weighted sum of values.static Supplier<WeightedStats> supplier(Supplier<? extends WeightedValues<? extends Number>> supplier) Convenience method to work with theSupplierAPI.doubleThe sum of all weights.
-
Constructor Details
-
WeightedStats
-
WeightedStats
-
-
Method Details
-
supplier
public static Supplier<WeightedStats> supplier(Supplier<? extends WeightedValues<? extends Number>> supplier) Convenience method to work with theSupplierAPI. -
count
public int count()The number of values. -
sum
public double sum()The weighted sum of values. -
weightSum
public double weightSum()The sum of all weights. -
mean
public double mean()The weighted average of values.
-