Java mean mean(double[] arr)

Here you can find the source of mean(double[] arr)

Description

mean

License

Open Source License

Declaration

public static double mean(double[] arr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double mean(double[] arr) {
        if (arr == null || arr.length == 0)
            return 0;
        return sum(arr) / arr.length;
    }//from   w  w  w . j ava 2s . co  m

    public static int sum(int[] arr) {
        if (arr == null || arr.length == 0)
            return 0;
        int l = arr.length;
        int res = 0;
        for (int i = 0; i < l; i++) {
            res += arr[i];
        }
        return res;
    }

    public static double sum(double[] arr) {
        if (arr == null || arr.length == 0)
            return 0;
        int l = arr.length;
        double res = 0;
        for (int i = 0; i < l; i++) {
            res += arr[i];
        }
        return res;
    }
}

Related

  1. mean(double[] a, double[] b)
  2. mean(double[] a, int from, int to)
  3. mean(double[] a, int n)
  4. mean(double[] aArray)
  5. mean(double[] an)
  6. mean(Double[] array)
  7. mean(double[] array)
  8. mean(double[] data)
  9. mean(double[] nums)