How to calculate covariance matrix
30 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (1)
Pratyush
le 25 Juin 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.
0 commentaires
Voir également
Catégories
En savoir plus sur Dimensionality Reduction and Feature Extraction dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!