python取得などの間隔の配列例


numpyのlinspace関数が使用できます。

np.linspace(start, stop, num, endpoint, retstep, dtype)
#start stop        ,    
#num   start stop      ,   50
#endpoint bool , False              
#restep bool , True              
#dtype          ,                     

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取得などの間隔の配列例は、小編集が皆さんに提供した内容の全てです。参考にしていただければと思います。よろしくお願いします。