numpylinspace()函数

numpylinspace()函数 首页 / Numpy入门教程 / numpylinspace()函数

它类似于排列功能。但是,它不允许我们在语法中指定步长。

取而代之的是,它仅返回指定时间段内均匀分隔的值。系统隐式计算步长。

链接:https://www.learnfk.comhttps://www.learnfk.com/numpy/numpy-linspace.html

来源:LearnFk无涯教程网

语法

numpy.linspace(start, stop, num, endpoint, retstep, dtype) 

参数

它接受以下参数。

  1. start:代表间隔的起始值。
  2. stop:代表间隔的停止值。
  3. num:要生成的间隔内均匀间隔的样本数量。默认值为50。
  4. endpoint:其真实值表示该间隔中包含停止值。
  5. rettstep:这必须是一个布尔值。表示连续数字之间的步骤和示例。
  6. dtype:表示数组项的数据类型。

返回

返回指定范围内的数组。

无涯教程网

例子1

import numpy as np
arr = np.linspace(10, 20, 5)
print("The array over the given range is ",arr)

输出:

The array over the given range is  [10.  12.5 15.  17.5 20.]

例子2

import numpy as np
arr = np.linspace(10, 20, 5, endpoint = False)
print("The array over the given range is ",arr)

输出:

The array over the given range is  [10. 12. 14. 16. 18.]

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

教程推荐

LangChain 实战课 -〔黄佳〕

编程高手必学的内存知识 -〔海纳〕

Flink核心技术与实战 -〔张利兵〕

OAuth 2.0实战课 -〔王新栋〕

罗剑锋的C++实战笔记 -〔罗剑锋〕

图解 Google V8 -〔李兵〕

零基础学Java -〔臧萌〕

重学前端 -〔程劭非(winter)〕

白话法律42讲 -〔周甲徳〕

好记忆不如烂笔头。留下您的足迹吧 :)