两个向量之间的相关性与向量之间的角度 [英] Correlation between two vectors vs. angle between vectors

查看:559
本文介绍了两个向量之间的相关性与向量之间的角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图确定两个物体的运动是同相"还是彼此相反.所以基本上我有两个向量,R1,R2在R ^ 3中,我想知道它们是否指向同一方向".

I am trying to determine if the movement of two objects is "in phase" or opposing each other. So basically I have two vectors, R1, R2 in R^3 and I want to know if they "point in the same direction".

我可以想到两种计算方法: a)计算两个向量之间的角度.角度表示其对齐方式. b)计算两个向量之间的相关系数. (例如使用Matlab的corr函数)1表示它们是平行的,反平行是-1.如果它们是垂直的,我的确会得到正负0.5,这似乎是错误的.

I can think of two ways to compute that: a) Calculate the angle between the two vectors. The angle indicates their alignment. b) Calculate the correlation coefficient between the two vectors. (e.g. using Matlab's corr function) 1 means they are parallel, -1 antiparallel. If they are perpendicular I do get either plus or minus 0.5, which seems wrong.

使用这两种方法是否有所不同?我的直觉认为这两种方法应该相同,但是我不确定.任何人都有一些见识,这些方法的潜在差异/优势是什么? 谢谢!

Is there a difference in using the two methodologies? My gut feeling says that the two methods should be identical, but I am not sure. Anyone has some insights and what could be potential differences/advantages of the methods? Thanks!

推荐答案

最简单的方法是计算两个归一化向量之间的点积.反余弦值直接给出向量之间的角度.

This is most easily done by calculating the dot product between the two normalized vectors. The inverse cosine gives directly the angle between the vectors.

Matlab没有"corr"功能.它具有"xcorr".两个3元素向量之间的互相关是5元素向量.中间元素与点积相同,因此基本上是相同的计算.

Matlab doesn't have a "corr" function. It has "xcorr". The cross correlation between two 3 element vectors is a 5 element vector. The middle element of that is the same as the dot product, so it's basically the same calculation.

这篇关于两个向量之间的相关性与向量之间的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆