Here you can find the source of meandiff(double[] v1, double[] v2)
public static double meandiff(double[] v1, double[] v2)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w. ja v a 2 s .c o m*/ * Returns the difference in the means of the two lists. */ public static double meandiff(double[] v1, double[] v2) { double s1 = 0, c1 = 0; for (int i = 0; i < v1.length; i++) { s1 += v1[i]; c1++; } double m1 = s1 / c1; double s2 = 0, c2 = 0; for (int i = 0; i < v2.length; i++) { s2 += v2[i]; c2++; } double m2 = s2 / c2; double diff = m1 - m2; // Want to normalize it, so that the values are somewhat comparable.. double rval = 0.000000001; // Just to prevent ugly divide by zero. if (m2 != 0) rval = diff / m2; return (rval); } }