numpy之linspace()
numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)
功能:
创建等差数列,范围在start和stop之间,数量为num个,其中start和stop分别会占用一个。
即bins=np.linspace(0,10,10)时,等差数列差值为10/9
代码示例如下:
>>> bins=np.linspace(0,10,10)
>>> bins
array([ 0. , 1.11111111, 2.22222222, 3.33333333, 4.44444444,
5.55555556, 6.66666667, 7.77777778, 8.88888889, 10. ])
>>>
>>> bins=np.linspace(0,10,11)
>>> bins
array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
>>>