Here you can find the source of mean(double[] a, double[] b)
Parameter | Description |
---|---|
a | first vector |
b | second vector |
Parameter | Description |
---|---|
IllegalArgumentException | if the two vector don't have the same length |
public static double[] mean(double[] a, double[] b)
//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; } }