Python numpy function Linspace implementation Create arithmetic progression instance sharing

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.