Details about how to create an equals series in linspace In the python numpy function, numpylinspace
Preface
This article describes how to create an equal-difference series in linspace. I will share the content for your reference and study. I will not talk about it here. Let's take a look at the details.
Numpy. linspace is used to create a one-dimensional array composed of an equal-difference series. It can use up to three parameters, of course, more than three.
In the first example, three parameters are used. The first parameter indicates the starting point, the second parameter indicates the ending point, and the third parameter indicates the number of series.
import numpy as npprint(np.linspace(1,10,10,endpoint=False))
Create an equal-difference sequence with all elements 1, or an equal-difference sequence with all elements 0.
import numpy as npprint(np.linspace(1,1,10))
You can use the endpoint parameter to determine whether to include the termination value. If this parameter is not set, the default value is True.
import numpy as npprint(np.linspace(1,10,10,endpoint=False))
You can also use two parameters to create an array. When two parameters are input, the first parameter indicates the starting point and the second parameter indicates the ending point. The default number is 50.
import numpy as npprint(np.linspace(1,50))
To verify that we use the three parameters, the results are obviously consistent.
import numpy as npprint(np.linspace(1,50,50))
You can also take a look at the data format of the elements in the array created by linspace, of course, float.
Summary
The above is all the content of this article. I hope the content of this article has some reference and learning value for everyone's learning or work. If you have any questions, please leave a message to us, thank you for your support.