How to calculate covariance matrix

35 visualizaciones (últimos 30 días)
yusuf zain
yusuf zain el 13 de Sept. de 2018
Respondida: Pratyush el 25 de Jun. de 2023
I have many datasets for PCA calculations, because the data is too large for the matrix covariance calculation. how can the results of the covariance matrix be stored in several matrix so that they are not too large if stored in one matrix? or is there another way to be able to calculate eigenvalues without manually looking for the covariance value of the matrix?
  1 comentario
hossein najafi
hossein najafi el 18 de Mayo de 2019
hi
I have the same problem. Could you find the solution?

Iniciar sesión para comentar.

Respuestas (1)

Pratyush
Pratyush el 25 de Jun. de 2023
Hi Yusuf.
It is my understanding that you have a large dataset and you would like to store the covariance of each field against the other in several matrices instead of one. Here is how we can achieve it.
MATLAB has a function named "cov" that returns the covariance based on what is passed as parameters to the function. Say we have two vectors a and b. Then cov(a,b) computes the covariance matrix of the two vectors which is a 2x2 matrix. The individual entries of the matrix have the following meaning.
cov(a,a) cov(a,b)
cov(b,a) cov(b,b)
The entry on the first row and second column is the covariance between the two vectors a and b.
In the case with large dataset, we can iteratively compute the covariances between all possible pairs of fields and store them as separately. For example in one vector we can store the covariances of the first field with all other fields. In the second vector we can store the covariances of the second field with all other fields, and so on.
Hope this resolves your problem.
Here is the documentation on the cov function in MATLAB.

Categorías

Más información sobre Dimensionality Reduction and Feature Extraction en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by