[SciPy-user] logspace

Alan G Isaac aisaac at american.edu
Tue Dec 6 19:32:35 CST 2005


Proposed redefinition of logspace:

def logspace(start,stop,num=50,endpoint=True,base=10.0):
    """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.
    """
    y = linspace(start,stop,num=int(num),endpoint=endpoint)
    return _nx.power(base,y)

Alan Isaac

PS The current defintion follows:

def logspace(start,stop,num=50,endpoint=1):
    """ Evenly spaced samples on a logarithmic scale.

        Return num evenly spaced samples from 10**start to 10**stop.  If
        endpoint=1 then last sample is 10**stop.
    """
    if num <= 0: return array([])
    if endpoint:
        step = (stop-start)/float((num-1))
        y = _nx.arange(0,num) * step + start
    else:
        step = (stop-start)/float(num)
        y = _nx.arange(0,num) * step + start
    return _nx.power(10.0,y)




More information about the SciPy-user mailing list