Numpy.linspace is used to create a one-dimensional array, and is a arithmetic progression composed of a one-dimensional array, the following article is mainly about the Python numpy function in the linspace to create arithmetic progression of the relevant information, the article through the sample code introduced in very detailed, You need a friend to refer to below.
Objective
This article mainly introduces to you about Linspace to create arithmetic progression related content, share out for everyone reference study, the following words do not say, come together to see the detailed introduction bar.
Numpy.linspace is used to create a one-dimensional array composed of arithmetic progression. It has a maximum of three parameters, of course more than three.
In the first example, three parameters are used, the first parameter represents the starting point, the second parameter represents the terminating point, and the third parameter represents the number of series.
Import NumPy as Npprint (Np.linspace (1,10,10,endpoint=false))
Create an element with all 1 arithmetic progression, or arithmetic progression with all elements of 0.
Import NumPy as Npprint (Np.linspace (1,1,10))
You can use the parameter endpoint to decide whether to include a terminating value, or true if you do not set this parameter.
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 passed, the first parameter represents the starting point, the second parameter represents the end point, and the default number is 50.
Import NumPy as Npprint (Np.linspace (1,50))
To verify that we are using 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 of an array created by Linspace, of course floating-point.
Summarize