0

I have 2 eigen vectors sets X and Y with size=(7,7) (so 7 eigen vectors of 7 components).

I am looking for a way to build a covariance matrix from these 2 eigen vectors sets.

In a first time, I did the function :

# Compute covariance between vectors of matrix
def compute_Cov(A,B):
  C = np.zeros((7,7))
  for i in range(7):
    C[0:7,i]= np.mean(A[0:7,i]*B[0:7,i]) - np.mean(A[0:7,i])*np.mean(B[0:7,i])
    #C[0:7,i] = np.cov(A[0:7,i],B[0:7,i])
  return C

and calling : CovXY = compute_Cov(X,Y)

But this way, the matrix CovXY is not symetric and I don't know how to build a symmetric matrix from X and Y eigen vectors sets (so X and Y are actually matrices).

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    How unsymetric is CovXY? It is not uncommon to do Covxy = (Covxy+Covxy.T)/2 to get rid of numerical errors. You have to judge yourself based on how unsymetric the matrix is if this is the way to go. – Bas Nov 20 '20 at 11:55
  • @Bas . Thanks for your quick answer. Unfortunately, I think I can't apply your formula since each column corresponds to an eigen vector. So, I have to handle with an array of eigen vectors (7 columns in my case). –  Nov 20 '20 at 13:09
  • 1
    Are you sure that you compute covariance matrix? It seems that you compute cross-covariance matrix, which is not symmetric https://en.wikipedia.org/wiki/Cross-covariance_matrix – fdermishin Nov 21 '20 at 00:28

0 Answers0