# Return evenly spaced numbers on a log scale and do not set the endpoint in Numpy

NumpyServer Side ProgrammingProgramming

To return evenly spaced numbers on a log scale, use the numpy.logspace() method in Python Numpy. The 1st parameter is the "start" i.e. the start of the sequence. The 2nd parameter is the "end" i.e. the end of the sequence. The 3rd parameter is the "num" i.e. the number of samples to generate. Default is 50. The 4th parameter is the "endpoint". If True, stop is the last sample. Otherwise, it is not included. Default is True.

In linear space, the sequence starts at base ** start (base to the power of start) and ends with base ** stop (see endpoint below). The start is the base ** start is the starting value of the sequence. The stop is the base ** stop is the final value of the sequence, unless endpoint is False. In that case, num + 1 values are spaced over the interval in log-space, of which all but the last are returned. The base of the log space. The step size between the elements in ln(samples) / ln(base) (or log_base(samples)) is uniform. Default is 10.0.

The axis in the result to store the samples. Relevant only if start or stop are array-like. By default (0), the samples will be along a new axis inserted at the beginning. Use -1 to get an axis at the end.

## Steps

At first, import the required library −

import numpy as np

To return evenly spaced numbers on a log scale, use the numpy.logspace() method −

arr = np.logspace(100.5, 200.7, num = 10, endpoint = False)
print("Array...\n", arr)

Get the array type −

print("\nType...\n", arr.dtype)

Get the dimensions of the Array −

print("\nDimensions...\n",arr.ndim)

Get the shape of the Array −

print("\nShape...\n",arr.shape)


Get the number of elements −

print("\nNumber of elements...\n",arr.size)

## Example

import numpy as np

# To return evenly spaced numbers on a log scale, use the numpy.logspace() method in Python Numpy
# The 1st parameter is the "start" i.e. the start of the sequence
# The 2nd parameter is the "end" i.e. the end of the sequence
# The 3rd parameter is the "num" i.e the number of samples to generate. Default is 50.
# The 4th parameter is the "endpoint". If True, stop is the last sample. Otherwise, it is not included. Default is True.
arr = np.logspace(100.5, 200.7, num = 10, endpoint = False)
print("Array...\n", arr)

# Get the array type
print("\nType...\n", arr.dtype)

# Get the dimensions of the Array
print("\nDimensions...\n",arr.ndim)

# Get the shape of the Array
print("\nShape...\n",arr.shape)

# Get the number of elements
print("\nNumber of elements...\n",arr.size)

## Output

Array...
[3.16227766e+100 3.31131121e+110 3.46736850e+120 3.63078055e+130
3.80189396e+140 3.98107171e+150 4.16869383e+160 4.36515832e+170
4.57088190e+180 4.78630092e+190]

Type...
float64

Dimensions...
1

Shape...
(10,)

Number of elements...
10
Updated on 16-Feb-2022 09:55:54