首页 技术 正文
技术 2022年11月17日
0 收藏 312 点赞 3,820 浏览 795 个字

在numpy中的linspace()函数类似与arange()、range()函数;

arange() 、range() 可以通过指定开始值、终值和步长创建一维等差数组,但其数组中不包含终值

通过  print(help(np.linspace))  来查看linspace() 函数

注意:

(1)np.linspace代表函数变量,帮助help文档可以查看函数的使用方法

(2)np.linspace()代表函数调用,需要传参,否则报错

numpy.linspace(start, stop[, num=50[, endpoint=True[, retstep=False[, dtype=None]]]]])

返回在指定范围内的均匀间隔的数字(组成的数组),也即返回一个等差数列

start – 起始点,

stop – 结束点

num – 元素个数,默认为50,

endpoint – 是否包含stop数值,默认为True,包含stop值;若为False,则不包含stop值

retstep – 返回值形式,默认为False,返回等差数列组,若为True,则返回结果(array([`samples`, `step`])),

dtype – 返回结果的数据类型,默认无,若无,则参考输入数据类型。

import numpy as npa = np.linspace(1,10,5,endpoint= True)print(a) # [ 1.    3.25  5.5   7.75 10.  ]b = np.linspace(1,10,5,endpoint= False)print(b) #[1.  2.8 4.6 6.4 8.2]c = np.linspace(1,10,5,retstep = False)print(c) # [ 1.    3.25  5.5   7.75 10.  ]d = np.linspace(1,10,5,retstep = True)print(d) # (array([ 1.  ,  3.25,  5.5 ,  7.75, 10.  ]), 2.25)
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,580
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918