Java examples for java.lang:Math Vector
get Mean Vector
//package com.java2s; public class Main { /** //from w w w.jav a 2 s . com * * @param matrix * @return */ public static <T> Double[] getMeanVector(T[][] matrix) { Double meanVector[] = new Double[matrix[0].length]; Double sum = 0.0; for (int i = 0; i < matrix[i].length; i++) { sum = 0.0; for (int j = 0; j < matrix.length; j++) { sum = sum + (Double) matrix[j][i]; } meanVector[i] = sum / matrix[i].length; } return meanVector; } }