np.linspace allows you to define how many values you get including the specified min and max value. It infers the stepsize:

>>> np.linspace(0,1,11)
array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ])

np.arange allows you to define the stepsize and infers the number of steps(the number of values you get).

>>> np.arange(0,1,.1)
array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])

contributions from user2357112:

np.arange excludes the maximum value unless rounding error makes it do otherwise.

For example, the following results occur due to rounding error:

>>> numpy.arange(1, 1.3, 0.1)
array([1. , 1.1, 1.2, 1.3])

You can exclude the stop value (in our case 1.3) using endpoint=False:

>>> numpy.linspace(1, 1.3, 3, endpoint=False)
array([1. , 1.1, 1.2])
Answer from warped on Stack Overflow
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.5 Manual
>>> import numpy as np >>> np.linspace(2.0, 3.0, num=5) array([2. , 2.25, 2.5 , 2.75, 3. ]) >>> np.linspace(2.0, 3.0, num=5, endpoint=False) array([2. , 2.2, 2.4, 2.6, 2.8]) >>> np.linspace(2.0, 3.0, num=5, retstep=True) (array([2. , 2.25, 2.5 , 2.75, 3.
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-linspace
NumPy linspace() Method | Create Evenly Spaced Array - GeeksforGeeks
February 14, 2026 - DSA Python · Data Science · NumPy · Pandas · Practice · Django · Flask · Last Updated : 14 Feb, 2026 · The numpy.linspace() function is used to generate an array of evenly spaced values between two specified numbers.
Discussions

python - What is the difference between np.linspace and np.arange? - Stack Overflow
I have always used np.arange. I recently came across np.linspace. I am wondering what exactly is the difference between them... Looking at their documentation: np.arange: Return evenly spaced values More on stackoverflow.com
🌐 stackoverflow.com
python - Creating numpy linspace out of datetime - Stack Overflow
I'm writing a script that plots some data with dates on the x axis (in matplotlib). I need to create a numpy.linspace out of those dates in order to create a spline afterwards. Is it possible to d... More on stackoverflow.com
🌐 stackoverflow.com
Python Numpy Linspace function for bidimensional array - Stack Overflow
I know it is possible to create numpy arrays using the Linspace function. More on stackoverflow.com
🌐 stackoverflow.com
python - Why does np.linspace(1,5,5, dtype = int, endpoint=False) result in an array that contains 1 twice? - Stack Overflow
Or np.linspace(1, 5, 5, dtype=int) (endpoint = True which is the default). More on stackoverflow.com
🌐 stackoverflow.com
🌐
DataCamp
datacamp.com › home › tutorials › python › how to use the numpy linspace() function
How to Use the NumPy linspace() Function | DataCamp
April 5, 2024 - The linspace() function is a simple and efficient method for generating linearly spaced values, offering a useful solution for a variety of scenarios where specific numerical ranges are needed, such as in data visualization, simulations, and even in the fine-tuning of algorithms.
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
arange() and linspace() to generate evenly spaced values
February 2, 2024 - With np.linspace(), you can specify the number of elements instead of the interval.
🌐
Analytics Vidhya
analyticsvidhya.com › home › what is numpy.linspace() in python?
What is numpy.linspace() in Python? - Analytics Vidhya
February 2, 2024 - Visualizing Patterns and Trends ... a powerful function in Python’s NumPy library that allows you to create evenly spaced arrays with a specified number of elements....
Find elsewhere
🌐
Programiz
programiz.com › python-programming › numpy › methods › linspace
NumPy linspace() | Programiz
August 30, 2023 - The linspace() method returns an array of evenly spaced values.
🌐
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .linspace()
Python:NumPy | Built-in Functions | .linspace() | Codecademy
May 26, 2025 - The .linspace() function in NumPy creates an array of evenly spaced numbers over a specified interval.
🌐
YouTube
youtube.com › watch
Python NumPy | Linspace - YouTube
The NumPy linspace function returns evenly spaced numbers based on a specified interval. The interval by default includes the starting value and ending value...
Published: June 13, 2019
🌐
Medium
vandroidsri.medium.com › creating-array-using-linspace-932ed1866ba3
Creating Array using linspace(). If you want linearly and evenly spaced… | by Vandana Srivastava | Medium
July 22, 2024 - Python · Machine Learning · AI · Vandana Srivastava · 2 min read · ·Jul 22, 2024 · -- Listen · Share · If you want linearly and evenly spaced values in the specified interval between two values then we use linspace.
🌐
Medium
medium.com › @ilamuhil › python-numpy-linspace-bc0238125d7b
Python Numpy linspace. The np.linspace() function is a NumPy… | by ilamuhil | Medium
June 25, 2023 - The np.linspace() function returns an array of equally spaced values. The step between consecutive values is determined by (stop — start) / (num — 1).
🌐
JAX Documentation
docs.jax.dev › en › latest › _autosummary › jax.numpy.linspace.html
jax.numpy.linspace — JAX documentation
jax.numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0, *, device=None)[source]#
🌐
w3resource
w3resource.com › numpy › array-creation › linspace.php
NumPy: numpy.linspace() function - w3resource
April 22, 2026 - The numpy.linspace() function is used to create an array of evenly spaced numbers within a specified range.
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.3 Manual
>>> import numpy as np >>> np.linspace(2.0, 3.0, num=5) array([2. , 2.25, 2.5 , 2.75, 3. ]) >>> np.linspace(2.0, 3.0, num=5, endpoint=False) array([2. , 2.2, 2.4, 2.6, 2.8]) >>> np.linspace(2.0, 3.0, num=5, retstep=True) (array([2. , 2.25, 2.5 , 2.75, 3.
🌐
NumPy
numpy.org › devdocs › › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.6.dev0 Manual
>>> import numpy as np >>> np.linspace(2.0, 3.0, num=5) array([2. , 2.25, 2.5 , 2.75, 3. ]) >>> np.linspace(2.0, 3.0, num=5, endpoint=False) array([2. , 2.2, 2.4, 2.6, 2.8]) >>> np.linspace(2.0, 3.0, num=5, retstep=True) (array([2. , 2.25, 2.5 , 2.75, 3.
🌐
Universal Equations
uequations.com › en-us › article › articles › 2025-04 › understanding-numpy-linspace-function
Understanding The Numpy linspace Function | Universal Equations, Inc.
The numpy.linspace function is a versatile tool that generates an array of equally spaced values over a specified range.
Published: April 18, 2025
Views: 24K