开发者

Compute Covariance Matrix in Java

开发者 https://www.devze.com 2023-03-14 04:49 出处:网络
I want to calculate covari开发者_C百科ance matrix using Java. Is there any free library to compute covariance Matrix in Java?Here is a short example, how you can create it with Apache Commons Math (3

I want to calculate covari开发者_C百科ance matrix using Java.

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


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();


The Apache Commons Math library can do this.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消