Is there a numpy function for generating sequences similar to R’s seq function?

Yes! An easy way to do this will be using numpy.linspace

Numpy Docs

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.

Example:

[In 1] np.linspace(start=0, stop=50, num=5)

[Out 1] array([  0. ,  12.5,  25. ,  37.5,  50. ])

Notice that the distance between the start and stop values is evenly spaced, i.e. evenly divided by num=5.

For those having problems installing numpy (a problem less common these days), you might look in to using anaconda (or miniconda), or some other similar distribution.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)