- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Return evenly spaced numbers on a log scale and set the base in Numpy

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 "base" i.e. the base of the log space. The step size between the elements in ln(samples) / ln(base) (or log_base(samples)) is uniform.

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. The 1st parameter is the "start" i.e. the start of the sequence −

arr = np.logspace(10.0, 20.0, num = 3, base = 2.0) print("Array...

", arr)

Get the array type −

print("

Type...

", arr.dtype)

Get the dimensions of the Array −

print("

Dimensions...

",arr.ndim)

Get the shape of the Array −

print("

Shape...

",arr.shape)

Get the number of elements −

print("

Number of elements...

",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 "base" i.e. 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. arr = np.logspace(10.0, 20.0, num = 3, base = 2.0) print("Array...

", arr) # Get the array type print("

Type...

", arr.dtype) # Get the dimensions of the Array print("

Dimensions...

",arr.ndim) # Get the shape of the Array print("

Shape...

",arr.shape) # Get the number of elements print("

Number of elements...

",arr.size)

## Output

Array... [1.024000e+03 3.276800e+04 1.048576e+06] Type... float64 Dimensions... 1 Shape... (3,) Number of elements... 3

- Related Articles
- Return evenly spaced numbers on a log scale and do not set the endpoint in Numpy
- Return evenly spaced numbers over a log scale in Numpy
- Return evenly spaced numbers on a log scale and set the number of samples to generate in Numpy
- Return numbers spaced evenly on a geometric progression in Numpy
- Return evenly spaced numbers on a geometric progression and do not set the endpoint in Numpy
- Return evenly spaced numbers on a geometric progression and set the number of samples to generate in Numpy
- Return evenly spaced numbers over a specified interval in Numpy
- Return evenly spaced numbers over a specified interval and do not set the endpoint in Numpy
- Return numbers spaced evenly on a geometric progression but with negative inputs in Numpy
- Return numbers spaced evenly on a geometric progression but with complex inputs in Numpy
- Return evenly spaced numbers over a specified interval and set the number of samples to generate in Numpy
- Return evenly spaced values within a given interval in Numpy
- Return evenly spaced values within a given interval and step size in Numpy
- Fill the area under a curve in Matplotlib python on log scale
- How do I show logarithmically spaced grid lines at all ticks on a log-log plot using Matplotlib?