Reputation: 1367
I want to calculate covariance matrix using Java.
Is there any free library to compute covariance Matrix in Java?
Upvotes: 8
Views: 8934
Reputation: 12042
Alternatively you can use the Efficient Java Matrix Library to calculate it too: https://gist.github.com/nok/73d07cc644a390fad9e9
Upvotes: 1
Reputation: 12042
Here is a short example, how you can create it with Apache Commons Math (3.5):
RealMatrix mx = MatrixUtils.createRealMatrix(new double[][]{
{1, 2, 3},
{2, 4, 6}
});
RealMatrix cov = new Covariance(mx).getCovarianceMatrix();
Upvotes: 10