Here you can find the source of mean(double[] a, double[] b)
Parameter | Description |
---|---|
a | a parameter |
b | a parameter |
public static double[] mean(double[] a, double[] b)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from www .ja v a 2 s .com*/ * average two identical double array * * @param a * @param b * @return */ public static double[] mean(double[] a, double[] b) { int n = Math.min(a.length, b.length); double[] ret = new double[a.length]; for (int i = 0; i < n; i++) { ret[i] = (a[i] + b[i]) / 2.0; } return ret; } public static double mean(double[] d) { return sum(d) / d.length; } public static int mean(int[] d) { return sum(d) / d.length; } public static float mean(float[] d) { return sum(d) / d.length; } public static long mean(long[] d) { return sum(d) / d.length; } public static double sum(double[] d) { double ret = 0; for (int i = 0; i < d.length; i++) { ret += d[i]; } return ret; } public static double sum(double[][] d) { double ret = 0; for (int i = 0; i < d.length; i++) { for (int j = 0; j < d[0].length; j++) { ret += d[i][j]; } } return ret; } public static double sum(double[] d, int n) { double ret = 0; for (int i = 0; i < n; i++) { ret += d[i]; } return ret; } public static int sum(int[] d) { int ret = 0; for (int i = 0; i < d.length; i++) { ret += d[i]; } return ret; } public static float sum(float[] d) { float ret = 0; for (int i = 0; i < d.length; i++) { ret += d[i]; } return ret; } public static long sum(long[] d) { long ret = 0; for (int i = 0; i < d.length; i++) { ret += d[i]; } return ret; } }