Pow
Pow

Reputation: 1367

Compute Covariance Matrix in Java

I want to calculate covariance matrix using Java.

Is there any free library to compute covariance Matrix in Java?

Upvotes: 8

Views: 8934

Answers (3)

Darius
Darius

Reputation: 12042

Alternatively you can use the Efficient Java Matrix Library to calculate it too: https://gist.github.com/nok/73d07cc644a390fad9e9

Upvotes: 1

Darius
Darius

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

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81674

The Apache Commons Math library can do this.

Upvotes: 5

Related Questions