Java Utililty Methods Array Average

List of utility methods to do Array Average

Description

The list of methods to do Array Average are organized into topic(s).

Method

float[]average(float[][] data, int startIndex, int endIndex)
Calculates average vector
if (data.length == 0) {
    return new float[] {};
float[] out = new float[data[startIndex].length];
for (int i = startIndex; i < endIndex; i++) {
    for (int j = 0; j < out.length; j++) {
        out[j] += data[i][j] / (endIndex - startIndex + 1);
return out;
voidaverage(float[][] originalValues, float[][] newValues, int[] indexArray)
set newValues to be the average of the original values in the index array
if (indexArray.length == 0) {
    return;
float total = 0;
for (int j = 0; j < indexArray.length; j++) {
    total += originalValues[0][indexArray[j]];
for (int j = 0; j < indexArray.length; j++) {
...
intaverage(int argb0, int argb1)
Averages two ARGB colors.
return packPixel((getAlpha(argb0) + getAlpha(argb1)) / 2, (getRed(argb0) + getRed(argb1)) / 2,
        (getGreen(argb0) + getGreen(argb1)) / 2, (getBlue(argb0) + getBlue(argb1)) / 2);
intaverage(int... is)
average
if (is.length == 0)
    return 0;
int i = 0;
for (double ii : is) {
    i += ii;
return i / is.length;
intaverage(int... values)
Gets the rounded average of all the integer values given
int total = 0;
for (int v : values)
    total += v;
return Math.round((float) total / (float) values.length);
intaverage(int[] a)
average
int sum = sum(a);
return sum / a.length;
doubleaverage(int[] array)
average
return sum(array) / array.length;
intaverage(int[] pixels)
average
float m = 0;
for (int i = 0; i < pixels.length; ++i) {
    m += pixels[i];
m = m / pixels.length;
return (int) m;
intaverage(int[] pixels)
average
float m = 0;
for (int i = 0; i < pixels.length; ++i) {
    m += pixels[i];
m = m / pixels.length;
return (int) m;
doubleaverage(int[] x)
average
int sum = 0;
for (int v : x)
    sum += v;
return (double) sum / x.length;