numpy等间距向量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import numpy as np


#5是样本数
a = np.linspace(0, 10.0, num=6)#封装
A = np.array([0, 2, 4, 6, 8, 10])#实现

if a.all() == A.all() :
print("a==A\n",a)


# endpoint?求间隔,5是步长
b = np.linspace(0,10,num=5,endpoint=False)
B = np.array([i for i in range(0,10, int((10-0)/5) )])
if b.all()==B.all():
print("b==B\n", b)

转载请注明来源 https://tianweiye.github.io