Here you can find the source of mean(double[][] o)
public static double[] mean(double[][] o)
//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); } }