Starting value of the NumPy array.
import numpy as np
arr = np.logspace(start=0, stop=2, num=5, base=10.0)
# Both 'start' & 'stop' are included as endpoint=True
print(arr)
'''
Output:
[ 1. 3.16227766 10. 31.6227766 100. ]
'''
Firstly the values are converted into np.linspace() and the base value is raised to the power of the returned linspace values.
The values in the above array are - [10.00.0, 10.00.5, 10.01.0, 10.01.5, 10.02.0]
End of the interval value of the NumPy array.
import numpy as np
arr = np.logspace(start=0, stop=1, num=5)
# Both 'start' & 'stop' are included as endpoint=True
print(arr)
'''
Output:
[ 1. 1.77827941 3.16227766 5.62341325 10. ]
'''
If stop > start, an array is returned with data in decreasing order.
If stop < start, an array is returned with data in ascending order.
If stop = start, an array of basestart is returned.
If endpoint is set to True, stop value is included in the returned NumPy array.
The desired data-type for the NumPy array is inferred from the dtype specified.
import numpy as np
arr = np.logspace(start=0, stop=4, num=5, dtype=np.int32)
# Both 'start' & 'stop' are included
print(arr)
'''
Output:
[ 1 10 100 1000 10000]
'''
np.int8: 8-bit signed integer (range: -128 to 127).
np.int16: 16-bit signed integer (range: -32,768 to 32,767).
np.int32: 32-bit signed integer (range: -2,147,483,648 to 2,147,483,647).
np.int64: 64-bit signed integer (large integer range).
np.uint8: 8-bit unsigned integer (range: 0 to 255).
np.uint16: 16-bit unsigned integer (range: 0 to 65,535).
np.uint32: 32-bit unsigned integer (range: 0 to 4,294,967,295).
np.uint64: 64-bit unsigned integer (large positive integer range).
np.float16: Half precision floating-point (16-bit, for low-precision computations).
np.float32: Single precision floating-point (32-bit).
np.float64: Double precision floating-point (64-bit, the default float in NumPy).
np.float128: Extended precision floating-point (128-bit, availability depends on system).
np.complex64: Complex number represented by two 32-bit floats (for real and imaginary parts).
np.complex128: Complex number represented by two 64-bit floats (default complex dtype).
np.complex256: Complex number represented by two 128-bit floats (system-dependent).
np.bool_: Boolean type, can be either True or False (stored as 1-bit but takes up a full byte).
np.str_: Fixed-length Unicode string, specified by S + length (e.g., S10 for a 10-character string).
np.unicode_: Fixed-length Unicode string with support for multiple characters (uses U).
np.object_: Allows storing any Python object, including mixed types, strings, or other arrays. Useful for heterogeneous data but slower than native NumPy types.
np.datetime64: Stores dates and times with varying precisions (e.g., Y, M, D, h, m, s, ms, us, ns, ps, fs, as). Example: np.datetime64('2003-10-02')
np.timedelta64: Represents time durations with units (same units as datetime64).
By passing the dtype, you are implicitly converting the values to the passed dtype.
The axis in the result to store the samples. Relevant only if start or stop are array-like.
A new NumPy array is returned with values generated along rows (number of rows = num).
A new NumPy array is returned with values along the columns instead of rows, which can be especially useful in multidimensional arrays.
axis is only useful when dealing with array-like input.
Plays a vital role in transformation of the input along your axis (columns or rows).