List of utility methods to do Collection Mean
double | calculateMean(Collection extends Number> values) Returns the mean of a collection of Number objects. int count = 0; double total = 0.0; final Iterator<? extends Number> iterator = values.iterator(); while (iterator.hasNext()) { final double value = iterator.next().doubleValue(); if (!Double.isNaN(value) && !Double.isInfinite(value)) { total += value; count++; ... |
double | calculateMean(Collection extends Number> values) Calculate a mean for the input if (values.isEmpty()) { throw new IllegalArgumentException("can't calculate a mean for an empty collection"); } else { double sum = 0.0; for (Number currValue : values) { sum += currValue.doubleValue(); return sum / values.size(); ... |
double | calculateMean(Collection calculate Mean if (values == null || values.isEmpty()) { throw new IllegalArgumentException("Can not calculate mean of null or empty collection!"); return (calcSum(values) / values.size()); |
double | getMean(Collection get Mean double sum = 0.0; for (double d : data) { sum += d; return sum / data.size(); |
double[] | getMean(Collection get Mean int l = cluster.iterator().next().length; double[] r = new double[l]; for (double[] d : cluster) for (int i = 0; i < l; i++) r[i] += d[i]; for (int i = 0; i < l; i++) r[i] /= cluster.size(); return r; ... |
double | getMean(final Collection get Mean final int size = collection.size(); final List<T> sorted = new ArrayList<T>(collection); Collections.sort(sorted, new Comparator<T>() { @Override public int compare(final T n1, final T n2) { return (int) Math.signum(n2.doubleValue() - n1.doubleValue()); }); ... |
double | getVariance(Collection extends Number> data, Number mean) Returns the standard deviation of a set of numbers. double result = Double.NaN; if (data != null && data.size() > 0 && mean != null) { double sum = 0.0; for (final Number n : data) { final double diff = n.doubleValue() - mean.doubleValue(); sum = sum + (diff * diff); result = sum / (data.size()); ... |
double | mean(Collection extends Number> coll) mean if (coll == null || coll.size() < 1) throw new IllegalArgumentException(); double res = 0; for (Number n : coll) { res += n.doubleValue(); return res / coll.size(); |
double | mean(Collection extends Number> nums) mean if (nums == null || nums.isEmpty()) { return Double.NaN; double sum = 0.0; for (Number n : nums) { sum += n.doubleValue(); return sum / nums.size(); ... |
Double | mean(Collection mean return (sum(data) / (double) data.size()); |