[Numpy-discussion] step paramter for linspace

Sebastian Berg sebastian at sipsolutions.net
Fri Mar 1 07:44:05 EST 2013

On Fri, 2013-03-01 at 12:33 +0000, Henry Gomersall wrote:
> On Fri, 2013-03-01 at 13:25 +0100, Sebastian Berg wrote:
> > there has been a request on the issue tracker for a step parameter to
> > linspace. This is of course tricky with the imprecision of floating
> > point numbers.
> How is that different to arange? Either you specify the number of points
> with linspace, or you specify the step with arange. Is there a third
> option?
> My usual hack to deal with the numerical bounds issue is to add/subtract
> half the step.

There is not much. It does that half step logic for you, and you
actually know that the end point is exact (since linspace makes sure of

In arange, the start and step are exact. In linspace the start and stop
are exact (even with a given step, it would vary on the order of
floating point accuracy).

Maybe the larger point is the hope that by adding this to linspace it is
easier to get new users to use it and avoid pitfalls of arange with
floating points when you are not aware of that half step thing.

> Henry
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

More information about the NumPy-Discussion mailing list