![]() |
VOOZH | about |
The numpy.logspace() function is used to generate numbers that are evenly spaced on a logarithmic scale. Instead of creating values with equal linear differences, this function generates values that are evenly spaced according to powers of a base value.
Example: The following example demonstrates how to generate logarithmically spaced values using logspace().
[ 100. 177.827941 316.22776602 562.34132519 1000. ]
Explanation:
numpy.logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None)
Parameters:
Return Type: ndarray
By default, logspace() uses base 10. This can be changed using the base parameter.
[ 121. 220.36039471 401.31159963 730.8527479 1331. ]
Explanation:
The output array can be converted to a specific data type using the dtype parameter.
[ 100 177 316 562 1000]
Explanation: dtype=int converts float values to integers and decimal values are removed during conversion.
This example demonstrate how to visualize logarithmically spaced values using pylab for a better visualized understanding of their distribution.
Output
Explanation: