First page Back Continue Last page Overview Graphics

linspace

numpy.linspace(start, stop, num=50,

endpoint=True,

retstep=False,

dtype=None)

Return evenly spaced numbers over a specified interval. Returns 'num' evenly spaced samples, calculated over the interval ['start', 'stop' ]. The endpoint of the interval can optionally be excluded.

Examples:

>>> start, stop, number_of_points = 0, 10, 6

>>> np.linspace(start, stop, number_of_points)

array([ 0., 2., 4., 6., 8., 10.])

>>> np.linspace(start, stop, 6, endpoint=False)

Array([ 0. , 1.66666667, 3.33333333, 5. , 6.66666667, 8.33333333])

>>> samples, spacing = np.linspace(1, 10, 20, endpoint=False, retstep=True)

>>> print(spacing)

0.45