List of utility methods to do Array Average
int | averageX(long[][] intImg, int width, int height, int i, int j, int dl, int dr) Compute the average x coordinate of nonzero pixels int count = 0, sum = 0, xstart = Math.max(0, j - dl), xend = Math.min(width - 1, j + dr), ystart = Math.max(-1, i - dl), yend = Math.min(height - 1, i + dr); for (int k = xstart; k < xend; k++) { int tmp = (int) (intImg[yend][k] - (ystart != -1 ? intImg[ystart][k] : 0) + (k != 0 ? -intImg[yend][k - 1] + (ystart != -1 ? intImg[ystart][k - 1] : 0) : 0)); count += tmp; sum += tmp * k; return count == 0 ? Integer.MAX_VALUE : sum / count; |
float | avg(byte[] values) The average of an array return avg(values, 0, values.length);
|
double | avg(double a, double b) Returns the average of two doubles return (a + b) / 2d;
|
double | avg(double v1, double v2) avg return (v1 + v2) / 2.;
|
double | avg(double values[], int size, boolean ignoreNan) avg if (values == null || size == 0) { return Double.NaN; int cnt = 0; double sum = 0; for (int i = 0; i < size; i++) { double v = values[i]; if (!Double.isNaN(v)) { ... |
double | avg(double... a) avg if (a == null) { return 0; long count = a.length; double sum = sum(a); if (count > 0) { return sum / count; } else { ... |
double | avg(double[] a) Average or mean value of array return sum(a) / (a.length);
|
double | avg(double[] array) avg double sum = 0; for (double val : array) { sum += val; return sum / array.length; |
double | avg(double[] nums) avg double sum = 0; for (double n : nums) sum += n; return sum / nums.length; |
double | avg(double[] values) Calculates the average over an given array of doubles. double avg = 0; for (double v : values) { avg += v; return avg / values.length; |