Java mean mean(double[][] o)

Here you can find the source of mean(double[][] o)

Description

mean

License

Open Source License

Declaration

public static double[] mean(double[][] o) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double[] mean(double[][] o) {
        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];// w  ww  .j  a va2 s .c  o m
            }
        }

        for (int i = 0; i < cols; ++i) {
            result[i] /= (double) rows;
        }

        return result;
    }

    /**
     * 
     * @param basqs
     * @return
     */
    public static byte mean(byte[] basqs) {
        int sum = 0;
        for (byte basq : basqs) {
            sum += (int) basq;
        }

        return (byte) (sum / basqs.length);
    }
}

Related

  1. mean(double[] vector)
  2. mean(double[] x, boolean[] used)
  3. mean(double[][] image)
  4. mean(double[][] input, int column)
  5. mean(double[][] matrix)
  6. mean(final double[] a)
  7. mean(final double[] data, final boolean noNaN)
  8. mean(final double[] expected, final int begin, final int end)
  9. mean(final double[] in, final int start, final int stop)