向量集的相关矩阵
我尝试计算一组直方图向量的相关矩阵。但结果是我(认为)想要的内容的删减版本。我有 200 个直方图,每个直方图有 32 个 bin。结果
correlation_matrix = corrcoef(set_of_histograms)
是一个 32 x 32 矩阵。
我想用它来计算我的原始直方图如何匹配。 (稍后使用 eigs 和其他东西)。
但哪种相关方法最适合这个呢?我尝试过“corrcoef”,但也有“corr”和“cov”。通过阅读matlab帮助无法理解它们的差异......
I try to calculate the correlation matrix of a set of histogram vectors. But the result is a truncated version of what I (think) I want. I have 200 histograms by 32 bins each. The result from
correlation_matrix = corrcoef(set_of_histograms)
is a 32 by 32 matrix.
I want to use this to calculate how my original histograms match up. (this by later using eigs and other stuff).
But which correlation method is right for this? I have tried "corrcoef" but there are "corr" and "cov" as well. Can't understand their differences by reading matlab help...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(注意
'
)(Note the
'
)1) corrcoef 将每一列视为一个观察值,并计算每对之间的相关性。我假设你的直方图矩阵是 200x32;因此,就您而言,每一行都是一个观察结果。如果您在运行 corrcoef 之前转置直方图矩阵,您应该得到您正在寻找的 200x200 结果:
[rho, p] = corrcoef( set_of_histograms' );
('转置矩阵)
2) cov 返回协方差矩阵,而不是相关性;虽然协方差矩阵用于计算相关性,但它不是您正在寻找的度量。
3)对于corr和corrcoef,它们之间有一些实现上的差异。只要您只对皮尔逊相关性感兴趣,它们对于您的目的来说是相同的。 corr 还可以选择计算 Spearman 或 Kendall 相关性,而 corrcoef 则没有。
1) corrcoef treats every column as an observation, and calculates the correlations between each pair. I'm assuming your histograms matrix is 200x32; hence, in your case, every row is an observation. If you transpose your histograms matrix before running corrcoef, you should get the 200x200 result you're looking for:
[rho, p] = corrcoef( set_of_histograms' );
(' transposes the matrix)
2) cov returns the covariance matrix, not the correlation; while the covariance matrix is used in calculating the correlation, it is not the measure you're looking for.
3) As for corr and corrcoef, they have a few implementation differences between them. As long as you are only interested in Pearson's correlation, they are identical for your purposes. corr also has an option to calculate Spearman's or Kendall's correlations, which corrcoef does not have.