Covariance
7 次查看(过去 30 天)
显示 更早的评论
Hi,
quick question: can someone confirm that Matlab doesn't give back correct results for 'cov ? Example is here: http://www.mathworks.ch/help/techdoc/ref/cov.html
I calculated by hand and excel. I think there's something. Need the covariance for the financial toolbox.
Thanks a lot Ben
2 个评论
David Young
2012-3-13
If you think the example has the wrong result, what do you think the correct result should be, according to your hand calculation and excel?
David Young
2012-3-14
Thanks for the information (though perhaps better to edit the question than to add an answer). I think Oleg has the explanantion.
采纳的回答
nor
2012-3-26
Matrix A in the example has 3 rows which represents 3 observations. In your case,if you use: a) cov(A) this command will divide by 2 i.e (N-1), giving you 10.3333 for the first element in the covariance matrix.
b)cov(A,1) this command will divide by 3 i.e (N), giving you the same result as you obtain in Excel. Hope this helps.
0 个评论
更多回答(4 个)
Oleg Komarov
2012-3-14
You should read the documentation thoroughly:
cov(A,1)
is the population covariance (divides by N), while
cov(A)
is the sample covariance (divides by N-1)
By default, the functions cov, var and std compute the sample statistic.
0 个评论
Sean Lawson
2012-3-13
I used MATLAB cov and don't experience a wrong answer. Maybe you could post your example here if you cannot find anything wrong.
1 个评论
Chinmayee L M
2021-7-19
I didn't quite understand the terminology used in the documentation. Could someone clarify?
The documentation reads:
"If A is a matrix whose columns represent random variables and whose rows represent observations, C is the covariance matrix with the corresponding column variances along the diagonal."
If I have 10 time series with 400 samples, how should the matrix be organised before taking covariance?
a. 10 x 400
b. 400 x 10
Thanks
1 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!