Here you can find the source of mean(Collection
Parameter | Description |
---|---|
dist | a parameter |
public static Double mean(Collection<Double> dist)
//package com.java2s; import java.util.Collection; import java.util.List; public class Main { /**/*from www . jav a 2s . c om*/ * @param sums * @param count */ public static void mean(List<Double> sums, int count) { if (sums != null && !sums.isEmpty()) { for (int i = 0; i < sums.size(); i++) { sums.set(i, sums.get(i) / count); } } } /** * * @param sum * @param count * @return */ public static double mean(double sum, int count) { return count > 0 ? sum / count : null; } /** * * @param dist * @return */ public static Double mean(Collection<Double> dist) { if (dist != null && !dist.isEmpty()) { double sum = 0d; int count = 0; for (Double val : dist) { if (val != null) { sum += val; count++; } } return count > 0 ? sum / count : null; } return null; } }