Change language

numpy.logspace () in Python

| | |

About:
numpy.logspace (start, stop, num = 50, endpoint = True, base = 10.0, dtype = None): returns numeric spaces evenly across the interval on a log scale. 
Parameters :

 -"  start:  [float] start (base ** start) of interval range. -"  stop:  [float] end (base ** stop) of interval range -"  endpoint:  [boolean, optional] If True, stop is the last sample. By default, True -"  num:  [int, optional] No. of samples to generate -"  base:  [float, optional] Base of log scale. By default, equals 10.0 -"  dtype:  type of output array 

Return:

 -"  ndarray  


Code 1: Explaining the use of logspace ()

# Python Programming Illustrative
# numpy.logspace method

  

import numpy as geek

 
# base = 11

print ( "B" , geek.logspace ( 2.0 , 3.0 , num = 5 , base = 11 ))

  
# base = 10

print ( "B" , geek.logspace ( 2.0 , 3.0 , num = 5 ))

 
# base = 10, dtype = int

print ( "B" , geek.logspace ( 2.0 , 3.0 , num = 5 , dtype = int ))

Exit :

 B [121. 220.36039471 401.31159963 730.8527479 1331.] B [100. 177.827941 316.22776602 562.34132519 1000.] B [100 177 316 562 1000] 

Code 2: Plotting numpy.logspace () using the matplotlib module — pylab

# Graphical representation of numpy.logspace ()

import numpy as geek

import pylab as p

 
# Start = 0
# End = 2
# Samples to generate = 10

x1 = geek.logspace ( 0 , 1 , 10 )

y1 = geek.zeros ( 10 )

  
# Start = 0,1
# End = 1.5
# Samples to generate = 12

x2 = geek.logspace ( 0.1 , 1.5 , 12 )

y2 = geek.zeros ( 12 )

 

p.plot (x1, y1 + 0.05 , ’o’ )

p.xlim ( - 0.2 , 18 )

p.ylim ( - 0.5 , 1 )

p.plot (x2, y2, ’x’ )

Output:

Notes:
These programs are NumPy- Python won’t work by onlineID, so run them on your systems to learn them

Similar methods:

  • arange
  • Shop

    Learn programming in R: courses

    $

    Best Python online courses for 2022

    $

    Best laptop for Fortnite

    $

    Best laptop for Excel

    $

    Best laptop for Solidworks

    $

    Best laptop for Roblox

    $

    Best computer for crypto mining

    $

    Best laptop for Sims 4

    $

    Latest questions

    NUMPYNUMPY

    psycopg2: insert multiple rows with one query

    12 answers

    NUMPYNUMPY

    How to convert Nonetype to int or string?

    12 answers

    NUMPYNUMPY

    How to specify multiple return types using type-hints

    12 answers

    NUMPYNUMPY

    Javascript Error: IPython is not defined in JupyterLab

    12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method