numpy.logspace()

It creates an array by using the numbers that are evenly separated on a log scale.

Syntax

snippet
numpy.logspace(start, stop, num, endpoint, base, dtype)

Parameters

It accepts the following parameters.

  1. start: It represents the starting value of the interval in the base.
  2. stop:It represents the stopping value of the interval in the base.
  3. num:The number of values between the range.
  4. endpoint:It is a boolean type value. It makes the value represented by stop as the last value of the interval.
  5. base:It represents the base of the log space.
  6. dtype:It represents the data type of the array items.

Return

An array within the specified range is returned.

Example 1

snippet
import numpy as np
arr = np.logspace(10, 20, num = 5, endpoint = True)
print("The array over the given range is ",arr)

Output:

Output
The array over the given range is [1.00000000e+10 3.16227766e+12 1.00000000e+15 3.16227766e+17 1.00000000e+20]

Example 2

snippet
import numpy as np
arr = np.logspace(10, 20, num = 5,base = 2, endpoint = True)
print("The array over the given range is ",arr)

Output:

Output
The array over the given range is [1.02400000e+03 5.79261875e+03 3.27680000e+04 1.85363800e+05 1.04857600e+06]
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +