I am trying to get 1000 numbers logarithmically spaced between two floats (say between 0.674 to 100.0) using python. Purpose of this was to get more numbers closer to 0.674 and after than just few large numbers near 100. I tried using 'numpy.logspace' function like following
NumberRange = np.logspace(0.674, 100.0, num=1000)
But it was giving result with these numbers as exponents. I want numbers between two floats but spaced logarithmically.
I have already checked this post but it was confusing.
The first two arguments of numpy.logspace
are the exponents of the limits. Use
NumberRange = np.logspace(np.log10(0.674), np.log10(100.0), num=1000)
Recent versions of NumPy have the function geomspace
, which takes the values of the endpoints rather than their logarithms:
NumberRange = np.geomspace(0.674, 100.0, num=1000)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With