How to create an evenly spaced array of values in log scale from 10^-2 to 10^3 using python?
current code:
In[1]: np.logspace(0.01,1000.,endpoint = True, base = 10.0)
C:\Users\harris.c.6\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\core\function_base.py:279: RuntimeWarning: overflow encountered in power
return _nx.power(base, y)
Out[1]:
array([1.02329299e+000, 2.61793695e+020, 6.69758706e+040, 1.71347413e+061,
4.38365871e+081, 1.12149132e+102, 2.86916221e+122, 7.34030804e+142,
1.87790436e+163, 4.80432804e+183, 1.22911307e+204, 3.14449581e+224,
8.04470650e+244, 2.05811381e+265, 5.26536608e+285, 1.34706253e+306,
inf, inf, inf, inf,
inf, inf, inf, inf,
inf, inf, inf, inf,
inf, inf, inf, inf,
inf, inf, inf, inf,
inf, inf, inf, inf,
inf, inf, inf, inf,
inf, inf, inf, inf,
inf, inf])
The
startandstoparguments oflogspaceare the exponents of the endpoints in the specified base. So you wantnp.logspace(-2, 3, endpoint=True, base=10). Also,endpoint=Trueandbase=10are the default values so you don't need to specify them.