import numpy as np
arr = [1,2,3,4,5,6]
#求均值
arr_mean = np.mean(arr)
#求方差
arr_var = np.var(arr)
#求标准差
arr_std = np.std(arr,ddof=1)
print("平均值为:%f" % arr_mean)
print("方差为:%f" % arr_var)
print("标准差为:%f" % arr_std)
from numpy import array
from numpy import cov
x = array([1,2,3,4,5,6,7,8,9])
print(x)
y = array([9,8,7,6,5,4,3,2,1])
print(y)
Sigma = cov(x,y)[0,1]
print(Sigma)
# [1 2 3 4 5 6 7 8 9]
# [9 8 7 6 5 4 3 2 1]
# -7.5
from scipy import stats
# two sample rank test
def sig_spearman_corr(x,y):
p=stats.spearmanr(x,y)[0]
return p
def sig_pearson_corr(x,y):
p=stats.pearsonr(x,y)[0]
return p