欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python 獲取等間隔的數(shù)組實(shí)例

 更新時(shí)間:2019年07月04日 11:43:31   作者:無聊的六婆  
今天小編就為大家分享一篇python 獲取等間隔的數(shù)組實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

可以使用numpy中的linspace函數(shù)

np.linspace(start, stop, num, endpoint, retstep, dtype)
#start和stop為起始和終止位置,均為標(biāo)量
#num為包括start和stop的間隔點(diǎn)總數(shù),默認(rèn)為50
#endpoint為bool值,為False時(shí)將會(huì)去掉最后一個(gè)點(diǎn)計(jì)算間隔
#restep為bool值,為True時(shí)會(huì)同時(shí)返回?cái)?shù)據(jù)列表和間隔值
#dtype默認(rèn)為輸入變量的類型,給定類型后將會(huì)把生成的數(shù)組類型轉(zhuǎn)為目標(biāo)類型
np.linspace(1,3,num=4)
Out[17]: array([1.    , 1.66666667, 2.33333333, 3.    ])

np.linspace(1,3,num=4,endpoint=False)
Out[18]: array([1. , 1.5, 2. , 2.5])

np.linspace(1,3,num=4,endpoint=False,retstep=True)
Out[19]: (array([1. , 1.5, 2. , 2.5]), 0.5)

np.linspace(1,3,num=4,endpoint=False,retstep=True,dtype=float)
Out[20]: (array([1. , 1.5, 2. , 2.5]), 0.5)

np.linspace(1,3,num=4,endpoint=False,retstep=True,dtype=int)
Out[21]: (array([1, 1, 2, 2]), 0.5)

以上這篇python 獲取等間隔的數(shù)組實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論