Java mean mean(double[] a, double[] b)

Here you can find the source of mean(double[] a, double[] b)

Description

Returns the mean between two vectors

License

Open Source License

Parameter

Parameter Description
a first vector
b second vector

Exception

Parameter Description
IllegalArgumentException if the two vector don't have the same length

Return

the mean

Declaration

public static double[] mean(double[] a, double[] b) 

Method Source Code

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

public class Main {
    /**/*from w  ww. jav  a  2  s  . c om*/
     * Returns the mean between two vectors
     *
     * @param a first vector
     * @param b second vector
     * @return the mean
     * @throws IllegalArgumentException if the two vector don't have the same length
     */
    public static double[] mean(double[] a, double[] b) {
        if (a.length != b.length) {
            throw new IllegalArgumentException(
                    "Error computing mean in Utilities.mean: arrays should have the same length");
        }
        double[] sum = new double[a.length];
        for (int i = 0; i < a.length; i++) {
            sum[i] = (a[i] + b[i]) / 2;
        }
        return sum;
    }
}

Related

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