回顾向量基础知识及在python中的应用
1.向量的点乘,计算两个空间向量的夹角
python代码:
import numpy as np
vector_OS = np.array([1, 2, 3])
vector_OM = np.array([8, 9, 10])
vector_MS = vector_OS - vector_OM
# r = np.linalg.norm(vector_MS)#range,spectral norm = 2
l_vector_OS = np.sqrt(vector_OS.dot(vector_OS))
l_vector_OM = np.sqrt(vector_OM.dot(vector_OM))
l_vector_MS = np.sqrt(vector_MS.dot(vector_MS))#range
theta = np.arccos((vector_OS.dot(vector_MS))/(l_vector_OS*l_vector_MS))#radians
计算出的角度单位为弧度制。
2.在python中某个数的10的多少次方:Ne10
表示N的10的10次方。
3.在数组中用sin()函数,不能调用math.sin,要用np.sin
。
如想计算这个公式:
代码:PTR = np.square(np.sin((math.pi)*B*t)/((math.pi)*B*t))
4.numpy.exp()函数https://blog.csdn.net/lixc316/article/details/89152745
def sigmoid(z):
return 1 / (1 + np.exp(-z))