Here you can find the source of variance(double m[], double[][] o)
public static double[] variance(double m[], double[][] o)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { public static double[] variance(double m[], double[][] o) { int rows = o.length; int cols = o[0].length; double[] var = new double[m.length]; Arrays.fill(var, 0.0); if (rows == 1) { return var; }/* w w w .java2 s . c om*/ for (double[] row : o) { assert (row.length == cols); for (int i = 0; i < cols; ++i) { var[i] += Math.pow(m[i] - row[i], 2.0); } } for (int i = 0; i < cols; i++) { var[i] /= (rows - 1); } return var; } }