forum.alglib.net
http://forum.alglib.net/

covm returns a matrix that is not symmetric
http://forum.alglib.net/viewtopic.php?f=2&t=4318
Page 1 of 1

Author:  jdb [ Mon Mar 30, 2020 6:10 pm ]
Post subject:  covm returns a matrix that is not symmetric

Hi there,

I am trying to use the alglib "covm" function to find the covariance matrix for some data but the results of the covm function are not symmetric.

In the following code block 'x' stores the data, 'c' stores the covariance matrix and dim is the dimension of an observation in x.

Code:
      covm(x, c);
      covariance = cv::Mat_<float>(dim, dim);
      for (int i = 0; i < dim; i++)
      {
         for (int j = 0; j < dim; j++)
         {
            float cij = *c[i, j];
            covariance.at<float>(i, j) = cij;
         }
      }


The result is a matrix whose columns store the same value. For example:
Code:
.0096 .0149
.0096 .0149


Shouldn't the results be a symmetric matrix with these values? I think I must be making a newbie mistake somewhere. Thank you for your help and time.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/