Here is a quick example of how you can create it using Apache Commons Math (3.5):
RealMatrix mx = MatrixUtils.createRealMatrix(new double[][]{ {1, 2, 3}, {2, 4, 6} }); RealMatrix cov = new Covariance(mx).getCovarianceMatrix();
Darius morawiec
source share