def vector_correlation(vect1,vect2):
"""
Compute correlation between two vector, which is the the cosine of the angle between two vectors in Euclidean space of any number of dimensions.
The dot product is directly related to the cosine of the angle between two vectors if they are normed !!!
"""
# -- We make sure that we have normed vectors.
from numpy.linalg import norm
if (np.round(norm(vect1)) != 1.):
vect1 = vect1/norm(vect1)
if (np.round(norm(vect2)) != 1.):
vect2 = vect2/norm(vect2)
return np.round(np.dot(vect1,vect2),3)
spatial_image_analysis.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录