numpy.linspace

2018-08-30  本文已影响27人  meowwzzz

Scipy.org -> Docs -> NumPy v1.15 Manual -> NumPy Reference -> Routines -> Array creation routines

numpy.linspace

numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)

Return evenly spaced numbers over a specified interval.
Returns num evenly spaced samples, calculated over the interval [start, stop].
The endpoint of the interval can optionally be excluded.
(即,返回指定区间[start,stop]内,均匀间隔的数值。num表示一共要获得多少数字。endpoint表示所得数字是否包含端点stop,默认包含。retstep表示是否给出数字之间的间隔值。dtype为数字的类型。)

Parameters:

New in version 1.9.0.

Returns:

Examples

>>> np.linspace(2.0, 3.0, num=5)
array([ 2.  ,  2.25,  2.5 ,  2.75,  3.  ])
>>> np.linspace(2.0, 3.0, num=5, endpoint=False) # 所选取的样本点不包含右端点。
array([ 2. ,  2.2,  2.4,  2.6,  2.8])
>>> np.linspace(2.0, 3.0, num=5, retstep=True) # 每两个样本点之间间隔0.25。
(array([ 2.  ,  2.25,  2.5 ,  2.75,  3.  ]), 0.25)
上一篇 下一篇

猜你喜欢

热点阅读