Here you can find the source of mean(final double[] vec)
Parameter | Description |
---|---|
vec | the vector. |
public static double mean(final double[] vec)
//package com.java2s; //License from project: Open Source License public class Main { /**/* ww w .j a v a 2s. c o m*/ * Computes the mean of the elements of a vector. * @param vec the vector. * @return the mean of the elements of the vector. */ public static double mean(final double[] vec) { assert vec != null; return sum(vec) / vec.length; } /** * Computes the sum of the elements of a vector. * @param array the array, to be summed. * @return the sum of the elements of the vector. */ public static double sum(final double[] vec) { assert vec != null; double s = 0; for (double i : vec) { s += i; } return s; } }