Java Array Average avg(final double... values)

Here you can find the source of avg(final double... values)

Description

avg

License

Open Source License

Declaration

public static double avg(final double... values) 

Method Source Code

//package com.java2s;
/**/* w w w  .  j  a v a 2 s.  co  m*/
 * Copyright? 2014-2016 LIST (Luxembourg Institute of Science and Technology), all right reserved.
 * Authorship : Olivier PARISOT, Yoanne DIDRY
 * Licensed under GNU General Public License version 3
 */

public class Main {
    public static double avg(final double... values) {
        return sum(values) / values.length;
    }

    public static double sum(final double... values) {
        double result = 0d;
        for (final double value : values)
            result += value;
        return result;
    }

    public static long sum(final long... values) {
        long result = 0;
        for (final long value : values)
            result += value;
        return result;
    }
}

Related

  1. avg(double[] nums)
  2. avg(double[] values)
  3. avg(double[] values)
  4. avg(double[] x, int start, int end)
  5. avg(final double a, final double b)
  6. avg(float... numbers)
  7. avg(int... values)
  8. avg(int[] arr)
  9. avg(int[] values)