np.dot()计算两个变量的乘积
np.dot()计算两个变量的乘积,返回的是一个值
import numpy as np np.dot(a, b, out=None) #该函数的作用是获取两个元素a,b的乘积.
a,b可以是数组或者int
print(np.dot(1,10)) #10
还可以
import numpy as np np.random.seed(20200623) x, y = np.random.randint(0, 20, size=(2, 4)) print(x) # [10 2 1 1] print(y) # [16 18 11 10] z = np.corrcoef(x, y) print(z) # [[1. 0.48510096] # [0.48510096 1. ]] a = np.dot(x - np.mean(x), y - np.mean(y)) b = np.sqrt(np.dot(x - np.mean(x), x - np.mean(x))) c = np.sqrt(np.dot(y - np.mean(y), y - np.mean(y))) print(a / (b * c)) # 0.4851009629263671