List of utility methods to do Array Average
double | average(long[] array) Returns the average value of an array. return array.length == 0 ? 0 : sum(array) / array.length;
|
double | average(long[] vals) average long sum = 0; double n = (double) vals.length; for (Long i : vals) sum += ((double) i); return sum / n; |
Number | average(Number[] numbers) Calculates the average, and returns it in the correct class. Number sum = sum(numbers); return divide(sum, new Integer(numbers.length)); |
double | average1(double[] d) average if (d == null || d.length < 1) return Double.NaN; double retVal = 0; int countNonNAN = 0; for (int i = 0; i < d.length; i++) { if (Double.isNaN(d[i]) || Double.isInfinite(d[i])) continue; countNonNAN++; ... |
double | average2(double[] d) average if (d.length < 1) return Double.NaN; double retVal = 0; int countNonNAN = 0; for (int i = 0; i < d.length; i++) { if (Double.isNaN(d[i]) || Double.isInfinite(d[i])) continue; countNonNAN++; ... |
int | average4RGBA(int var0, int var1, int var2, int var3) average RGBA int var4 = var0 & 255; int var5 = var1 & 255; int var6 = var2 & 255; int var7 = var3 & 255; switch (var4 << 24 | var5 << 16 | var6 << 8 | var7) { case -16777216: return var0; case -16776961: ... |
float[] | averageChroma(float[] chromaSums, int countChromas) average Chroma float[] resultChroma = new float[12]; for (int i = 0; i < chromaSums.length; i++) { resultChroma[i] = chromaSums[i] / countChromas; return resultChroma; |
double | averageLuminance(double[] luminance) average Luminance double avgLum = 0; for (double element : luminance) { avgLum += element; avgLum = avgLum / luminance.length; return avgLum; |
double | averageNonZeros(int[] array) Returns the average value only among non-zero values if (array.length == 0) return 0; int numNonZeros = 0; double sum = 0; for (int i = 0; i < array.length; i++) { if (array[i] != 0) { sum += array[i]; numNonZeros++; ... |
double[] | averagePt(double[][] ndPoints) Find the average n-d point in a collection of n-d points. int nDimensions = ndPoints[0].length; double[] avg = new double[nDimensions]; for (double[] ndPoint : ndPoints) { for (int n = 0; n < nDimensions; n++) { avg[n] += ndPoint[n]; for (int n = 0; n < nDimensions; n++) { ... |