ответвлено от main/python-labs
18 строки
310 B
Python
18 строки
310 B
Python
import math
|
|
import statistics as st
|
|
def correlation(list1, list2):
|
|
n = min(len(list1), len(list2))
|
|
x = list1[:n]
|
|
y = list2[:n]
|
|
|
|
Xsr = st.mean(x)
|
|
Ysr = st.mean(y)
|
|
|
|
cov = st.covariance(x,y)
|
|
|
|
Xso = st.stdev(x)
|
|
Yso = st.stdev(y)
|
|
|
|
R_paired = cov / ( Xso*Yso)
|
|
return R_paired
|