![](https://secure.gravatar.com/avatar/beebe07772844149dcd47e23e5276e72.jpg?s=120&d=mm&r=g)
Hi, I am wondering a bit about the the behaviour of logspace: Definition: numpy.logspace(start, stop, num=50, endpoint=True, base=10.0) Reading this I would assume that numpy.logspace(10**-12, 0.0, 100) gives 100 values, from start=10**-12 to stop=0.0, equispaced on a logarithmic scale. But this is not the case. Instead one has to do: numpy.logspace(-12, 0.0, 100) Docstring: Evenly spaced numbers on a logarithmic scale. Computes int(num) evenly spaced exponents from start to stop. If endpoint=True, then last exponent is stop. Returns base**exponents. My impression is that only the very last line is clearly saying what logspace does. And of course the code itself: y = linspace(start,stop,num=num,endpoint=endpoint) return _nx.power(base,y) Possible solutions (see below): a) modify logspace so that numpy.logspace(10**-12, 0.0, 100) works b) keep the current behaviour and improve the doc-string I would be interested in opinions on this. Best, Arnd Possible solution for (a) (no error checking yet): def logspace_modified(start, stop, num=50, endpoint=True): """Evenly spaced numbers on a logarithmic scale. Computes `num` evenly spaced numbers on a logarithmic scale from `start` to `stop`. If endpoint=True, then last exponent is `stop`. """ lstart = log(start) lstop = log(stop) y = linspace(lstart, lstop, num=num, endpoint=endpoint) return exp(y) Possible improvent of the doc-string (b) - due to Lars Bittrich: def logspace(start,stop,num=50,endpoint=True,base=10.0): """Evenly spaced numbers on a logarithmic scale. Return 'int(num)' evenly spaced samples on a logarithmic scale from 'base'**'start' to 'base'**'stop'. If 'endpoint' is True, the last sample is 'base'**'stop'."""
![](https://secure.gravatar.com/avatar/39916bae984cb93b797efd2b175f59c0.jpg?s=120&d=mm&r=g)
On Fri, 30 Jun 2006, T) Arnd Baecker wrote:
I am wondering a bit about the the behaviour of logspace:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/logspace.html fwiw, Alan Isaac
![](https://secure.gravatar.com/avatar/beebe07772844149dcd47e23e5276e72.jpg?s=120&d=mm&r=g)
Hi Alan, sorry, for answering so late - your message slipped through ... On Fri, 30 Jun 2006, Alan Isaac wrote:
Alright, if one wants to keep compatibility with matlab, the behaviour of logspace should be unchanged. I'd suggest that something along def logspace(start,stop,num=50,endpoint=True,base=10.0): """Evenly spaced numbers on a logarithmic scale. Return 'int(num)' evenly spaced samples on a logarithmic scale from 'base'**'start' to 'base'**'stop'. If 'endpoint' is True, the last sample is 'base'**'stop'.""" is clearer than the present one Docstring: Evenly spaced numbers on a logarithmic scale. Computes int(num) evenly spaced exponents from start to stop. If endpoint=True, then last exponent is stop. Returns base**exponents. (Note that I am not a native speaker - surprise - ; so maybe the present one is already clear enough?) Best, Arnd
![](https://secure.gravatar.com/avatar/39916bae984cb93b797efd2b175f59c0.jpg?s=120&d=mm&r=g)
On Fri, 30 Jun 2006, T) Arnd Baecker wrote:
I am wondering a bit about the the behaviour of logspace:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/logspace.html fwiw, Alan Isaac
![](https://secure.gravatar.com/avatar/beebe07772844149dcd47e23e5276e72.jpg?s=120&d=mm&r=g)
Hi Alan, sorry, for answering so late - your message slipped through ... On Fri, 30 Jun 2006, Alan Isaac wrote:
Alright, if one wants to keep compatibility with matlab, the behaviour of logspace should be unchanged. I'd suggest that something along def logspace(start,stop,num=50,endpoint=True,base=10.0): """Evenly spaced numbers on a logarithmic scale. Return 'int(num)' evenly spaced samples on a logarithmic scale from 'base'**'start' to 'base'**'stop'. If 'endpoint' is True, the last sample is 'base'**'stop'.""" is clearer than the present one Docstring: Evenly spaced numbers on a logarithmic scale. Computes int(num) evenly spaced exponents from start to stop. If endpoint=True, then last exponent is stop. Returns base**exponents. (Note that I am not a native speaker - surprise - ; so maybe the present one is already clear enough?) Best, Arnd
participants (2)
-
Alan Isaac
-
Arnd Baecker