Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Numpy exercise
  • pandas
  • Matplotlib
  • Data visulisation
  • EDA
  • Machin Learning
  • Deep Learning
  • NLP
  • Data science
  • ML Tutorial
  • Computer Vision
  • ML project
Open In App
Next Article:
numpy.geomspace() in Python
Next article icon

numpy.geomspace() in Python

Last Updated : 31 May, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

numpy.geomspace() is used to return numbers spaced evenly on a log scale (a geometric progression). 
This is similar to numpy.logspace() but with endpoints specified directly. Each output sample is a constant multiple of the previous. 
 

Syntax : numpy.geomspace(start, stop, num=50, endpoint=True, dtype=None)
Parameters : 
start : [scalar] The starting value of the sequence. 
stop : [scalar] 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 (a sequence of length num) are returned. 
num : [integer, optional] Number of samples to generate. Default is 50. 
endpoint : [boolean, optional] If true, stop is the last sample. Otherwise, it is not included. Default is True. 
dtype : [dtype] The type of the output array. If dtype is not given, infer the data type from the other input arguments.
Return : 
samples : [ndarray] num samples, equally spaced on a log scale. 
 


Code #1 : Working 
 

Python
# Python3 Program demonstrate # numpy.geomspace() function  import numpy as geek   print("B\n", geek.geomspace(2.0, 3.0, num = 5), "\n")  # To evaluate sin() in long range  point = geek.geomspace(1, 2, 10) print("A\n", geek.sin(point)) 

Output : 
 

B  [ 2.          2.21336384  2.44948974  2.71080601  3.        ]   A  [ 0.84147098  0.88198596  0.91939085  0.95206619  0.9780296   0.9948976   0.99986214  0.98969411  0.96079161  0.90929743]


  
Code #2 : Graphical Representation of numpy.geomspace() 
 

Python
# Graphical Representation of numpy.geomspace() import numpy as geek  import pylab as p  % matplotlib inline    # Start = 1  # End = 3   # Samples to generate = 10  x1 = geek.geomspace(1, 3, 10, endpoint = False)  y1 = geek.ones(10)     p.plot(x1, y1, '+')  

Output : 
 


 


Next Article
numpy.geomspace() in Python

J

jana_sayantan
Improve
Article Tags :
  • Python
  • Python-numpy
  • Python numpy-arrayCreation
Practice Tags :
  • python

Similar Reads

    numpy.logspace() in Python
    The numpy.logspace() function returns number spaces evenly w.r.t interval on a log scale. Syntax :   numpy.logspace(start, stop, num = 50, endpoint = True, base = 10.0, dtype = None) Parameters :  -> start : [float] start(base ** start) of interval range. -> stop : [float] end(base ** stop) of
    2 min read
    NumPy Array in Python
    NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C
    2 min read
    numpy.atleast_3d() in Python
    numpy.atleast_3d() function is used when we want to Convert inputs to arrays with at least three dimension. Scalar, 1 and 2 dimensional inputs are converted to 3-dimensional arrays, whilst higher-dimensional inputs are preserved. Input includes scalar, lists, lists of tuples, tuples, tuples of tuple
    2 min read
    numpy.atleast_2d() in Python
    numpy.atleast_2d() function is used when we want to Convert inputs to arrays with at least two dimension. Scalar and 1-dimensional inputs are converted to 2-dimensional arrays, whilst higher-dimensional inputs are preserved. Syntax : numpy.atleast_2d(*arrays) Parameters : arrays1, arrays2, ... : [ar
    2 min read
    Python NumPy
    Numpy is a general-purpose array-processing package. It provides a high-performance multidimensional array object, and tools for working with these arrays. It is the fundamental package for scientific computing with Python.Besides its obvious scientific uses, Numpy can also be used as an efficient m
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences