Ask Your Question
0

How to use function calcCovarMatrix ?

asked 2014-04-04 02:47:28 -0600

lingyun gravatar image

image description

I want to compute the covariance matrix using function calcCovarMatrix in java. The size of covariance matrix should be 22 ,but result coming from the code is 1010 . I can not see the fail! Could you tell me? Thanks in advance!

Here is my code:

double[] a= new double[]{1.5,2.3,3.0,1.7,1.2,2.9,2.1,2.2,3.1,3.1, 1.3, 2.7,2.0,1.7, 1.0,2.0,0.5,0.6,1.0,0.9};

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

Mat srcMat = Mat.zeros(10, 2, CvType.CV_64FC1);

srcMat.put(0,0,a);

System.out.println(srcMat.dump());

Mat Avg = Mat.zeros(2,1, CvType.CV_64FC1);

Mat COV = Mat.zeros(2,2,CvType.CV_64FC1);

Core.calcCovarMatrix(srcMat,COV,Avg,Core.COVAR_ROWS);

System.out.println(Avg.dump());

System.out.println(COV.dump());

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-01-19 06:55:55 -0600

max gravatar image

Hi man, just change Core.COVAR_ROWS with Core.COVAR_COLS, and you will get the 2x2 covariance matrix!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-04-04 02:47:28 -0600

Seen: 2,432 times

Last updated: Apr 04 '14