Why I get two different covariance matrix?
Afficher commentaires plus anciens
Hi all,
Prof. Andrew Ng in his ML class says that we can calculate covariance matrix as: 1/m*X'*X .
Where;
examples are in rows of X,
X' is transpose of X,
and, m is number of examples.
For example:
X=randi(12,[6,2]);
cov1=1/size(X,1)*X'*X
And, covariance with cov function is:
cov2=cov(X)
As you can see, cov1 is different from cov2 !!!
What is the reasan for that? Do you have any idea?
Thanks
Réponse acceptée
Plus de réponses (1)
4 commentaires
John D'Errico
le 14 Juil 2022
Modifié(e) : John D'Errico
le 14 Juil 2022
PLEASE DON"T ASK a new question as an answer to your own question! In fact, I won't answer a question posed as you have done, and I could probably do so.
ali yaman
le 14 Juil 2022
John D'Errico
le 14 Juil 2022
Modifié(e) : John D'Errico
le 14 Juil 2022
Since this is probably of some general interest, I'll actually post a question of my own, then answer it myself, discussing the relative issues between eig and svd.
ali yaman
le 14 Juil 2022
Catégories
En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!