np.linspace() 函数用法
numpy.linspace | np.linspace 函数用法np.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)在间隔start和stop之间返回num个均匀间隔的数据。Parameters:start: array_like序列的起始值stop: array_like序列的结束值
·
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)
更多推荐
活动日历
查看更多
直播时间 2025-02-26 16:00:00


直播时间 2025-01-08 16:30:00


直播时间 2024-12-11 16:30:00


直播时间 2024-11-27 16:30:00


直播时间 2024-11-21 16:30:00


所有评论(0)