Java Utililty Methods mean

List of utility methods to do mean

Description

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

Method

double[]mean(double[][] o)
mean
int rows = o.length;
int cols = o[0].length;
double[] result = new double[cols];
for (double[] row : o) {
    assert (row.length == cols);
    for (int i = 0; i < cols; ++i) {
        result[i] += row[i];
for (int i = 0; i < cols; ++i) {
    result[i] /= (double) rows;
return result;
doublemean(final double[] a)
Calculate the mean of the vector, NaN if it's empty
return mean(a, sum(a));
doublemean(final double[] data, final boolean noNaN)
Calc the mean of an array of double
return mean(noNaN ? removeNaN(data) : data);
doublemean(final double[] expected, final int begin, final int end)
mean
int trueN = 0;
double mean = 0d;
for (int i = Math.max(0, begin); i < Math.min(expected.length - 1, end); i++) {
    mean += expected[i];
    trueN++;
if (trueN == 0)
    throw new IllegalStateException();
...
doublemean(final double[] in, final int start, final int stop)
Calculate the mean of an array of doubles.
if ((stop - start) <= 0)
    return Double.NaN;
double total = 0;
for (int i = start; i < stop; ++i) {
    total += in[i];
return total / (stop - start);
doublemean(final double[] values)
mean
return sum(values) / values.length;
doublemean(final double[] vec)
Computes the mean of the elements of a vector.
assert vec != null;
return sum(vec) / vec.length;
floatmean(final int[] scores)
mean
if (scores.length == 0) {
    return -1f;
long total = 0L;
for (int s : scores) {
    total += s;
return total / scores.length;
...
doublemean(final int[] values)
Get the mean of an array of integers.
if (values == null) {
    throw new IllegalArgumentException("input value array is null");
final int len = values.length;
int sum = 0;
for (int value : values) {
    sum += value;
return (double) sum / len;
floatmean(float a, float b)
mean
return (a + b) * 0.5f;