您的当前位置:首页正文

numpy.linspace 等差数列,实现间隔采样

来源:图艺博知识网

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

Examples

"start--end--step(不能为负数)"#
>>> np.linspace(2.0, 3.0, num=5) 
array([ 2.  ,  2.25,  2.5 ,  2.75,  3.  ])

"start"--"end"--"step"--"是否包含end这个数(默认True)"#
 >>> np.linspace(2.0, 3.0, num=5, endpoint=False)        
 array([ 2. ,  2.2,  2.4,  2.6,  2.8])

"start"--"end"--"step"--"返回参数step(默认False)"#
>>> np.linspace(2.0, 3.0, num=5, retstep=True)
(array([ 2.  ,  2.25,  2.5 ,  2.75,  3.  ]), 0.25)
wuq.jpg
Top