15分钟
从数值区间创建
np.arange([start,] stop[, step,][, dtype])
:返回均匀间隔的值组成的一维ndarray
。区间是半闭半开的[start,stop)
,其采样行为类似Python的range
函数。start
为开始点,stop
为终止点,step
为步长,默认为1。这几个数可以为整数可以为浮点数。注意如果step
为浮点数,则结果可能有误差,因为浮点数相等比较不准确。np.linspace(start, stop[, num, endpoint, ...])
:返回num
个均匀采样的数值组成的一维ndarray
(默认为50)。区间是闭区间[start,stop]
。endpoint
为布尔值,如果为真则表示stop
是最后采样的值(默认为True
),否则结果不包含stop
。retstep
如果为True
则返回结果包含采样步长step
,默认为True
。np.logspace(start, stop[, num, endpoint, base, ...])
:返回对数级别上均匀采样的数值组成的一维ndarray
。采样点开始于base^start
,结束于base^stop
。base
为对数的基,默认为 10。- 它逻辑上相当于先执行
arange
获取数组array
,然后再执行base^array[i]
获取采样点 - 它没有
retstep
关键字参数
- 它逻辑上相当于先执行
学员评价