Java Mean Calculate computeMean(double[] data)

Here you can find the source of computeMean(double[] data)

Description

Compute mean value of an array of double

License

Apache License

Parameter

Parameter Description
data a parameter

Return

mean

Declaration

public static double computeMean(double[] data) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//  w  w  w  .j a  v a2 s.c  o m
     * Compute mean value of an array of double
     *
     * @param data
     * @return mean
     */
    public static double computeMean(double[] data) {
        // sum of all the elements
        double sum = 0;
        for (double aData : data) {
            sum += aData;
        }
        return sum / data.length;
    }
}

Related

  1. computeMean(double[] results)
  2. computeMean(float[] array)
  3. computeMean(float[] data)
  4. computeMean(int val1, int val2, float ratio)