np.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)
在间隔start和stop之间返回num个均匀间隔的数据。

Parameters:

start: array_like
	序列的起始值
stop: array_like
	序列的结束值
num: int, optional
	要生成的样本数,默认值为50,必须为非负数
endpoint: bool, optional
	如果为True,则包含stop
	如果为False,则不包含stop
retstep: bool, optional
	如果为True,返回('samples', 'step'),其中step是samples之间的间隔
dtype: dtype, optional
	输出数组的类型
	如果没有给出,将通过start和stop进行推断
	永远不会推断为int,即使给定的参数会生成整数数组,也将被推断成float

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)
(array([2.  ,  2.25,  2.5 ,  2.75,  3.  ]), 0.25)
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐