Java mean mean(Double totalValue, int numValues)

Here you can find the source of mean(Double totalValue, int numValues)

Description

Retrieves mean value of the list of floats.

License

BSD License

Parameter

Parameter Description
totalValue total value of the number.
numValues number of values.

Return

mean value.

Declaration

public static Double mean(Double totalValue, int numValues) 

Method Source Code

//package com.java2s;
/**//from w  ww.  ja  v  a2  s  .com
 * Copyright 5AM Solutions Inc, ESAC, ScenPro & SAIC
 *
 * Distributed under the OSI-approved BSD 3-Clause License.
 * See http://ncip.github.com/caintegrator/LICENSE.txt for details.
 */

public class Main {
    /**
     * Retrieves mean value of the list of floats.
     *
     * @param totalValue total value of the number.
     * @param numValues number of values.
     * @return mean value.
     */
    public static Double mean(Double totalValue, int numValues) {
        return numValues != 0 ? totalValue / numValues : 0;
    }

    /**
     * Retrieves mean value of the list of floats.
     *
     * @param values of values.
     * @return mean value.
     */
    public static float mean(float[] values) {
        float totalNumber = 0.0f;
        for (float value : values) {
            totalNumber += value;
        }
        return values.length == 0 ? 0 : totalNumber / values.length;
    }
}

Related

  1. getMeanValue(ArrayList values)
  2. Mean(ArrayList values)
  3. mean(Collection terms)
  4. mean(double a, double b)
  5. mean(double ask, double bid)
  6. mean(double v1, double v2)
  7. mean(double values[])
  8. mean(Double[] a)
  9. mean(double[] a)