Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
你能帮我找到这两个列表在python中导入stats-model的相关性吗?
a=[1.0,2.0,3.0,2.0] b=[789.0,786.0,788.0,785.0]
使用一些内置函数
>>> import numpy as np >>> a = np.array([1.0,2.0,3.0,2.0]) >>> b = np.array([789.0,786.0,788.0,785.0]) >>> np.corrcoef(a,b) array([[ 1. , -0.2236068], [-0.2236068, 1. ]])
只需使用索引来提取正确的:
np.corrcoef(a,b)[0,1]