Details about how to create an equals series in linspace In the python numpy function, numpylinspace

Source: Internet
Author: User

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.

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.