public static void centerColum(DoubleMatrix2D mat) { System.out.println("Standardizing probe mean"); for (int c = 0; c < mat.columns(); c++) { double mean = Descriptives.mean(mat.viewColumn(c).toArray()); for (int r = 0; r < mat.rows(); r++) { mat.set(r, c, ((mat.getQuick(r, c) - mean))); } } }
public static void rankColumns(DoubleMatrix2D matrix) { RankingAlgorithm COV_RANKER_TIE = new NaturalRanking(NaNStrategy.FAILED, TiesStrategy.AVERAGE); for (int c = 0; c < matrix.columns(); c++) { double[] rank = COV_RANKER_TIE.rank(matrix.viewColumn(c).toArray()); for (int r = 0; r < matrix.rows(); r++) { matrix.set(r, c, (rank[r])); } } }
public static void scaleColum(DoubleMatrix2D mat) { System.out.println("Standardizing probe standard deviation"); for (int c = 0; c < mat.columns(); c++) { double[] t = mat.viewColumn(c).toArray(); double mean = Descriptives.mean(t); double stdev = Math.sqrt(Descriptives.variance(t, mean)); for (int r = 0; r < mat.rows(); r++) { mat.set(r, c, ((mat.getQuick(r, c)) / stdev)); } } }