Java Mean Calculate computeMean(float[] array)

Here you can find the source of computeMean(float[] array)

Description

Computes the mean value of a given array

License

Open Source License

Parameter

Parameter Description
array the array

Return

the mean value as float

Declaration

public static float computeMean(float[] array) 

Method Source Code

//package com.java2s;
/*// w w  w .  j  av a  2 s.  co  m
 * Copyright (C) 2010-2014  Andreas Maier
 * CONRAD is developed as an Open Source project under the GNU General Public License (GPL).
*/

public class Main {
    /**
     * computes the mean of the array "values" on the interval [start, end].
     * @param values the array
     * @param start the start index
     * @param end the end index
     * @return the mean value
     */
    public static float computeMean(float[] values, int start, int end) {
        float revan = 0;
        for (int i = start; i <= end; i++) {
            revan += values[i];
        }
        revan /= end - start + 1;
        return revan;
    }

    /**
     * Computes the mean value of a given array
     * @param array the array
     * @return the mean value as float
     */
    public static float computeMean(float[] array) {
        float mean = 0;
        for (int i = 0; i < array.length; i++) {
            mean += array[i];
        }
        return mean / array.length;
    }
}

Related

  1. computeMean(double[] data)
  2. computeMean(double[] results)
  3. computeMean(float[] data)
  4. computeMean(int val1, int val2, float ratio)
  5. computeMean(int[][] pixels)
  6. computeMeanSquaredError(double[] trueValues, double[] predValues)